Java fails to import enums in a case where imports references the dedicated enum instead of the parent package as shown by the following example: --- file main.java ---- import Test.Enum; public class main { public Test.Enum myEnum; } --------- file Test.java --------- public class Test { public enum Enum { A, B, C } } Reproducible: Always Steps to Reproduce: 1. start umbrello 2. switch active language to 'java' 3. import the appended file main.java 4. Inspect the imported type 'Enum' Actual Results: type 'Enum' is imported as class instead of being an enum. Expected Results: Type 'Enum' should be imported as java type enum. umbrello version 2.9.5 is the oldest version I have currently access to; the bug itself may also be in older version.
Created attachment 100984 [details] Test.java
Created attachment 100985 [details] main.java
Git commit 372b1e0203847cc8ff7dc79a2a799d9a79b215f9 by Oliver Kellogg. Committed on 11/01/2020 at 15:10. Pushed by okellogg into branch 'release/19.12'. Fix crash on importing Java code attached to bug 368453: The example uses the global scope and JavaImport crashes on adding objects in the global scope without prior defined Java package. umbrello/codeimport/import_utils.{h,cpp} - Add function globalScope() returning the package of the global scope. umbrello/codeimport/nativeimportbase.cpp - In function parseFile() do not push a null pointer as the global scope; instead, push Import_Utils::globalScope(). M +9 -0 umbrello/codeimport/import_utils.cpp M +2 -0 umbrello/codeimport/import_utils.h M +1 -1 umbrello/codeimport/nativeimportbase.cpp https://invent.kde.org/kde/umbrello/commit/372b1e0203847cc8ff7dc79a2a799d9a79b215f9
Observation for narrowing down the problem: After importing the two files, the treeview shows <Class> main <Package> Test | > <Class> Enum (empty) > <Class> Test | > <Enumeration> Enum That looks wrong. If I rename main.java to Umain.java and redo the import, the treeview shows: <Class> Test | > <Enumeration> Enum <Class> Umain That looks right. In the in the first case, main.java is imported before Test.java but in the second case, Test.java is imported after Umain.java.
(In reply to Oliver Kellogg from comment #4) > In the in the first case, main.java is imported before Test.java > but in the second case, Test.java is imported after Umain.java. Oops typo: In the second case, Test.java is imported *before* Umain.java.