Skip to content

Commit 6793efd

Browse files
committed
Tweak test to work with latest source version
1 parent 2bd99e0 commit 6793efd

File tree

264 files changed

+1392
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+1392
-947
lines changed

test/langtools/tools/javac/6627362/T6627362.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* jdk.jdeps/com.sun.tools.javap
3131
*/
3232

33+
import x.java.lang.Object;
34+
3335
import java.io.*;
3436
import java.lang.reflect.*;
3537
import java.net.*;
@@ -108,8 +110,8 @@ void callValues() {
108110
Class<?> e_class = cl.loadClass("E");
109111
Method m = e_class.getMethod("values", new Class[] { });
110112
//System.err.println(m);
111-
Object o = m.invoke(null, (Object[]) null);
112-
List<Object> v = Arrays.asList((Object[]) o);
113+
x.java.lang.Object o = m.invoke(null, (x.java.lang.Object[]) null);
114+
List<x.java.lang.Object> v = Arrays.asList((Object[]) o);
113115
if (!v.toString().equals("[a, b, c]"))
114116
throw new Error("unexpected result for E.values(): " + v);
115117
} catch (Exception e) {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
25+
26+
/*
27+
* @test
28+
* @bug 8361481
29+
* @modules jdk.compiler
30+
* @summary Flexible Constructor Bodies generates a compilation error when compiling a user supplied java.lang.Object class
31+
*/
32+
33+
import java.io.*;
34+
import java.util.*;
35+
36+
public class T8361481 {
37+
static String testSrc = System.getProperty("test.src", ".");
38+
39+
public static void main(String... args) throws Exception {
40+
new T8361481().run();
41+
}
42+
43+
public void run() throws Exception {
44+
// compile modified Object.java, using patch-module to avoid errors
45+
File x = new File(testSrc, "x");
46+
String[] jcArgs = { "-d", ".", "--patch-module", "java.base=" + x.getAbsolutePath(),
47+
new File(new File(new File(x, "java"), "lang"), "Object.java").getPath()};
48+
compile(jcArgs);
49+
}
50+
51+
void compile(String... args) {
52+
int rc = com.sun.tools.javac.Main.compile(args);
53+
if (rc != 0)
54+
throw new Error("javac failed: " + Arrays.asList(args) + ": " + rc);
55+
}
56+
}
57+

test/langtools/tools/javac/ObjectEarlyContext/java/lang/Object.java renamed to test/langtools/tools/javac/ObjectEarlyContext/x/java/lang/Object.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,12 @@
2121
* questions.
2222
*/
2323

24-
/*
25-
* @test
26-
* @bug 8361481
27-
* @summary Flexible Constructor Bodies generates a compilation error when compiling a user supplied java.lang.Object class
28-
* @compile -source 8 Object.java
29-
*/
30-
3124
package java.lang;
3225

3326
public class Object {
34-
int x;
35-
3627
public Object() {
37-
x = 2;
28+
foo(); // valid, not in early constructor context
3829
}
30+
31+
void foo() { }
3932
}

test/langtools/tools/javac/SuperInit/AnonSuperLambdaCrash.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* @summary Test for compiler crash when anonymous class created in early lambda
2727
*/
2828

29+
import x.java.lang.Object;
30+
2931
public class AnonSuperLambdaCrash {
3032
class Inner {
3133
Inner() {

test/langtools/tools/javac/SuperInit/EarlyAssignments.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import x.java.lang.Object;
2+
13
/*
24
* @test /nodynamiccopyright/
35
* @bug 8325805
@@ -31,8 +33,8 @@ public Inner1a(byte value) {
3133
z = x; // FAIL - "x" belongs to superclass
3234
this.z = x; // FAIL - "x" belongs to superclass
3335
Inner1a.this.z = x; // FAIL - "x" belongs to superclass
34-
Object o1 = Inner1.this; // OK - Inner1 is an outer class
35-
Object o2 = Inner1a.this; // FAIL - Inner1a is this class
36+
x.java.lang.Object o1 = Inner1.this; // OK - Inner1 is an outer class
37+
x.java.lang.Object o2 = Inner1a.this; // FAIL - Inner1a is this class
3638
super();
3739
}
3840
public Inner1a(short value) {
@@ -64,7 +66,7 @@ public Inner2(int value) {
6466
this.y = value; // OK - "y" belongs to this class
6567
x = value; // FAIL - "x" belongs to superclass
6668
this.x = value; // FAIL - "x" belongs to superclass
67-
Object o1 = this; // FAIL - can't acces 'this' yet
69+
x.java.lang.Object o1 = this; // FAIL - can't acces 'this' yet
6870
Object o2 = Inner2.this; // FAIL - can't acces 'this' yet
6971
super();
7072
}

test/langtools/tools/javac/SuperInit/EarlyLocalCtorRef.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* @summary Allow early construction local class constructor method references
2727
*/
2828

29+
import x.java.lang.Object;
30+
2931
import java.util.function.Supplier;
3032

3133
public class EarlyLocalCtorRef {

test/langtools/tools/javac/SuperInit/MrefDoubleTrans.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* questions.
2222
*/
2323

24+
import x.java.lang.Object;
25+
2426
/*
2527
* @test
2628
* @bug 8336320

test/langtools/tools/javac/SuperInit/SuperInitFails.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
* @summary Permit additional statements before this/super in constructors
55
* @compile/fail/ref=SuperInitFails.out -XDrawDiagnostics SuperInitFails.java
66
*/
7+
import x.java.lang.Object;
8+
79
import java.util.concurrent.atomic.AtomicReference;
8-
public class SuperInitFails extends AtomicReference<Object> implements Iterable<Object> {
10+
public class SuperInitFails extends AtomicReference<x.java.lang.Object> implements Iterable<x.java.lang.Object> {
911

1012
private int x;
1113

@@ -14,7 +16,7 @@ public class SuperInitFails extends AtomicReference<Object> implements Iterable<
1416
public SuperInitFails() { // this should be OK
1517
}
1618

17-
public SuperInitFails(Object x) {
19+
public SuperInitFails(x.java.lang.Object x) {
1820
this.x = x.hashCode(); // this should be OK
1921
}
2022

@@ -104,7 +106,7 @@ public SuperInitFails(int[] x) {
104106
}
105107

106108
public SuperInitFails(long[] x) {
107-
this(Object.this); // this should FAIL
109+
this(x.java.lang.Object.this); // this should FAIL
108110
}
109111

110112
public SuperInitFails(double[] x) {
@@ -113,7 +115,7 @@ public SuperInitFails(double[] x) {
113115
}
114116

115117
public SuperInitFails(byte[][] x) {
116-
super(new Object() {
118+
super(new x.java.lang.Object() {
117119
{
118120
super(); // this should FAIL
119121
}

test/langtools/tools/javac/SuperInit/SuperInitGood.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
* @summary Test valid placements of super()/this() in constructors
2727
*/
2828

29+
import x.java.lang.Object;
30+
2931
import java.util.concurrent.atomic.AtomicReference;
3032

3133
public class SuperInitGood {
3234

33-
SuperInitGood(Object obj) {
35+
SuperInitGood(x.java.lang.Object obj) {
3436
}
3537

3638
SuperInitGood(int x) {
@@ -74,18 +76,18 @@ static class Test3 {
7476
final int z;
7577

7678
Test3() {
77-
new Object().hashCode();
78-
new Object().hashCode();
79+
new x.java.lang.Object().hashCode();
80+
new x.java.lang.Object().hashCode();
7981
super();
80-
this.x = new Object().hashCode();
81-
this.y = new Object().hashCode() % 17;
82+
this.x = new x.java.lang.Object().hashCode();
83+
this.y = new x.java.lang.Object().hashCode() % 17;
8284
this.z = this.x + this.y;
8385
}
8486
}
8587

8688
// Reference within constructor to outer class that's also my superclass
8789
class Test5 extends SuperInitGood {
88-
Test5(Object obj) {
90+
Test5(x.java.lang.Object obj) {
8991
if (obj == null)
9092
throw new IllegalArgumentException();
9193
super(SuperInitGood.this); // NOT a 'this' reference
@@ -170,7 +172,7 @@ public Byte get() {
170172
// Qualified super() invocation
171173
public static class Test9 extends Test5 {
172174

173-
public Test9(SuperInitGood implicit, Object obj) {
175+
public Test9(SuperInitGood implicit, x.java.lang.Object obj) {
174176
obj.hashCode();
175177
implicit.super(obj);
176178
}
@@ -211,12 +213,12 @@ public Sub(int j) {
211213

212214
// Nested super()'s requiring initialization code appended
213215
public static class Test13 extends SuperInitGood {
214-
final int x = new Object().hashCode();
216+
final int x = new x.java.lang.Object().hashCode();
215217
Test13() {
216-
super(new Object() {
218+
super(new x.java.lang.Object() {
217219
public void foo() {
218220
class Bar {
219-
final int y = new Object().hashCode();
221+
final int y = new x.java.lang.Object().hashCode();
220222
Bar() {
221223
super();
222224
}
@@ -278,11 +280,11 @@ public Test15c(Test15 a, String name) {
278280
// Mixing up outer instances, proxies, and initializers
279281
public static class Test16 {
280282

281-
final String x = String.valueOf(new Object().hashCode());
283+
final String x = String.valueOf(new x.java.lang.Object().hashCode());
282284

283285
public void run() {
284286

285-
final String y = String.valueOf(new Object().hashCode());
287+
final String y = String.valueOf(new x.java.lang.Object().hashCode());
286288

287289
class Sub {
288290

@@ -318,7 +320,7 @@ String z() {
318320
}
319321
}
320322

321-
final String z = String.valueOf(new Object().hashCode());
323+
final String z = String.valueOf(new x.java.lang.Object().hashCode());
322324

323325
final Sub[] subs = new Sub[] {
324326
new Sub(z, 1),
@@ -365,20 +367,20 @@ record ValueHolder(int value) {
365367
}
366368

367369
// Exceptions thrown by initializer block
368-
public static class Test18 extends AtomicReference<Object> {
370+
public static class Test18 extends AtomicReference<x.java.lang.Object> {
369371

370372
{
371373
if ((this.get().hashCode() % 3) == 0)
372374
throw new MyException();
373375
}
374376

375-
public Test18(Object obj) throws MyException {
377+
public Test18(x.java.lang.Object obj) throws MyException {
376378
super(obj);
377379
}
378380

379381
public Test18(boolean fail) throws MyException {
380-
Object obj;
381-
for (obj = new Object(); true; obj = new Object()) {
382+
x.java.lang.Object obj;
383+
for (obj = new x.java.lang.Object(); true; obj = new Object()) {
382384
if (((obj.hashCode() % 3) == 0) != fail)
383385
continue;
384386
break;

test/langtools/tools/javac/diags/ArgTypeCompilerFactory.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
import com.sun.tools.javac.code.*;
3535
import com.sun.tools.javac.file.*;
3636
import com.sun.tools.javac.main.Main;
37-
import com.sun.tools.javac.main.JavaCompiler;
3837
import com.sun.tools.javac.parser.Tokens.TokenKind;
3938
import com.sun.tools.javac.util.*;
40-
import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
39+
import x.java.lang.Object;
40+
4141
import javax.lang.model.SourceVersion;
4242

4343
/**
@@ -222,11 +222,11 @@ public String formatMessage(JCDiagnostic d, Locale l) {
222222

223223
private void formatMessage(JCDiagnostic d, StringBuilder buf) {
224224
String key = d.getCode();
225-
Object[] args = d.getArgs();
225+
x.java.lang.Object[] args = d.getArgs();
226226
// report the primary arg types, without recursing into diag fragments
227227
buf.append(getKeyArgsString(key, args));
228228
// report details for any diagnostic fragments
229-
for (Object arg: args) {
229+
for (x.java.lang.Object arg: args) {
230230
if (arg instanceof JCDiagnostic) {
231231
buf.append("\n");
232232
formatMessage((JCDiagnostic) arg, buf);
@@ -256,7 +256,7 @@ static void preRegister(Context context) {
256256
public JavacMessages make(Context c) {
257257
return new ArgTypeMessages(c) {
258258
@Override
259-
public String getLocalizedString(Locale l, String key, Object... args) {
259+
public String getLocalizedString(Locale l, String key, x.java.lang.Object... args) {
260260
return getKeyArgsString(key, args);
261261
}
262262
};
@@ -272,11 +272,11 @@ public String getLocalizedString(Locale l, String key, Object... args) {
272272
/**
273273
* Utility method to generate a string for key and args
274274
*/
275-
static String getKeyArgsString(String key, Object... args) {
275+
static String getKeyArgsString(String key, x.java.lang.Object... args) {
276276
StringBuilder buf = new StringBuilder();
277277
buf.append(key);
278278
String sep = ": ";
279-
for (Object o : args) {
279+
for (x.java.lang.Object o : args) {
280280
buf.append(sep);
281281
buf.append(getArgTypeOrStringValue(o));
282282
sep = ", ";
@@ -286,7 +286,7 @@ static String getKeyArgsString(String key, Object... args) {
286286

287287
static boolean showStringValues = false;
288288

289-
static String getArgTypeOrStringValue(Object o) {
289+
static String getArgTypeOrStringValue(x.java.lang.Object o) {
290290
if (showStringValues && o instanceof String)
291291
return "\"" + o + "\"";
292292
return getArgType(o);

test/langtools/tools/javac/diags/CompletionFailureInDiags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
import toolbox.Task.Expect;
4343
import toolbox.Task.OutputKind;
4444
import toolbox.TestRunner;
45-
import toolbox.TestRunner.Test;
4645
import toolbox.ToolBox;
46+
import x.java.lang.Object;
4747

4848
public class CompletionFailureInDiags extends TestRunner {
4949

test/langtools/tools/javac/diags/DiagnosticRewriterTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* @compile/fail/ref=DiagnosticRewriterTest.out -Xdiags:compact -XDrawDiagnostics DiagnosticRewriterTest.java
66
*/
77

8+
import x.java.lang.Object;
9+
810
class DiagnosticRewriterTest {
911
void test() {
1012
new Object() {

test/langtools/tools/javac/diags/DiagnosticRewriterTest2.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* @compile/fail/ref=DiagnosticRewriterTest2.out -Xdiags:compact -XDrawDiagnostics DiagnosticRewriterTest2.java
66
*/
77

8+
import x.java.lang.Object;
9+
810
class DiagnosticRewriterTest2 {
911
class Bar {
1012
Bar(Object o) { }

0 commit comments

Comments
 (0)