I am using Proguard to obfuscate my project, and I am using some property descriptor in my Java 8 project. The problem is Java Property Descriptor uses a small constructor which assumes what will be the method name :
public PropertyDescriptor(String propertyName, Class<?> beanClass)
throws IntrospectionException {
this(propertyName, beanClass,
Introspector.IS_PREFIX + NameGenerator.capitalize(propertyName),
Introspector.SET_PREFIX + NameGenerator.capitalize(propertyName));
}
For example, my property name will be “actor” in a “ActorFactory.class” and it will try to finds the method “getActor” and “setActor” in “ActorFactory.class”. The problem is my property name is a static String, so I will always call the property descriptor like this :
private final static ACTOR_PROPERTY = "actor";
private final PropertyDescriptor actorPropertyDescriptor = new PropertyDescriptor(
ACTOR_PROPERTY , ActorFactory.class);
So when I start the application, I encounter this error :
[ERROR] - 2024-01-11 17:06:04,506 com.example.a.B - JavaFX-Launcher
java.beans.IntrospectionException: Method not found: getActor
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:107)
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:71)
...
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
This is my actual proguard configuration :
#path to jars that will be obfuscate
-injars target/deploy/libToObfuscate/(**.jar;)
#path to the obfuscated jars will be put
-outjars target/deploy/lib/(**.jar;)
#We keep references to classes that are not in those package
-keep class !com.example.** { *; }
#to keep all annotations (exemple @inject, @post construcy,....) in obfuscated classes
-keepattributes *Annotation*,Signature,RuntimeVisibleAnnotations,InnerClasses,EnclosingMethod,SourceFile
-keep @javax.persistence.** class * {
*;
}
# Rename FXML files together with related views
-adaptresourcefilenames **.fxml,**.css
#adapt in resources files package names where it is needed
-adaptresourcefilecontents
-adaptclassstrings
# Keep names of fields marked with @FXML attribute
-keepclassmembers class * {
@javafx.fxml.FXML *;
}
-keepclassmembernames class * {
@javafx.fxml.FXML *;
}
#keep unobfuscated all parameters from messages classes
-keepclassmembers class * extends org.eclipse.osgi.util.NLS {
<fields>;
}
#keep class if it extends Node from JavaFX, because proguard doesn't detect and change custom xml tag (ex: HeaderPane)
-keep class * extends javafx.scene.Node { *; }
-keepdirectories
-useuniqueclassmembernames
-dontnote
-dontshrink
-dontoptimize
-dontwarn
# To force uppercase of class name, because JavaFX FXML can't import lowercase named class
-classobfuscationdictionary obfuscationClassNames.txt
Any idea how can I obfuscate this part ? Thank you very much !