Uploaded image for project: 'Maven JXR'
  1. Maven JXR
  2. JXR-170

NullPointerException while parsing Java 15 multi-line String source

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.0
    • 3.3.0
    • maven2 jxr plugin
    • None

    Description

      I am encountering a NullPointerException in the aggregate goal while parsing a Java source that makes use of new Java 15 multi-line Strings containing a reserved Java keyword i.e. import.

      Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "name" is null
          at org.apache.maven.jxr.pacman.JavaFileImpl.parseRecursive (JavaFileImpl.java:128)
          at org.apache.maven.jxr.pacman.JavaFileImpl.parseRecursive (JavaFileImpl.java:144)
          at org.apache.maven.jxr.pacman.JavaFileImpl.parse (JavaFileImpl.java:74)
          at org.apache.maven.jxr.pacman.JavaFileImpl.<init> (JavaFileImpl.java:59)
      

      Command-line: 

      mvn org.apache.maven.plugins:maven-jxr-plugin:3.2.0:aggregate

      Cause: variable name is null in line 128 of org.apache.maven.jxr.pacman.JavaFileImpl:

              if ( name.charAt( name.length() - 1 ) == '.' )

      This is the cause of the run-time exception.
      The real cause however is more likely a parsing issue.

      The plugin stumbles at following statement in my project, a code generator (code abbreviated for clarity):

              Code code = new Code().addFormat("""
                  import {0};
                  import java.util.List;
                  """,
                  additionalImportClass.getName()
                  );
      

      Same error can be observed in older versions of the plugin.

      The only work-around I found was to exclude this source from jxr in its Maven configuration:

              <pluginManagement>
                  <plugins>
                      <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-jxr-plugin</artifactId>
                          <configuration>
                              <linkJavadoc>false</linkJavadoc>
                              <skip>false</skip>
                              <excludes>
                                  <exclude>**/ClassFailinginJxr.java</exclude>
                              </excludes>
                          </configuration>
                      </plugin>
                  </plugins>
              </pluginManagement>
      

      The plugin should not encounter run-time exceptions and ignore content of multi-line strings.

      Attachments

        Issue Links

          Activity

            People

              sjaranowski Slawomir Jaranowski
              spannjp Markus Spann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: