设置Maven Java编译器debug为false不删除行号表? [英] Setting Maven Java compiler debug to false does not remove line number table?

查看:815
本文介绍了设置Maven Java编译器debug为false不删除行号表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是我缺乏理解,但我会假设这样做在一个Maven Java项目将禁用所有调试信息进入类文件:

 < plugin> 
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< configuration>
< debug> false< / debug>
< / configuration>
< / plugin>

但是,我只是测试它,并且当局部变量表不见了,去了,行号表仍然存在。我做了一个 javap -l MyClass ,仍然有像:

  protected com.mycorp.myapp.randomMethod(); 
LineNumberTable:
line 197:0
line 68:4
line 69:9
line 70:14
line 198:19

显然,这些东西还在里面....我想。

解决方案

这看起来像是 MCOMPILER-114 。使用以下似乎与插件的版本2.3.2工作:

 < plugin& 
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.3.2< / version>
< configuration>
< debug> true< / debug>
< debuglevel> none< / debuglevel>
< / configuration>
< / plugin>

(是啊,我知道,这不是文档说的, / p>

Perhaps this is my lack of understanding, but I would have assumed that doing this in a Maven Java project would disable all debug info from going into the Class file:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <debug>false</debug>
                </configuration>
            </plugin>

However, I just tested it and while the local variable table is gone, and the source file reference is gone, the line number table is still present. I did a javap -l MyClass and still got things like:

protected com.mycorp.myapp.randomMethod();
  LineNumberTable: 
   line 197: 0
   line 68: 4
   line 69: 9
   line 70: 14
   line 198: 19

Clearly, the stuff is still in there....I think.

解决方案

This looks like MCOMPILER-114. Using the following seems to work with the version 2.3.2 of the plugin:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <debug>true</debug>
      <debuglevel>none</debuglevel>
    </configuration>
  </plugin>

(yeah, I know, that's not what the documentation is saying, but well, it works)

这篇关于设置Maven Java编译器debug为false不删除行号表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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