mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8199290: [TESTBUG] sun.hotspot.WhiteBox$WhiteBoxPermission is not copied
Reviewed-by: iignatyev, dholmes
This commit is contained in:
parent
83163dbfe6
commit
8b2453f93b
2 changed files with 73 additions and 9 deletions
|
@ -124,6 +124,35 @@ public class JarBuilder {
|
||||||
executeProcess(args.toArray(new String[1]));
|
executeProcess(args.toArray(new String[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add commonly used inner classes that are often omitted by mistake. Currently
|
||||||
|
// we support only sun/hotspot/WhiteBox$WhiteBoxPermission. See JDK-8199290
|
||||||
|
private static String[] addInnerClasses(String[] classes, int startIdx) {
|
||||||
|
boolean seenWB = false;
|
||||||
|
boolean seenWBInner = false;
|
||||||
|
// This method is different than ClassFileInstaller.addInnerClasses which
|
||||||
|
// uses "." as the package delimiter :-(
|
||||||
|
final String wb = "sun/hotspot/WhiteBox";
|
||||||
|
final String wbInner = "sun/hotspot/WhiteBox$WhiteBoxPermission";
|
||||||
|
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = startIdx; i < classes.length; i++) {
|
||||||
|
String cls = classes[i];
|
||||||
|
list.add(cls);
|
||||||
|
switch (cls) {
|
||||||
|
case wb: seenWB = true; break;
|
||||||
|
case wbInner: seenWBInner = true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (seenWB && !seenWBInner) {
|
||||||
|
list.add(wbInner);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] array = new String[list.size()];
|
||||||
|
list.toArray(array);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String createSimpleJar(String jarclassDir, String jarName,
|
private static String createSimpleJar(String jarclassDir, String jarName,
|
||||||
String[] classNames) throws Exception {
|
String[] classNames) throws Exception {
|
||||||
|
@ -140,6 +169,8 @@ public class JarBuilder {
|
||||||
private static void addClassArgs(ArrayList<String> args, String jarclassDir,
|
private static void addClassArgs(ArrayList<String> args, String jarclassDir,
|
||||||
String[] classNames) {
|
String[] classNames) {
|
||||||
|
|
||||||
|
classNames = addInnerClasses(classNames, 0);
|
||||||
|
|
||||||
for (String name : classNames) {
|
for (String name : classNames) {
|
||||||
args.add("-C");
|
args.add("-C");
|
||||||
args.add(jarclassDir);
|
args.add(jarclassDir);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -32,6 +32,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
@ -84,17 +85,47 @@ public class ClassFileInstaller {
|
||||||
"where possible options include:\n" +
|
"where possible options include:\n" +
|
||||||
" -jar <path> Write to the JAR file <path>");
|
" -jar <path> Write to the JAR file <path>");
|
||||||
}
|
}
|
||||||
writeJar(args[1], null, args, 2, args.length);
|
String jarFile = args[1];
|
||||||
|
String[] classes = addInnerClasses(args, 2);
|
||||||
|
writeJar_impl(jarFile, null, classes);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.out.println("ClassFileInstaller: Writing to " + System.getProperty("user.dir"));
|
System.out.println("ClassFileInstaller: Writing to " + System.getProperty("user.dir"));
|
||||||
}
|
}
|
||||||
for (String arg : args) {
|
String[] classes = addInnerClasses(args, 0);
|
||||||
writeClassToDisk(arg);
|
for (String cls : classes) {
|
||||||
|
writeClassToDisk(cls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add commonly used inner classes that are often omitted by mistake. Currently
|
||||||
|
// we support only sun.hotspot.WhiteBox$WhiteBoxPermission. See JDK-8199290
|
||||||
|
private static String[] addInnerClasses(String[] classes, int startIdx) {
|
||||||
|
boolean seenWB = false;
|
||||||
|
boolean seenWBInner = false;
|
||||||
|
final String wb = "sun.hotspot.WhiteBox";
|
||||||
|
final String wbInner = "sun.hotspot.WhiteBox$WhiteBoxPermission";
|
||||||
|
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = startIdx; i < classes.length; i++) {
|
||||||
|
String cls = classes[i];
|
||||||
|
list.add(cls);
|
||||||
|
switch (cls) {
|
||||||
|
case wb: seenWB = true; break;
|
||||||
|
case wbInner: seenWBInner = true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (seenWB && !seenWBInner) {
|
||||||
|
list.add(wbInner);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] array = new String[list.size()];
|
||||||
|
list.toArray(array);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Manifest {
|
public static class Manifest {
|
||||||
private InputStream in;
|
private InputStream in;
|
||||||
|
|
||||||
|
@ -122,7 +153,7 @@ public class ClassFileInstaller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeJar(String jarFile, Manifest manifest, String classes[], int from, int to) throws Exception {
|
private static void writeJar_impl(String jarFile, Manifest manifest, String classes[]) throws Exception {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.out.println("ClassFileInstaller: Writing to " + getJarPath(jarFile));
|
System.out.println("ClassFileInstaller: Writing to " + getJarPath(jarFile));
|
||||||
}
|
}
|
||||||
|
@ -137,8 +168,8 @@ public class ClassFileInstaller {
|
||||||
writeToDisk(zos, "META-INF/MANIFEST.MF", manifest.getInputStream());
|
writeToDisk(zos, "META-INF/MANIFEST.MF", manifest.getInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=from; i<to; i++) {
|
for (String cls : classes) {
|
||||||
writeClassToDisk(zos, classes[i]);
|
writeClassToDisk(zos, cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
zos.close();
|
zos.close();
|
||||||
|
@ -157,12 +188,14 @@ public class ClassFileInstaller {
|
||||||
* @build ClassFileInstaller
|
* @build ClassFileInstaller
|
||||||
*/
|
*/
|
||||||
public static String writeJar(String jarFile, String... classes) throws Exception {
|
public static String writeJar(String jarFile, String... classes) throws Exception {
|
||||||
writeJar(jarFile, null, classes, 0, classes.length);
|
classes = addInnerClasses(classes, 0);
|
||||||
|
writeJar_impl(jarFile, null, classes);
|
||||||
return getJarPath(jarFile);
|
return getJarPath(jarFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String writeJar(String jarFile, Manifest manifest, String... classes) throws Exception {
|
public static String writeJar(String jarFile, Manifest manifest, String... classes) throws Exception {
|
||||||
writeJar(jarFile, manifest, classes, 0, classes.length);
|
classes = addInnerClasses(classes, 0);
|
||||||
|
writeJar_impl(jarFile, manifest, classes);
|
||||||
return getJarPath(jarFile);
|
return getJarPath(jarFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue