java.lang.IllegalStateException with classes defined inside and outside namespace

+1 vote
asked Feb 6 in Bug by barometz (120 points)

The following example:

@startuml test
Pin -- Component
namespace Data {

  Component -- Pin
}
@enduml

Leads to an exception:

PS C:\(..)> java -jar scripts/plantuml.jar -v figures/test.puml
(0.000 - 15 Mo) 12 Mo - PlantUML Version 1.2020.00
(0.007 - 15 Mo) 12 Mo - GraphicsEnvironment.isHeadless() false
(0.010 - 15 Mo) 12 Mo - Found 1 files
(0.010 - 15 Mo) 12 Mo - Working on C:\(..)\figures\test.puml
(0.018 - 15 Mo) 11 Mo - Setting current dir: .
(0.019 - 15 Mo) 11 Mo - Setting current dir: C:\(..)\figures
(0.019 - 15 Mo) 11 Mo - Using default charset
(0.023 - 15 Mo) 11 Mo - Reading from test.puml
(0.049 - 15 Mo) 13 Mo - Reading file: figures\test.puml
(0.051 - 15 Mo) 12 Mo - name from block=test
(0.051 - 15 Mo) 12 Mo - Checking=test
(0.051 - 15 Mo) 12 Mo - f=test
(0.052 - 15 Mo) 12 Mo - Relative, so let's change it
(0.052 - 15 Mo) 12 Mo - f=C:\(..)\figures\test
(0.052 - 15 Mo) 12 Mo - It's not a directory
(0.052 - 15 Mo) 12 Mo - test is not taken as a directory
(0.053 - 15 Mo) 12 Mo - We are going to put data in C:\(..)\figures\test[0]
(0.193 - 15 Mo) 10 Mo - Compilation duration 139
(0.193 - 15 Mo) 10 Mo - Regex total/invoked/compiled 106/106/39
(0.193 - 15 Mo) 10 Mo - Matches created 28
(0.194 - 15 Mo) 9 Mo - Creating file: C:\(..)\figures\test.png
java.lang.IllegalStateException
        at net.sourceforge.plantuml.svek.Bibliotekon.getShapeUid(Bibliotekon.java:130)
        at net.sourceforge.plantuml.cucadiagram.Link.getEntityPort1(Link.java:256)
        at net.sourceforge.plantuml.svek.Line.<init>(Line.java:230)
        at net.sourceforge.plantuml.svek.GeneralImageBuilder.buildImage(GeneralImageBuilder.java:373)
        at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFileInternal(CucaDiagramFileMakerSvek.java:105)
        at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFile(CucaDiagramFileMakerSvek.java:71)
        at net.sourceforge.plantuml.cucadiagram.CucaDiagram.exportDiagramInternal(CucaDiagram.java:612)
        at net.sourceforge.plantuml.classdiagram.ClassDiagram.exportDiagramInternal(ClassDiagram.java:194)
        at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:201)
        at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)
        at net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(PSystemUtils.java:235)
        at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:91)
        at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:159)
        at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:520)
        at net.sourceforge.plantuml.Run.processArgs(Run.java:404)
        at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:372)
        at net.sourceforge.plantuml.Run.main(Run.java:188)
(0.448 - 15 Mo) 7 Mo - Starting Graphviz process [c:\Program Files (x86)\Graphviz2.38\bin\dot.exe, -Tsvg]
(0.448 - 15 Mo) 7 Mo - DotString size: 539
(0.535 - 15 Mo) 7 Mo - Ending process ok
(0.535 - 15 Mo) 7 Mo - Ending Graphviz process
(0.571 - 15 Mo) 9 Mo - Creating image 173x243
(0.602 - 15 Mo) 8 Mo - Ok for com.sun.imageio.plugins.png.PNGMetadata
(1.130 - 15 Mo) 6 Mo - Number of image(s): 1

The resulting file is incomplete, the out-of-namespace classes are not rendered. I'm using version 1.2020.0, it works correctly with whatever's integrated in the VS Code plantuml extension.

commented Feb 6 by barometz (120 points)

Addendum: it's gone when I write the in-namespace classes as:

namespace Data {
  Component -- Data.Pin
}

1 Answer

0 votes
answered Jun 9 by sjoerdtalsma (180 points)
edited Jun 9 by sjoerdtalsma
I posted this also as an issue on github (with a link to this forum post) as that allows diagrams to be included more easily: https://github.com/plantuml/plantuml/issues/337
...