java 错误:找不到常见的超类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2591602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: Can't find common super class of
提问by PatlaDJ
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:
我正在尝试使用 Proguard 处理 MS Windows 桌面应用程序(使用 Eclipse 提供的 SWT 库的 Java 6 SE)。我收到以下严重错误:
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.
当我试图用谷歌搜索这个错误时,它只出现在整个网络上的两个地方,这让我非常惊讶。我是使用 Proguard 和 Java 代码优化工具的新手。任何解决此问题的想法和建议,将不胜感激。提前致谢。
Above error is now fixed,with the using of "-dontskipnonpubliclibraryclasses"
以上错误现已修复,使用“-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
回答by JRL
Try adding the option -dontskipnonpubliclibraryclassesto your command line.
尝试将选项添加-dontskipnonpubliclibraryclasses到命令行。
From the Proguard Manual:
来自Proguard 手册:
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-dontskipnonpubliclibraryclassesoption, and maybe even the-dontskipnonpubliclibraryclassmembersoption. The graphical user interface has checkboxes for these settings.
回答by Marcus Adams
Try removing the -dontnoteoption. You may have duplicate definitions that you aren't receiving warnings for, or maybe you're ignoring the warnings.
尝试删除该-dontnote选项。您可能有未收到警告的重复定义,或者您可能忽略了警告。
回答by Petarian
I had the same issue but did not try specifying the -dontskipnonpubliclibraryclassesor any other option to get fixed. My problem was occurring on java.lang.StringBufferclass, which was very weird. StringBufferclass was being used all over the project and the error did not occur anywhere else.
我遇到了同样的问题,但没有尝试指定-dontskipnonpubliclibraryclasses或任何其他选项来解决。我的问题发生在java.lang.StringBuffer课堂上,这很奇怪。StringBuffer整个项目都在使用类,并且在其他任何地方都没有发生错误。
To fix, all I did was to move the scope of StringBuffer.
为了解决这个问题,我所做的只是移动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.
我有一种感觉,这与 ProGuard 以及它如何解析代码有关。
回答by Habib
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:
我尝试保留(-keep 选项)两个类都没有成功。基于其他线程,我发现最小的解决方案是禁用变量优化:
-optimizations !code/allocation/variable
This lets me compile successfully, but has its drawbacks.
这让我可以成功编译,但也有它的缺点。

