Skip to content

Commit 08fc5f7

Browse files
committed
Adjust 1.6.1 'testRunningBrokenCode_pr102733*' tests ECJ Java 22
Initially, these tests made sure that an old AJC bug causing incompatibility to ECJ when using `-proceedOnError` was fixed and there were no regressions. See also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=102733 Now with the Java 22 changes for JEP 463 "Implicitly Declared Classes and Instance Main Methods (Second Preview)" in JDT Core, source code is parsed into a significantly different AST structure than before, even when using compiler targets < 22. See also https://openjdk.org/jeps/463. One test has been temporarily adjusted to the byte code created by ECJ/AJC now. TODO: Revert/adjust after this upstream bug has been fixed: eclipse-jdt/eclipse.jdt.core#2205 Signed-off-by: Alexander Kriegisch <[email protected]>
1 parent dee8028 commit 08fc5f7

File tree

5 files changed

+110
-62
lines changed

5 files changed

+110
-62
lines changed

tests/bugs161/pr102733/C3.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
public class C3 {
3+
public static void main(String[] argv) {}
4+
5+
blahblahpackage pack;
6+
}
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import java.lang.reflect.Method;
2-
31
public class Invoker {
4-
public static void main(String[] args) throws Throwable {
5-
try {
6-
C.main(null);
7-
} catch (Throwable t) {
8-
boolean failedCorrectly = t.toString().indexOf("Unresolved compilation")!=-1;
9-
if (failedCorrectly) return;
10-
throw t;
11-
}
12-
throw new RuntimeException("Call to main should have failed!");
13-
}
14-
}
2+
public static void main(String[] args) throws Throwable {
3+
try {
4+
new C();
5+
}
6+
catch (Throwable t) {
7+
boolean failedCorrectly =
8+
t.toString().contains("Unresolved compilation problem") &&
9+
t.toString().contains("The method main cannot be declared static");
10+
if (failedCorrectly)
11+
return;
12+
throw new RuntimeException("Constructor call should have failed!", t);
13+
}
14+
}
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class Invoker3 {
2+
public static void main(String[] args) throws Throwable {
3+
try {
4+
C3.main(null);
5+
}
6+
catch (Throwable t) {
7+
boolean failedCorrectly = t.toString().indexOf("Unresolved compilation") != -1;
8+
if (failedCorrectly)
9+
return;
10+
throw new RuntimeException("Call to main should have failed!", t);
11+
}
12+
try {
13+
new C3();
14+
}
15+
catch (Throwable t) {
16+
boolean failedCorrectly =
17+
t.toString().contains("Unresolved compilation problem") &&
18+
t.toString().contains("blahblahpackage cannot be resolved to a type");
19+
if (failedCorrectly)
20+
return;
21+
throw new RuntimeException("Constructor call should have failed!", t);
22+
}
23+
}
24+
}

tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ public void testDeow_pr237381_2() {
5454
runTest("ataspectj deow - 2");
5555
}
5656

57+
public void testRunningBrokenCode_pr102733() {
58+
// TODO: Revert, when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2205 is fixed
59+
runTest("running broken code");
60+
}
61+
5762
public void testRunningBrokenCode_pr102733_2() {
5863
runTest("running broken code - 2");
5964
}
6065

