[MCOMPILER-556] debug=false still includes line numbers / documentation is misleading
Marcono1234 opened MCOMPILER-556 and commented
The issue
The documentation of the debug parameter says:
Set to
trueto include debugging information in the compiled class files.
This suggests that setting it to false does not include debugging information. However, that is not actually the case. The class files still include debugging information, such as line numbers.
You can only get rid of debug information by setting debug=true and debuglevel=none, which is rather confusing.
As side note: Setting debug=false seems to have some effect because it does omit LocalVariableTable (and maybe more?) but it might still be confusing that it does not exclude all debug information.
(This might be a clone of MCOMPILER-114, but that is more than 10 years old and was closed back then during Jira clean-up, so it is not clear how much of that would still apply to the current state of the Maven Compiler Plugin.)
Reproduction steps
(Tested with JDK 17 and Maven 3.9.1)
Create a sample project with
```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version>
<build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> <configuration> <release>11</release> </configuration> </plugin> </plugins> </pluginManagement> </build> </project>
-
class Test { public void test() { System.out.println("hello"); } }
1. Run
mvn clean compile "-Dmaven.compiler.debug=false"
1. Inspect the compiled class file
javap -v target/classes/Test.class
(x) Bug: The class data contains `LineNumberTable`
1. Now run with `debug=true` and `debuglevel=none`
mvn clean compile "-Dmaven.compiler.debug=true" "-Dmaven.compiler.debuglevel=none"
1. Inspect the compiled class file
javap -v target/classes/Test.class
(i) Now as desired the class data does not contain `LineNumberTable`
## Expected behavior
Either the documentation of the `debug` parameter should be improved and it should be explicitly mentioned that `debug=false` will still include debug information, and instead `debug=true` and `debuglevel=none` has to be used.
Or better (\?), the behavior for `debug=false` should be changed to exclude all debug information. This should hopefully not be a breaking change since the default value of `debug` is `true`, so this would only affect users who most likely did not want to include debug information in the first place.
But maybe there are users who explicitly rely on the current `debug=false` behavior.
---
**Affects:** 3.11.0
**Issue Links:**
- [MCOMPILER-114](https://issues.apache.org/jira/browse/MCOMPILER-114) Setting the debug option to false still compiles the code with line numbers resulting in increased class file.