[
https://issues.apache.org/jira/browse/JXR-170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Slawomir Jaranowski reassigned JXR-170:
---------------------------------------
Assignee: Slawomir Jaranowski
> NullPointerException while parsing Java 15 multi-line String source
> -------------------------------------------------------------------
>
> Key: JXR-170
> URL: https://issues.apache.org/jira/browse/JXR-170
> Project: Maven JXR
> Issue Type: Bug
> Components: maven2 jxr plugin
> Affects Versions: 3.2.0
> Reporter: Markus Spann
> Assignee: Slawomir Jaranowski
> Priority: Minor
>
> 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{}}}.
> {noformat}
> 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)
> {noformat}
> Command-line:
> {noformat}
> mvn org.apache.maven.plugins:maven-jxr-plugin:3.2.0:aggregate{noformat}
> Cause: variable name is null in line 128 of
> {{{}org.apache.maven.jxr.pacman.JavaFileImpl{}}}:
> {code:java}
> if ( name.charAt( name.length() - 1 ) == '.' ){code}
> 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:java}
> Code code = new Code().addFormat("""
> import {0};
> import java.util.List;
> """,
> additionalImportClass.getName()
> );
> {code}
> 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:
> {code:java}
> <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>
> {code}
> The plugin should not encounter run-time exceptions and ignore content of
> multi-line strings.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)