Error: Can't find common super class of

匿名 (未验证) 提交于 2019-12-03 02:20:02

问题:

I am trying to process with Proguard a MS Windows desktop application (Java 6 SE using the SWT lib provided by Eclipse). And I get the following critical error:

Unexpected error while performing partial evaluation: Class = [org/eclipse/swt/widgets/DateTime] Method = [<init>(Lorg/eclipse/swt/widgets/Composite;I)V] Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/StringBuffer] and [org/eclipse/swt/internal/win32/TCHAR]) Error: Can't find common super class of [java/lang/StringBuffer] and [org/eclipse/swt/internal/win32/TCHAR] ---------------------------- 

When I tried to Google the error, it came out only on two spots on the entire web, that astonished me greatly. I am newbie using Proguard and Java code optimization tools at all. Any thoughts and suggestions how to fix this, will be appreciated. Thanks in advance.

Above error is now fixed, with the using of "-dontskipnonpubliclibraryclasses"

--final update:

I still get another error now. The whole output is now the folowing:

D:\eclipse_projs\java_obfuscate\gci>gci.bat ProGuard, version 4.4 Reading program jar [D:\eclipse_projs\java_obfuscate\gci\gci.jar] Reading library jar [D:\jre1.6.0_07\lib\rt.jar] Unexpected error while evaluating instruction:   Class       = [org/eclipse/swt/widgets/Synchronizer]   Method      = [runAsyncMessages(Z)Z]   Instruction = [60] aload_1 v1   Exception   = [java.lang.IllegalArgumentException] (Value is not a reference value [proguard.evaluation.value.UnknownIntegerValue]) Unexpected error while performing partial evaluation:   Class       = [org/eclipse/swt/widgets/Synchronizer]   Method      = [runAsyncMessages(Z)Z]   Exception   = [java.lang.IllegalArgumentException] (Value is not a reference value [proguard.evaluation.value.UnknownIntegerValue])  Error: Value is not a reference value [proguard.evaluation.value.UnknownIntegerValue]  D:\eclipse_projs\java_obfuscate\gci> 

This is a problem that i cannot understand for certain :( any help will be much appreciated.

The options I use are the following:

-dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers -optimizationpasses 3 -overloadaggressively -repackageclasses '' -allowaccessmodification -dontnote 

回答1:

Try adding the option -dontskipnonpubliclibraryclasses to your command line.

From the Proguard Manual:

Limitations

For efficiency, ProGuard always ignores any private or package visible library classes while reading library jars. If any of them are extended by public library classes, and then extended again by input classes, ProGuard will complain it can't find them. In that case, you'll have to use the -dontskipnonpubliclibraryclasses option, and maybe even the -dontskipnonpubliclibraryclassmembers option. The graphical user interface has checkboxes for these settings.


回答2:

I had the same issue but did not try specifying the -dontskipnonpubliclibraryclasses or any other option to get fixed. My problem was occurring on java.lang.StringBuffer class, which was very weird. StringBuffer class was being used all over the project and the error did not occur anywhere else.

To fix, all I did was to move the scope of StringBuffer.

OLD Code - with error:

function(){    if(condition){        StringBuffer buffer = new StringBuffer();        //additional code    }else if(condition){        StringBuffer buffer = new StringBuffer();        //additional code    } } 

NEW Code - without problem.

function(){     StringBuffer buffer = new StringBuffer();         if(condition){             //additional code        }else if(condition){             //additional code        }     } 

I have a feeling this has to do something with ProGuard and how it parses the code.



回答3:

Try removing the -dontnote option. You may have duplicate definitions that you aren't receiving warnings for, or maybe you're ignoring the warnings.



回答4:

I had an issue with an application depending on various other projects. I tried the listed solutions, but none of them help. Based on tests, the shrinking and preverify steps were correctly running, the optimization threw the error:

> java.io.IOException: java.lang.IllegalArgumentException: Can't find common super class of [java/io/File] (with 2 known super classes) and [org/antlr/v4/runtime/tree/gui/TreeViewer] (with 1 known super classes) 

I tried keeping (-keep options) both classes without any success. Based on other threads I found the minimal solution is to disable variable optimization:

-optimizations !code/allocation/variable 

This lets me compile successfully, but has its drawbacks.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!