为什么我的javap输出与你的jar文件不同? [英] Why is my javap output different than yours for the same jar file?

查看:200
本文介绍了为什么我的javap输出与你的jar文件不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法编译对jline-0.9.94具有maven依赖性的代码。具体来说,我正在编译 Groovy 1.7.6 它的默认Ant目标并得到以下错误:

$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Java运行环境版本:1.6.0_22
[echo] Java运行时环境供应商:Apple Inc.
[echo] Ant版本:2008年6月27日编译的Apache Ant版本1.7.1
[echo]操作系统名称:Mac OS X
[echo]操作系统架构:x86_64
[echo]操作系统版本:10.6.6
[echo] ldhanson2 / tmp / groovy-1.7.6
[echo] Java Home:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
[...]
-stagedcompile-groovy:
[groovyc]将166个源文件编译为/Users/ldhanson2/tmp/groovy-1.7.6/target/classes
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:
[groovyc]使用javac编译期间编译错误。
[groovyc] /Users/ldhanson2/tmp/groovy-1.7.6/src/main/groovy/ui/InteractiveShell.java:222:找不到符号
[groovyc] symbol:method setDefaultPrompt(java .lang.String)
[groovyc] location:class jline.ConsoleReader
[groovyc] reader.setDefaultPrompt(groovy>);
[groovyc] ^

jline依赖被正确解析,但奇怪的是setDefaultPrompt方法没有出现在jar中:

  $ javap -classpath target / lib / compile / jline-0.9.94.jar jline.ConsoleReader | grep setDefaultPrompt 
$

(其他方法也会从javap输出中丢失,但setDefaultPrompt )

我试着从我的本地maven仓库中删除jline并再次尝试,但无济于事。我还检查了 Maven Central



奇怪的是,我可以将jar文件复制到另一台机器上(Sun),并执行完全相同的操作步骤,并按预期方式查看jar文件中的setDefaultPrompt方法。其他人也在Mac上成功执行了相同的步骤。



在我的机器上会发生什么情况会阻止Java工具链查看jar文件中包含的方法?

解决方案

我的机器上有同样的问题(编译JRuby,而不是Groovy)。

解决我的问题的方法是,我在/Library/Java/Extensions/jline-0_9_5.jar发现了一个古老的jline jar文件,所以我将其烧毁并替换为更新的版本。


I'm having trouble compiling code which has a maven dependency on jline-0.9.94. Specifically, I'm compiling Groovy 1.7.6 using its default Ant target and getting the following error:

[...]
-banner:
     [echo] Java Runtime Environment version: 1.6.0_22
     [echo] Java Runtime Environment vendor: Apple Inc.
     [echo] Ant version: Apache Ant version 1.7.1 compiled on June 27 2008
     [echo] Operating system name: Mac OS X
     [echo] Operating system architecture: x86_64
     [echo] Operating system version: 10.6.6
     [echo] Base directory: /Users/ldhanson2/tmp/groovy-1.7.6
     [echo] Java Home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
[...]
-stagedcompile-groovy:
  [groovyc] Compiling 166 source files to /Users/ldhanson2/tmp/groovy-1.7.6/target/classes
  [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  [groovyc] Compile error during compilation with javac.
  [groovyc] /Users/ldhanson2/tmp/groovy-1.7.6/src/main/groovy/ui/InteractiveShell.java:222: cannot find symbol
  [groovyc] symbol  : method setDefaultPrompt(java.lang.String)
  [groovyc] location: class jline.ConsoleReader
  [groovyc]         reader.setDefaultPrompt("groovy> ");
  [groovyc]               ^

The jline dependency is correctly resolved, but strangely the setDefaultPrompt method does not appear to be present in the jar:

$ javap -classpath target/lib/compile/jline-0.9.94.jar jline.ConsoleReader | grep setDefaultPrompt
$ 

(Other methods appear missing from the javap output as well, but setDefaultPrompt is the one breaking my build.)

I've tried wiping out jline from my local maven repository and trying again, to no avail. I've also checked the jline jarfile from Maven Central as well as a mirror with the same results.

Oddly, I can copy the jar file to a different machine (a Sun) and perform the exact same steps and I see the setDefaultPrompt method in the jar file as expected. Others have successfully performed the same steps on a Mac as well.

What could be happening on my machine which would prevent the Java toolchain from seeing methods contained in the jar file?

解决方案

I had the same problem on my machine (compiling JRuby, rather than Groovy).

The solution to my problem was that I discovered an ancient jline jar at /Library/Java/Extensions/jline-0_9_5.jar, so I nuked it and replaced it with a more modern version.

这篇关于为什么我的javap输出与你的jar文件不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