61-
public void testRunningBrokenCode_pr102733() {
62-
runTest("running broken code");
66+
public void testRunningBrokenCode_pr102733_3() {
67+
// TODO: Adjust as necessary, when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2205 is fixed
68+
runTest("running broken code - 3");
6369
}
6470

6571
public void testErrorOnNonabstractGenericAtAspectJAspect_pr168982() {

tests/src/test/resources/org/aspectj/systemtest/ajc161/ajc161.xml

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
<ajc-test dir="bugs161/pr173978" title="lv table for around">
1212
<compile files="TestAroundAspect.java Test.java" options="-1.5"/>
1313
</ajc-test>
14-
14+
1515
<ajc-test dir="bugs161/pr237419" title="generics ataround">
1616
<compile files="problem/aspect/AnyAspect.java problem/SpecificService.java problem/Specific.java problem/GenericService.java problem/Generic.java" options="-1.5"/>
1717
<run class="problem.SpecificService"/>
1818
</ajc-test>
19-
19+
2020
<ajc-test dir="bugs161/pr203367" title="generic marker match">
2121
<compile files="CantMatchOnInterfaceIntroducedToGenericClass.java" options="-1.5"/>
2222
<run class="bug.CantMatchOnInterfaceIntroducedToGenericClass"/>
2323
</ajc-test>
24-
24+
2525
<ajc-test dir="bugs161/pr198196" title="super itds - 2">
2626
<compile files="Marker.java Foo.java MarkerAspect2.java"/>
2727
<run class="Foo">
@@ -35,65 +35,76 @@
3535
</stdout>
3636
</run>
3737
</ajc-test>
38-
38+
3939
<ajc-test dir="bugs161/pr198196" title="super itds - 3">
4040
<compile files="Marker.java Foo.java MarkerAspect1.java"/>
4141
<run class="Foo"/>
4242
</ajc-test>
43-
43+
4444
<ajc-test dir="bugs161/pr198196" title="super itds - 4">
4545
<compile files="Marker.java Foo.java MarkerAspect3.java"/>
4646
<run class="Foo"/>
4747
</ajc-test>
48-
48+
4949
<ajc-test dir="bugs161/pr134425" title="super itds">
5050
<compile files="Derived.java Base.java"/>
5151
<run class="pkg.Derived"/>
5252
</ajc-test>
53-
53+
5454
<ajc-test dir="bugs161/pr237381" title="ataspectj deow - 1">
5555
<compile files="Deow1.java" options="-1.5">
5656
<message kind="warning" line="7" text="fromX"/>
5757
<message kind="warning" line="15" text="fromY"/>
5858
</compile>
5959
</ajc-test>
60-
60+
6161
<ajc-test dir="bugs161/pr237381" title="ataspectj deow - 2">
6262
<compile files="Deow2.java" options="-1.5">
6363
<message kind="error" line="7" text="fromX"/>
6464
<message kind="error" line="15" text="fromY"/>
6565
</compile>
6666
</ajc-test>
67-
67+
6868
<ajc-test dir="bugs161/pr102733" title="running broken code">
69-
<compile files="Invoker.java C.java" options="-proceedOnError">
70-
<message kind="error" line="2" text="Syntax error"/>
69+
<compile files="C.java" options="-proceedOnError">
70+
<message file="C.java" kind="error" line="1" text="Unnamed Classes and Instance Main Methods"/>
71+
<message file="C.java" kind="error" line="2" text="blahblahpackage cannot be resolved to a type"/>
72+
<message file="C.java" kind="error" line="2" text="Implicitly declared class must have a candidate main method"/>
73+
<message file="C.java" kind="error" line="2" text="The method main cannot be declared static; static methods can only be declared in a static or top level type"/>
7174
</compile>
75+
<compile files="Invoker.java"/>
7276
<run class="Invoker"/>
7377
</ajc-test>
74-
78+
7579
<ajc-test dir="bugs161/pr102733" title="running broken code - 2">
7680
<compile files="Invoker2.java C2.java" options="-proceedOnError">
7781
<message kind="error" line="5"/>
7882
</compile>
7983
<run class="Invoker2"/>
8084
</ajc-test>
81-
85+
86+
<ajc-test dir="bugs161/pr102733" title="running broken code - 3">
87+
<compile files="C3.java Invoker3.java" options="-proceedOnError">
88+
<message file="C3.java" kind="error" line="5" text="blahblahpackage cannot be resolved to a type"/>
89+
</compile>
90+
<run class="Invoker3"/>
91+
</ajc-test>
92+
8293
<ajc-test dir="bugs161/pr168982" title="error on non-abstract generic ataspectj aspect">
8394
<compile files="TracingAspect2.java" options="-1.5">
8495
<message kind="error" line="9"/>
8596
</compile>
8697
</ajc-test>
87-
98+
8899
<ajc-test dir="bugs161/pr234933" title="ignoring type level suppress">
89100
<compile files="Foobar.java" options="-1.5 -Xlint:error"/>
90101
</ajc-test>
91-
102+
92103
<ajc-test dir="bugs161/pr223226" title="duplicate method signature - 2">
93104
<compile files="AspectX.java BInterface.java FooInterface.java AspectXMarker.java Foo.java Test.java" options="-1.5"/>
94105
<run class="Test"/>
95106
</ajc-test>
96-
107+
97108
<ajc-test dir="bugs161/pr223226" title="duplicate method signature">
98109
<compile files="AspectX.java BInterface.java FooInterface.java AspectXMarker.java Foo.java Test.java" options="">
99110
<message kind="error" line="1"/>
@@ -106,7 +117,7 @@
106117
<ajc-test dir="bugs161/pr197719" title="protected methods and around advice - again - 2">
107118
<compile files="test/aspects/C1.java test/aspects/C3.java test/aspects/MyAnn.java test/aspects/MyAnnAspect.java test/aspects2/C2.java" options="-1.5 -showWeaveInfo">
108119
<message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects.C1' (C1.java:12) "/>
109-
120+
110121
<!-- first of these through accessor - so line number wrong and target wrong -->
111122
<message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects2.C2' (C2.java:1) "/><!-- was line 18 -->
112123
<message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects2.C2' (C2.java:8) "/>
@@ -123,7 +134,7 @@
123134
<run class="test.aspects.C3">
124135
</run>
125136
</ajc-test>
126-
137+
127138
<ajc-test dir="bugs161/pr197719" title="protected methods and around advice - again">
128139
<compile files="A.java B.java X.java" options="-1.5"/>
129140
<run class="b.B">
@@ -139,24 +150,24 @@
139150
<compile files="A.java B.java C.java X.java" options="-1.5"/>
140151
<run class="a.C"/>
141152
</ajc-test>
142-
153+
143154
<ajc-test dir="bugs161/pr174385" title="static strings in annotation pointcuts">
144155
<compile files="StaticFinalStringInPointcutAspect.java" options="-1.5"/>
145156
<run class="bug.StaticFinalStringInPointcutAspect"/>
146157
</ajc-test>
147-
158+
148159
<ajc-test dir="bugs161/pr199130" title="complex bounds on generic aspect - 1">
149160
<compile files="Simple.java" options="-1.5"/>
150161
<run class="Simple">
151162
</run>
152163
</ajc-test>
153-
164+
154165
<ajc-test dir="bugs161/pr199130" title="complex bounds on generic aspect - 2">
155166
<compile files="Complex.java" options="-1.5"/>
156167
<run class="Complex">
157168
</run>
158169
</ajc-test>
159-
170+
160171
<ajc-test dir="bugs161/pr199130" title="complex bounds on generic aspect - 3">
161172
<compile files="Complex2.java" options="-1.5"/>
162173
<run class="Complex2">
@@ -172,7 +183,7 @@
172183
<ajc-test dir="bugs161/pr235829" title="crazy generics and inner types">
173184
<compile files="Main.java a/Adapter.java a/b/Adapter.java" options="-1.5"/>
174185
<run class="Main"/>
175-
</ajc-test>
186+
</ajc-test>
176187

177188
<ajc-test dir="bugs161/pr235597" title="annotation exposure and generics">
178189
<compile files="AnnotationTest1.java SomeAnnotation.java SomeAspect.java" options="-1.5"/>
@@ -196,12 +207,12 @@
196207
</stdout>
197208
</run>
198209
</ajc-test>
199-
210+
200211

201212
<ajc-test dir="bugs161/pr235204" title="incorrect call relationship">
202213
<compile files="RecursiveCatcher.java" options="-1.5 -emacssym"/>
203214
</ajc-test>
204-
215+
205216
<ajc-test dir="bugs161/pr233838" title="itd precedence - 1">
206217
<compile files="Z.java" options="-1.5"/>
207218
<run class="Z">
@@ -219,7 +230,7 @@
219230
</stdout>
220231
</run>
221232
</ajc-test>
222-
233+
223234

224235
<ajc-test dir="bugs161/pr227401" title="getfield problem with generics">
225236
<compile files="Instrumentation.java Fails.java" options="-1.5"/>
@@ -236,8 +247,8 @@
236247
<line text="22"/>
237248
</stdout>
238249
</run>
239-
</ajc-test>
240-
250+
</ajc-test>
251+
241252
<ajc-test dir="bugs161/pr231478" title="generic abstract aspects">
242253
<compile files="Base.java Sub.java AbstractComponent.java AbstractWindow.java" options="-1.5"/>
243254
</ajc-test>
@@ -255,7 +266,7 @@
255266
<line text="set of NO field"/>
256267
</stderr>
257268
</run>
258-
</ajc-test>
269+
</ajc-test>
259270

260271
<ajc-test dir="bugs161/pr231187x" title="generics bounds decp">
261272
<compile files="Cement.java ConcreteClass.java SuperClass.java SuperClassAspect.aj WetCement.java Main.java" options="-1.5"/>
@@ -264,14 +275,14 @@
264275
<line text="ran!"/>
265276
</stdout>
266277
</run>
267-
</ajc-test>
268-
278+
</ajc-test>
279+
269280
<ajc-test dir="bugs161/pr231187x" title="generics bounds decp - 2">
270281
<compile files="Cement.java ConcreteClass.java SuperClass.java WetCement.java" options="-1.5">
271282
<message kind="error" text="The type WetCement is not a valid substitute for the bounded parameter"/>
272283
</compile>
273-
</ajc-test>
274-
284+
</ajc-test>
285+
275286
<ajc-test dir="bugs161/pr230134" title="ltw inherited cflow">
276287
<compile files="HW.java"/>
277288
<compile files="SimpleTracing.java Tracing.java HelloWorldTracing.java" outjar="foo.jar" options="-1.4"/>
@@ -281,21 +292,21 @@
281292
</stdout>
282293
</run>
283294
</ajc-test>
284-
295+
285296
<ajc-test dir="bugs161/pr229910" title="around advice on field set">
286297
<compile files="Test.java" options="-1.5"/>
287298
<run class="Test"/>
288-
</ajc-test>
289-
299+
</ajc-test>
300+
290301
<ajc-test dir="bugs161/pr226567" title="pipeline compilation and generic return type">
291302
<compile files="BarAspect.aj Foo.java Bar.java" options="-1.5"/>
292303
<compile files="BarAspect.aj Bar.java Foo.java" options="-1.5"/>
293-
</ajc-test>
294-
304+
</ajc-test>
305+
295306
<ajc-test dir="bugs161/pr235505" title="privileged generic aspect">
296307
<compile files="A.java" options="-1.5"/>
297-
</ajc-test>
298-
308+
</ajc-test>
309+
299310
<ajc-test dir="bugs161/pr235505" title="privileged generic aspect - 2">
300311
<compile files="B.java" options="-1.5"/>
301312
<run class="B">
@@ -304,18 +315,18 @@
304315
<line text="Hello World"/>
305316
</stdout>
306317
</run>
307-
</ajc-test>
308-
318+
</ajc-test>
319+
309320
<ajc-test dir="bugs161/pr64222" title="parsing around advice no return">
310321
<compile files="C.java" options="-1.5">
311322
<message kind="error" line="6" text="to complete around advice declaration"/>
312323
</compile>
313-
</ajc-test>
324+
</ajc-test>
314325

315326
<ajc-test dir="bugs161/pr159268" title="before array name">
316327
<compile files="C.java" options="-1.5"/>
317-
</ajc-test>
318-
319-
328+
</ajc-test>
329+
330+
320331

321-
</suite>
332+
</suite>

0 commit comments

Comments
 (0)