matthiasblaesing commented on issue #6826:
URL: https://github.com/apache/netbeans/issues/6826#issuecomment-1856713174

   @mbien thank you. I was able to narrow this down some more. Maven project 
with source: 
[test.zip](https://github.com/apache/netbeans/files/13678553/test.zip)
   
   The reproducer holds a single class:
   
   ```java
   package test;
   
   public class Demo  {
   
       public Demo() {
           Test2.test();
       }
   
   }
   ```
   
   This is used to trigger the error. The "knob" for checking is in the pom:
   
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <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>test</groupId>
       <artifactId>test</artifactId>
       <version>1.0-SNAPSHOT</version>
       <packaging>jar</packaging>
   
       <properties>
           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>
   
       <build>
           <plugins>
               <plugin>
                   <artifactId>maven-compiler-plugin</artifactId>
                   <version>3.11.0</version>
                   <configuration>
                       <release>17</release>
   <!--                    <compilerArgs>
                           <arg>-Xlint:all</arg>
                       </compilerArgs>-->
                   </configuration>
               </plugin>
           </plugins>
       </build>
   </project>
   ```
   
   With the shown configuration, all is fine. When opening the test project, 
NetBeans correctly flags `Demo.java` as broken and in the file `Test2` is 
marked "Symbol not found" (there might be a different sentence, I translated 
from my german output). 
   
   Now remove the comment symbols around the `compilerArgs` element in the pom. 
When I do that, I get instantly an exception that looks remarkably similar to 
the one shown here. When you know acknowledge the exception, you can change the 
`Test2` in `Demo.java` for example to `Test2231`. The diagnoses about the 
"Symbol not found" goes away, the exception pops up.
   
   Add the comment symbols around `compilerArgs` again, acknowledge the 
exception, and diagnosis comes back, exception are not thrown anymore.
   
   To me this looks like either a bug in the `ThisEscapeAnalyser`, which makes 
assumptions, that only hold if it is used on a tree without error or a bug in 
NetBeans integration, which should not call into the analyser phase of javac, 
when the tree has errors.
   
   Anyway, this needs to be fixed.
   
   @lahodaj could you please have a look at this? You worked in the area of the 
`ThisEscapeAnalyzer` and might have an idea how to fix this.
   
   @jjazzboss I modified the main `pom.xml` for your project like this:
   
   ```diff
   --- a/pom.xml
   +++ b/pom.xml
   @@ -45,7 +45,7 @@
            <jjazzlab.javac.fork>false</jjazzlab.javac.fork>
            
<jjazzlab.javac.showDeprecation>true</jjazzlab.javac.showDeprecation>
            <jjazzlab.javac.showWarnings>true</jjazzlab.javac.showWarnings>
   -        <jjazzlab.javac.xlint>-Xlint:all</jjazzlab.javac.xlint>
   +        <jjazzlab.javac.xlint></jjazzlab.javac.xlint>
            
<jjazzlab.surefire.plugin.version>3.1.0</jjazzlab.surefire.plugin.version>
            <jjazzlab.surefire.skipTests>true</jjazzlab.surefire.skipTests>
            <jjazzlab.forceEnglish>false</jjazzlab.forceEnglish>
   ```
   
   And after switching the project to JDK 17, building it, restarting once, the 
project opens clean for me on a NetBeans, that is not that far from master. 
Given the analysis above, this seems sensible.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to