From 974582f7e5bb227b3bfc81f87299f665bc0d1a2a Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Fri, 17 May 2024 10:49:45 +0200 Subject: [PATCH] Fix #333 --- resources/bytecode/javFiles/Bug333.jav | 11 +++++++++++ .../SyntaxTreeGenerator/StatementGenerator.java | 1 + src/test/java/TestComplete.java | 7 +++++++ 3 files changed, 19 insertions(+) create mode 100644 resources/bytecode/javFiles/Bug333.jav diff --git a/resources/bytecode/javFiles/Bug333.jav b/resources/bytecode/javFiles/Bug333.jav new file mode 100644 index 00000000..244e8a66 --- /dev/null +++ b/resources/bytecode/javFiles/Bug333.jav @@ -0,0 +1,11 @@ +import java.lang.String; + +public class Bug333 { + public static String Bar = "Bar"; +} + +class Bar { + public bar() { + String s = Bug333.Bar; + } +} \ No newline at end of file diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index 54f6b680..abe38580 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -804,6 +804,7 @@ public class StatementGenerator { // Check for Classname: if (reg.contains(whole)) { receiver = generateStaticClassName(whole, offset); + break; } whole += "."; } diff --git a/src/test/java/TestComplete.java b/src/test/java/TestComplete.java index de1d24ef..bc844bc0 100644 --- a/src/test/java/TestComplete.java +++ b/src/test/java/TestComplete.java @@ -1108,4 +1108,11 @@ public class TestComplete { var clazz = classFiles.get("Bug328"); var instance = clazz.getDeclaredConstructor().newInstance(); } + + @Test + public void testBug333() throws Exception { + var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug333.jav"); + var clazz = classFiles.get("Bug333"); + var instance = clazz.getDeclaredConstructor().newInstance(); + } }