我在jar文件上使用Proguard对其进行了模糊处理。它在Windows和Linux上都能很好地工作,但是在AIX上部署时会出现以下错误。
2019-06-29 13:09:12:192 [ERROR] [main:ID=1]:[null:-1] java.lang.ClassFormatError: JVMCFRE114 field name is invalid; class=Messaging/broadcaster/OracleWriterMessageBroadcaster, offset=0
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:346)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:718)
at java.net.URLClassLoader.access$400(URLClassLoader.java:95)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1169)
at java.security.AccessController.doPrivileged(AccessController.java:742)
at java.net.URLClassLoader.findClass(URLClassLoader.java:601)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:792)
at java.lang.ClassLoader.loadClass(ClassLoader.java:766)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
at java.lang.ClassLoader.loadClass(ClassLoader.java:747)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:257)
at UniversalGprsClientService.ProcessMonitor.a(Unknown Source)
at UniversalGprsClientService.ProcessMonitor.main(Unknown Source)
这是发生错误的代码段:
Class<?> c = Class.forName(sClassName);
Constructor<?> cons = c.getConstructor();
IMessageBroadcaster clsBroadcaster = (IMessageBroadcaster) cons.newInstance();
clsBroadcaster.setAppSettings(clsAppSettings);
clsBroadcaster.setProcessMonitor(clsMonitor);
return clsBroadcaster;
我想可以通过对类进行硬编码来解决,但这意味着失去其提供的灵活性。