Skip to content
Permalink
Browse files

8235970: [TESTBUG] Remove dependency of sun.tools.jar from RedefineCl…

…assHelper

Reviewed-by: alanb
  • Loading branch information
iklam committed Dec 16, 2019
1 parent 8b2453f commit 1b4b652408583c73db5c36852cf42e3a0198ba2d
@@ -28,7 +28,6 @@
* make sure class redefinition works with CDS.
* @requires vm.cds
* @library /test/lib /test/hotspot/jtreg/serviceability/jvmti/RedefineClasses /test/hotspot/jtreg/runtime/cds/appcds
* @modules jdk.jartool/sun.tools.jar
* @run driver RedefineClassHelper
* @build sun.hotspot.WhiteBox RedefineBasic
* @run driver RedefineBasicTest
@@ -28,7 +28,6 @@
* make sure class redefinition works with CDS.
* @requires vm.cds
* @library /test/lib /test/hotspot/jtreg/serviceability/jvmti/RedefineClasses /test/hotspot/jtreg/runtime/cds/appcds
* @modules jdk.jartool/sun.tools.jar
* @run driver RedefineClassHelper
* @build sun.hotspot.WhiteBox RedefineRunningMethods_SharedHelper
* @run driver RedefineRunningMethods_Shared
@@ -29,7 +29,6 @@
* @library /test/lib
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @run main RedefineClassHelper
* @run main/othervm -Xmx256m -XX:MaxMetaspaceSize=64m -javaagent:redefineagent.jar -Xlog:all=trace:file=all.log RedefineClasses
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @run main RedefineClassHelper
* @run main/othervm -javaagent:redefineagent.jar RedefineClassTest
*/
@@ -29,7 +29,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @compile ../../NamedBuffer.java
* @compile redef/Xost.java
* @run main RedefineClassHelper
@@ -29,7 +29,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @compile ../NamedBuffer.java
* @compile redef/Xost.java
* @run main RedefineClassHelper
@@ -29,7 +29,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @compile ../NamedBuffer.java
* @compile redef/Xost.java
* @run main RedefineClassHelper
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @compile ../NamedBuffer.java
* @run main RedefineClassHelper
* @compile Host/Host.java
@@ -31,7 +31,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @compile ../NamedBuffer.java
* @run main RedefineClassHelper
* @compile --enable-preview -source ${jdk.version} Host/Host.java
@@ -31,7 +31,6 @@
* @modules java.base/jdk.internal.misc
* @modules java.compiler
* java.instrument
* jdk.jartool/sun.tools.jar
* @compile ../NamedBuffer.java
* @run main RedefineClassHelper
* @compile --enable-preview --source ${jdk.version} Host/Host.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,8 @@
*/

import java.io.PrintWriter;
import java.lang.instrument.*;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.ClassDefinition;
import jdk.test.lib.compiler.InMemoryJavaCompiler;

/*
@@ -64,16 +65,7 @@ public static void redefineClass(Class clazz, byte[] bytecode) throws Exception
* Main method to be invoked before test to create the redefineagent.jar
*/
public static void main(String[] args) throws Exception {
ClassFileInstaller.main("RedefineClassHelper");

PrintWriter pw = new PrintWriter("MANIFEST.MF");
pw.println("Premain-Class: RedefineClassHelper");
pw.println("Can-Redefine-Classes: true");
pw.close();

sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineClassHelper.class" })) {
throw new Exception("jar operation failed");
}
String manifest = "Premain-Class: RedefineClassHelper\nCan-Redefine-Classes: true\n";
ClassFileInstaller.writeJar("redefineagent.jar", ClassFileInstaller.Manifest.fromString(manifest), "RedefineClassHelper");
}
}

0 comments on commit 1b4b652

Please sign in to comment.
You can’t perform that action at this time.