plantuml / plantuml

Generate diagrams from textual description
https://plantuml.com
Other
9.73k stars 881 forks source link

Bibliotekon.getNodeUid throws IllegalStateException #337

Closed sjoerdtalsma closed 3 years ago

sjoerdtalsma commented 3 years ago

Please forgive the repost of the forum post: https://forum.plantuml.net/10804/illegalstateexception-classes-defined-outside-namespace

as github lets me post decent images of the diagrams :+1:

The following exception regularly occurs when referring to a class in another package:

java.lang.IllegalStateException
    at net.sourceforge.plantuml.svek.Bibliotekon.getNodeUid(Bibliotekon.java:127)
    at net.sourceforge.plantuml.cucadiagram.Link.getEntityPort1(Link.java:251)
    at net.sourceforge.plantuml.svek.Line.<init>(Line.java:191)
    at net.sourceforge.plantuml.svek.GeneralImageBuilder.buildImage(GeneralImageBuilder.java:406)
    at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFileInternal(CucaDiagramFileMakerSvek.java:107)
    at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.createFile(CucaDiagramFileMakerSvek.java:72)
    at net.sourceforge.plantuml.cucadiagram.CucaDiagram.exportDiagramInternal(CucaDiagram.java:646)
    at net.sourceforge.plantuml.classdiagram.ClassDiagram.exportDiagramInternal(ClassDiagram.java:191)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:196)
        ... (many more lines)

(PlantUML version 1.2020.12)

I have extracted a simple diagram that reproduces it:

@startuml
    namespace issues {
        interface issues.MySupplier<T>

        class issues.MySet<T> {
            +iterator(): Iterator<T>
            +size(): int
        }

        java.util.function.Supplier <|-- issues.MySupplier
        java.util.AbstractSet <|-- issues.MySet
    }

    namespace java.util.function {
        interface Supplier<T> {
            {abstract} +get(): T
        }
    }

    namespace java.util {
        abstract class AbstractSet<E>
    }
@enduml

This results in the above exception and the interface java.util.function.Supplier completely missing from the diagram: image

Again, sorry for the repost.

sjoerdtalsma commented 3 years ago

Leaving out the relations provides a slightly better result, although the nested namespace is not recognized unfortunately.

image

sjoerdtalsma commented 3 years ago

Adding the relations again, but this time outside the issues namespace almost gives the desired effect:

@startuml
    namespace issues {
        interface issues.MySupplier<T>

        class issues.MySet<T> {
            +iterator(): Iterator<T>
            +size(): int
        }
    }

    namespace java.util.function {
        interface Supplier<T> {
            {abstract} +get(): T
        }
    }

    namespace java.util {
        abstract class AbstractSet<E>
    }

    java.util.function.Supplier <|-- issues.MySupplier
    java.util.AbstractSet <|-- issues.MySet
@enduml

image

sjoerdtalsma commented 3 years ago

Nesting the namespaces explicitly as follows results in the intended diagram:

    namespace java.util {
        abstract class AbstractSet<E>

        namespace function {
            interface Supplier<T> {
                {abstract} +get(): T
            }
        }
    }

image

sjoerdtalsma commented 3 years ago

The funny thing is, the original diagram I started with did work at some point in the past, I just cannot recall in which version of PlantUML that was.

Is there some change in behaviour with regard to namespace vs. package I need to catch up on?

bobjacobsen commented 3 years ago

The problem with the test file in 1st comment is present in v1.2019.9 and not present in v1.2019.8. Git bisect settles on:

Bisecting: 0 revisions left to test after this (roughly 0 steps)
[c10dc0a6f75a60b6f8f91ee7a9e5251075687f9d] Merge pull request #245 from leechor/master
arnaudroques commented 3 years ago

We have made some changes to prepare this. This is indeed an unexpected regression and we are going to investigate. Sorry about that!

sjoerdtalsma commented 3 years ago

Thank you for the link! For what it’s worth, I think it is an improvement although it’s causing the regression now.

I think Umldoclet ought to switch to the new package notation so we’re also more in line with standard UML. I think that should fix our issue by using proper diagram syntax.

In the mean time, the IllegalStateException probably should be fixed anyway, so I’ll leave this issue open for the moment if that is okay.

Op 9 jun. 2020 om 21:19 heeft arnaudroques notifications@github.com het volgende geschreven:

 We have made some changes to prepare this. This is indeed an unexpected regression and we are going to investigate. Sorry about that!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sjoerdtalsma commented 3 years ago

@bobjacobsen thank you for finding the version, I hadn’t gone back that far yet 😉

sjoerdtalsma commented 3 years ago

This could be (but might not) be related to #298 ?

arnaudroques commented 3 years ago

This should be fixed in last beta http://beta.plantuml.net/plantuml.jar Tell us if it's not working for you !

bobjacobsen commented 3 years ago

Thank you! That's fixed it.

sjoerdtalsma commented 3 years ago

Closing this, as the behaviour in 1.2020.15 is now effectively the same as the last-known working version 1.2019.8.

sjoerdtalsma commented 3 years ago

@arnaudroques Thanks again for fixing this!