[JXR-179] Classes with curly braces in class-level annotations are missing in allclasses and package html
- Dominant language
- Java
- Stars
- 16
- Forks
- 30
- Avg merge
- 5h 16m
- Merged PRs (30d)
- 5
Description
**[Michael Stollhans](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER302230)** opened **[JXR-179](https://issues.apache.org/jira/browse/JXR-179?redirect=false)** and commented
Classes with curly braces in class-level annotations are misssing in allclasses-frame.html and package-frame.html of the xref report. However, the html files for those classes are created.
### Steps to reproduce:
Create a maven project with to dependencies:
```java
org.projectlombok
lombok
1.18.28
provided
javax.persistence
javax.persistence-api
2.2
```
Configure reporting with maven-jxr-plugin.
Create two java files:
```java
import javax.persistence.Entity;
import lombok.Data;
@Entity
@Data
public class A {
private String name;
private B b;
}
```
```java
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import lombok.Data;
@Entity
@Table(name = "C_TABLE", indexes = { @Index(name = "NameIndex", columnList = "firstname,lastname") })
@Data
public class B {
private String firstname;
private String lastname;
}
```
Run "mvn jxr:jxr".
Result:
* All html files of the xref report are created as expected
* Only class A is listed in allclasses-frame.html and package-frame.html. Class B is missing.
### Assumed cause:
I did some debugging with the maven-jxr library. Eventually I think the cause is the attribute _indexes_ of the _@Table_ annotation. The attribute has an array type.
I suspect the error to happen in the class JavaFileImpl of the maven-jxr project.
```java
public class JavaFileImpl extends JavaFile {
...
private void parseRecursive(String nestedPrefix, StreamTokenizer stok) throws IOException {
...
while (stok.nextToken() != StreamTokenizer.TT_EOF) {
if (stok.sval == null) {
if (stok.ttype == '{') {
openBracesCount++;
} else if (stok.ttype == '}') {
if (--openBracesCount == 0) {
// break out of recursive
return;
}
}
continue;
} else {
...
}
}
...
}
```
I think the cause is the return statement with the comment "break out of recursive". After parsing the annotation with the curly braces the tokenizer stops and the parser does not find the class declaration in the file.
Later in the method a ClassType object should be created but that never happens in this case.
---
**Affects:** 3.3.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in JavaFileImpl.parseRecursive and reproduce the report with the two Java classes and `mvn jxr:jxr`. Trace how curly braces in the class-level annotation affect parsing, then verify that the generated HTML for class B is listed in both allclasses-frame.html and package-frame.html.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100