< prev index next >
test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2015, 2018, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 67,83 ****
+ "class PackagePrivate {\n"
+ " int getVersion() {\n"
+ " return 9;\n"
+ " }\n"
+ "}\n";
! final private String java10 = java8.replace("8", "10");
final String readme8 = "This is the root readme file";
final String readme9 = "This is the version nine readme file";
! final String readme10 = "This is the version ten readme file";
private Map<String,byte[]> rootClasses;
private Map<String,byte[]> version9Classes;
! private Map<String,byte[]> version10Classes;
public void buildUnversionedJar() throws IOException {
JarBuilder jb = new JarBuilder("unversioned.jar");
jb.addEntry("README", readme8.getBytes());
jb.addEntry("version/Main.java", main.getBytes());
--- 67,85 ----
+ "class PackagePrivate {\n"
+ " int getVersion() {\n"
+ " return 9;\n"
+ " }\n"
+ "}\n";
! final int currentVersion = Runtime.version().major();
! final String currentVersionStr = Integer.toString(currentVersion);
! final private String javaCurrent = java8.replace("8", currentVersionStr);
final String readme8 = "This is the root readme file";
final String readme9 = "This is the version nine readme file";
! final String readmeCurrent = "This is the current version readme file";
private Map<String,byte[]> rootClasses;
private Map<String,byte[]> version9Classes;
! private Map<String,byte[]> versionCurrentClasses;
public void buildUnversionedJar() throws IOException {
JarBuilder jb = new JarBuilder("unversioned.jar");
jb.addEntry("README", readme8.getBytes());
jb.addEntry("version/Main.java", main.getBytes());
*** 132,144 ****
jb.addEntry("version/Version.class", rootClasses.get("version.Version"));
jb.addEntry("META-INF/versions/9/README", readme9.getBytes());
jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes());
jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes());
jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate"));
! jb.addEntry("META-INF/versions/10/README", readme10.getBytes());
! jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes());
! jb.addEntry("META-INF/versions/10/version/Version.class", version10Classes.get("version.Version"));
}
public void buildSignedMultiReleaseJar() throws Exception {
String testsrc = System.getProperty("test.src",".");
String testdir = findTestDir(testsrc);
--- 134,146 ----
jb.addEntry("version/Version.class", rootClasses.get("version.Version"));
jb.addEntry("META-INF/versions/9/README", readme9.getBytes());
jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes());
jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes());
jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate"));
! jb.addEntry("META-INF/versions/" + currentVersionStr + "/README", readmeCurrent.getBytes());
! jb.addEntry("META-INF/versions/" + currentVersionStr + "/version/Version.java", javaCurrent.getBytes());
! jb.addEntry("META-INF/versions/" + currentVersionStr + "/version/Version.class", versionCurrentClasses.get("version.Version"));
}
public void buildSignedMultiReleaseJar() throws Exception {
String testsrc = System.getProperty("test.src",".");
String testdir = findTestDir(testsrc);
*** 184,192 ****
input.clear();
input.put("version.Version", java9);
input.put("version.PackagePrivate", ppjava9);
version9Classes = (new Compiler(input)).setRelease(9).compile();
input.clear();
! input.put("version.Version", java10);
! version10Classes = (new Compiler(input)).setRelease(9).compile(); // fixme in JDK 10
}
}
--- 186,194 ----
input.clear();
input.put("version.Version", java9);
input.put("version.PackagePrivate", ppjava9);
version9Classes = (new Compiler(input)).setRelease(9).compile();
input.clear();
! input.put("version.Version", javaCurrent);
! versionCurrentClasses = (new Compiler(input)).compile(); // Use default release
}
}
< prev index next >