-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Describe the bug
For both YUML and PlantUML, the method getPackages will fail if any class contains anonymous inner classes.
To Reproduce
Steps to reproduce the behavior:
- Create class with anonymous class
package org.test.stuff;
public class Stuff {
public static void doThing() {
// anonymous class
new Runnable() {public void run() {}}.run();
}
}- Generate UML
PlantUML generator = new PlantUML();
generator.addPackages("org.test.stuff");
String diagramText = generator.generateClassDiagram();Expected behavior
java.lang.IllegalArgumentException: Cannot be empty!
at br.com.luque.java2uml.core.classdiagram.reflection.model.BaseItem.setName(BaseItem.java:23)
at br.com.luque.java2uml.core.classdiagram.reflection.model.BaseItem.<init>(BaseItem.java:10)
at br.com.luque.java2uml.core.classdiagram.reflection.model.Clazz.<init>(Clazz.java:12)
at br.com.luque.java2uml.core.classdiagram.reflection.model.ScopedClazz.<init>(ScopedClazz.java:14)
at br.com.luque.java2uml.core.classdiagram.reflection.model.ClazzPool.getFor(ClazzPool.java:26)
at br.com.luque.java2uml.plantuml.writer.classdiagram.PlantUMLWriter.generateClassDiagramUsing(PlantUMLWriter.java:23)
at br.com.luque.java2uml.plantuml.PlantUML.generateClassDiagram(PlantUML.java:47)
at br.com.luque.java2uml.plantuml.PlantUML.generateClassDiagram(PlantUML.java:59)
Screenshots
If applicable, add screenshots to help explain your problem.
(please complete the following information):
- Version 1.0.0 commit c3659ef
c3659ef | Leandro Luque | 2025-02-09T18:27:53+01:00 | fix: fix issue with visibility detector
Additional context
The setup above will generate the following classes from classloader.
org.test.stuff.Stuff.class
org.test.stuff.Stuff$1.class
For a quick fix you can just exclude '$' containing resources by default.
That's also how I worked around this issue, by listing the classes recursively and using addClasses instead of addPackages.
Metadata
Metadata
Assignees
Labels
No labels