Skip to content

Commit 4acbd98

Browse files
committed
8202100: Merge vm/share/InMemoryJavaCompiler w/ jdk/test/lib/compiler/InMemoryJavaCompiler
Backport-of: 7404ddf
1 parent 81b0d41 commit 4acbd98

File tree

12 files changed

+142
-198
lines changed

12 files changed

+142
-198
lines changed

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaProxyCallerIsHidden.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,8 @@
3737
* jdk/test/lib/compiler/InMemoryJavaCompiler
3838
* jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1
3939
* jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper
40-
* jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject
40+
* jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile
41+
* jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile
4142
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
4243
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LambdaProxyCallerIsHidden
4344
*/

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RedefineCallerClassTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,8 @@ public class RedefineCallerClassTest extends DynamicArchiveTestBase {
5252
"jdk/test/lib/compiler/InMemoryJavaCompiler",
5353
"jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper",
5454
"jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1",
55-
"jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject"
55+
"jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile",
56+
"jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile"
5657
};
5758

5859
public static void main(String[] args) throws Exception {

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RegularHiddenClass.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,8 @@
3535
* jdk/test/lib/compiler/InMemoryJavaCompiler
3636
* jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1
3737
* jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper
38-
* jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject
38+
* jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile
39+
* jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile
3940
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
4041
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. RegularHiddenClass
4142
*/

test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineBasicTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,8 @@ public class RedefineBasicTest {
4747
"jdk/test/lib/compiler/InMemoryJavaCompiler",
4848
"jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper",
4949
"jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1",
50-
"jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject"
50+
"jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile",
51+
"jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile"
5152
};
5253

5354
public static void main(String[] args) throws Exception {

test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineRunningMethods_Shared.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,8 @@ public class RedefineRunningMethods_Shared {
4848
"jdk/test/lib/compiler/InMemoryJavaCompiler",
4949
"jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper",
5050
"jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1",
51-
"jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject"
51+
"jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile",
52+
"jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile"
5253
};
5354

5455
public static void main(String[] args) throws Exception {

test/hotspot/jtreg/vmTestbase/gc/g1/unloading/bytecode/BytecodeGeneratorFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
2626
import java.util.Map;
2727
import java.util.Random;
2828

29-
import vm.share.InMemoryJavaCompiler;
29+
import jdk.test.lib.compiler.InMemoryJavaCompiler;
3030

3131
/**
3232
* BytecodeFactory that employs in memory compilation.
@@ -44,12 +44,10 @@ public BytecodeGeneratorFactory(long seed) {
4444

4545
@Override
4646
public Bytecode createBytecode(String className) {
47-
Map<String, CharSequence> sources = new HashMap<String, CharSequence>();
48-
sources.put(className, sourceGenerator.generateSource(className,
47+
byte[] bytecode = InMemoryJavaCompiler.compile(className, sourceGenerator.generateSource(className,
4948
"public static void main() { System.out.println(\"From main method in in-mem-compiled code " + random.nextGaussian() +
5049
" + str_bytesToReplace0 str_bytesToReplace1\"); }\n " +
5150
"public static int methodForCompilation(Object object) { int i = object.hashCode(); i = i * 2000 / 1994 + 153; return i; }\n"));
52-
byte[] bytecode = InMemoryJavaCompiler.compile(sources).values().iterator().next();
5351
return new Bytecode(className, bytecode);
5452
}
5553

test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
import nsk.share.test.Stresser;
6161
import nsk.share.test.TestBase;
6262
import nsk.share.test.Tests;
63-
import vm.share.InMemoryJavaCompiler;
63+
import jdk.test.lib.compiler.InMemoryJavaCompiler;
6464

6565
/**
6666
* Test checks that static fields will be initialized in new loaded class. Test performs in loop the following routine:
@@ -210,9 +210,7 @@ private void checkStaticFields(Class clazz) {
210210
}
211211

212212
private byte[] generateAndCompile(int[] fieldQuantities) {
213-
Map<String, CharSequence> sources = new HashMap<String, CharSequence>();
214-
sources.put("A", generateSource(fieldQuantities));
215-
return InMemoryJavaCompiler.compile(sources).values().iterator().next();
213+
return InMemoryJavaCompiler.compile("A", generateSource(fieldQuantities));
216214
}
217215

218216
private StringBuffer generateSource(int[] fieldQuantities) {

test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
4343

4444
import nsk.share.gc.GCTestBase;
4545
import nsk.share.test.*;
46-
import vm.share.InMemoryJavaCompiler;
46+
import jdk.test.lib.compiler.InMemoryJavaCompiler;
4747

4848
/**
4949
* There is a data structure named "dictionary" in class BlockFreelist. It stores
@@ -178,10 +178,8 @@ public void run() {
178178
}
179179

180180
private byte[] generateAndCompile() {
181-
Map<String, CharSequence> sources = new HashMap<String, CharSequence>();
182181
String className = "MyClass" + classesCounter.incrementAndGet();
183-
sources.put(className, generateSource(className));
184-
return InMemoryJavaCompiler.compile(sources).values().iterator().next();
182+
return InMemoryJavaCompiler.compile(className, generateSource(className));
185183
}
186184

187185
private CharSequence generateSource(String className) {

test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
2424

2525
import java.util.*;
2626

27-
import vm.share.InMemoryJavaCompiler;
27+
import jdk.test.lib.compiler.InMemoryJavaCompiler;
2828
import jdk.test.lib.Utils;
2929

3030
public class GenerateHierarchyHelper {

test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,6 @@
2121
* questions.
2222
*/
2323

24-
//package nsk.jvmti.RedefineClasses.StressRedefine;
2524
package nsk.jvmti.RedefineClasses;
2625

2726

@@ -41,7 +40,7 @@
4140
import nsk.share.test.Stresser;
4241
import nsk.share.test.Tests;
4342

44-
import vm.share.InMemoryJavaCompiler;
43+
import jdk.test.lib.compiler.InMemoryJavaCompiler;
4544

4645
/**
4746
* There is a data structure named "dictionary" in class BlockFreelist. It stores
@@ -203,9 +202,7 @@ private static ThreadFactory virtualThreadFactory() {
203202
}
204203

205204
private static byte[] generateAndCompile() {
206-
Map<String, CharSequence> sources = new HashMap<String, CharSequence>();
207-
sources.put(GenerateSourceHelper.CLASS_NAME, GenerateSourceHelper.generateSource());
208-
return InMemoryJavaCompiler.compile(sources).values().iterator().next();
205+
return InMemoryJavaCompiler.compile(GenerateSourceHelper.CLASS_NAME, GenerateSourceHelper.generateSource());
209206
}
210207

211208
// Auxiliary classloader. Used only once at the beginning.

0 commit comments

Comments
 (0)