Need guidance to understand why method is being removed

I have the following class.

package myPackage.handlers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import org.eclipse.core.commands.AbstractHandler;

public class MyHandler extends AbstractHandler {

	public Object execute( ExecutionEvent event ) throws ExecutionException {
		ActionListener myListener = new ActionListener() {
			public void actionPerformed( ActionEvent e ) {
				// do something here

		Timer myTimer = new Timer( 2000, myListener );

When it is obfuscated, the anonymous class (new ActionListener) is placed on a new file (MyHandler$1.class)

If I compile it for Java 8, the actionPerformed method is there.
But if compile it for Java 17, the actionPerformed method is removed, leading to java.lang.AbstractMethodErrors being thrown at runtime.

When compiling for Java 8, the ProGuard settings are these:

-keepattributes SourceFile, LineNumberTable, RuntimeVisibleParameterAnnotations, RuntimeVisibleAnnotations
-keep class * implements org.eclipse.core.commands.AbstractHandler

When compiling for Java 17, the settings are the same, with the addition of:

-libraryjars C:/pathToMyJava/jmods/java.base.jmod(!**.jar;!module-info.class)

Some tests I did while trying to figure it out:

  • Add some other methods on the anonymous class: none of them is present on the .class file.
  • Add a call to myListener.actionPerformed() in the end of the execute method: the line is not present on the MyHandler.class file.
  • Add a call to System.out.println( myListener ) in the end of the execute method: the line is not present on the MyHandler.class file.

Iā€™d like to get some insight on what could I do to understand why is the method being removed.

The keep rule seems to be wrong. Did you try using the Keepclassmembers instead ? -keepclassmembers class com.example.SomeClass {
Also, please consider using the Proguard playground to.test your Keep rules :

1 Like

Thanks for the answer.

I discovered a solution for my problem.

The thing was that the java.awt.event.ActionListener class is part of a different Java .jmod file.

I changed the -libraryjars setting, from

-libraryjars C:/pathToMyJava/jmods/java.base.jmod(!**.jar;!module-info.class)


-libraryjars <java.home>/jmods/(**.jmod;!**.jar;!module-info.class)
1 Like