提交 672bf3db 编写于 作者: D dcherepanov

Merge

......@@ -199,3 +199,4 @@ a996b57e554198f4592a5f3c30f2f9f4075e545d jdk8-b70
4a67fdb752b7d6329d9be9c28d3f9d6cf7eb9a3c jdk8-b75
3a263052866137b645ab86498a43693ff5c19e69 jdk8-b76
b2fc8e31cecc35b76188e821d4c5dc0e0b74ac24 jdk8-b77
00b7535d743f83eda763c10b3c9ea19ba4b67f55 jdk8-b78
......@@ -405,3 +405,11 @@ ifdef CROSS_COMPILE_ARCH
endif
LIB_LOCATION ?= $(LIBDIR)
# Adding these macros will make it an error to link to mac APIs newer than OS version 10.7
ifeq ($(MACOSX_REQUIRED_VERSION),)
MACOSX_REQUIRED_VERSION:=1070
endif
MACOSX_OS_VERSION_CFLAGS := -DMAC_OS_X_VERSION_MAX_ALLOWED=$(MACOSX_REQUIRED_VERSION) -DMAC_OS_X_VERSION_MIN_REQUIRED=$(MACOSX_REQUIRED_VERSION)
OTHER_CFLAGS += $(MACOSX_OS_VERSION_CFLAGS)
OTHER_CXXFLAGS += $(MACOSX_OS_VERSION_CFLAGS)
......@@ -1056,6 +1056,7 @@ initial-image-jdk:: initial-image-jdk-setup \
-processor com.sun.tools.javac.sym.CreateSymbols \
-Acom.sun.tools.javac.sym.Jar=$(RT_JAR) \
-Acom.sun.tools.javac.sym.Dest=$(OUTPUTDIR)/symbols/META-INF/sym/rt.jar \
-Acom.sun.tools.javac.sym.Profiles=$(JDK_TOPDIR)/makefiles/profile-rtjar-includes.txt \
$(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS) $(EXPORTED_PRIVATE_PKGS)
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS_NOMANIFEST) $(LIBDIR)/ct.sym \
-C $(OUTPUTDIR)/symbols META-INF $(BOOT_JAR_JFLAGS)
......
# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2013, 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
......@@ -208,6 +208,7 @@ COMMON_JAVADOCFLAGS = \
-use \
-keywords \
-Xdoclint:none \
-Xprofilespath $(JDK_TOPDIR)/makefiles/profile-rtjar-includes.txt \
$(ADDITIONAL_JAVADOCFLAGS)
ifdef OPENJDK
......
#
# Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 2012, 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
......@@ -40,6 +40,7 @@ $(GENSRCDIR)/sun/misc/Version.java: \
-e 's/@@java_version@@/$(RELEASE)/g' \
-e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \
-e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \
-e 's/@@java_profile_name@@//g' \
$< > $@.temp
@$(MV) $@.temp $@
......
/*
* Copyright (c) 2012, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.classfile;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Set;
import java.util.HashSet;
import com.sun.tools.classfile.AccessFlags;
import com.sun.tools.classfile.Attributes;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.ClassWriter;
import com.sun.tools.classfile.ConstantPool;
import com.sun.tools.classfile.Field;
import com.sun.tools.classfile.Method;
public class RemoveMethods {
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: java RemoveMethods classfile output [method...]");
System.exit(-1);
}
// class file to read
Path input = Paths.get(args[0]);
// class file to write, if directory then use the name of the input
Path output = Paths.get(args[1]);
if (Files.isDirectory(output))
output = output.resolve(input.getFileName());
// the methods to remove
Set<String> methodsToRemove = new HashSet<>();
int i = 2;
while (i < args.length)
methodsToRemove.add(args[i++]);
// read class file
ClassFile cf;
try (InputStream in = Files.newInputStream(input)) {
cf = ClassFile.read(in);
}
final int magic = cf.magic;
final int major_version = cf.major_version;
final int minor_version = cf.minor_version;
final ConstantPool cp = cf.constant_pool;
final AccessFlags access_flags = cf.access_flags;
final int this_class = cf.this_class;
final int super_class = cf.super_class;
final int[] interfaces = cf.interfaces;
final Field[] fields = cf.fields;
final Attributes class_attrs = cf.attributes;
// remove the requested methods, no signature check at this time
Method[] methods = cf.methods;
i = 0;
while (i < methods.length) {
Method m = methods[i];
String name = m.getName(cp);
if (methodsToRemove.contains(name)) {
int len = methods.length;
Method[] newMethods = new Method[len-1];
if (i > 0)
System.arraycopy(methods, 0, newMethods, 0, i);
int after = methods.length - i - 1;
if (after > 0)
System.arraycopy(methods, i+1, newMethods, i, after);
methods = newMethods;
String paramTypes = m.descriptor.getParameterTypes(cp);
System.out.format("Removed method %s%s from %s%n",
name, paramTypes, cf.getName());
continue;
}
i++;
}
// TBD, prune constant pool of entries that are no longer referenced
// re-write class file
cf = new ClassFile(magic, minor_version, major_version, cp, access_flags,
this_class, super_class, interfaces, fields, methods, class_attrs);
try (OutputStream out = Files.newOutputStream(output)) {
new ClassWriter().write(cf, out);
}
}
}
/*
* Copyright (c) 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.deps;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.Dependencies;
import com.sun.tools.classfile.Dependency;
/**
* A simple tool to check the JAR files in a JRE image to ensure that there
* aren't any references to types that do not exist. The tool is intended to
* be used in the JDK "profiles" build to help ensure that the profile
* definitions are kept up to date.
*/
public class CheckDeps {
// classfile API for finding dependencies
static final Dependency.Finder finder = Dependencies.getClassDependencyFinder();
// "known types", found in rt.jar or other JAR files
static final Set<String> knownTypes = new HashSet<>();
// References to unknown types. The map key is the unknown type, the
// map value is the set of classes that reference it.
static final Map<String,Set<String>> unknownRefs = new HashMap<>();
// The property name is the name of an unknown type that is allowed to be
// references. The property value is a comma separated list of the types
// that are allowed to reference it. The list also includes the names of
// the profiles that the reference is allowed.
static final Properties allowedBadRefs = new Properties();
/**
* Returns the class name for the given class file. In the case of inner
* classes then the enclosing class is returned in order to keep the
* rules simple.
*/
static String toClassName(String s) {
int i = s.indexOf('$');
if (i > 0)
s = s.substring(0, i);
return s.replace("/", ".");
}
/**
* Analyze the dependencies of all classes in the given JAR file. The
* method updates knownTypes and unknownRefs as part of the analysis.
*/
static void analyzeDependencies(Path jarpath) throws Exception {
System.out.format("Analyzing %s%n", jarpath);
try (JarFile jf = new JarFile(jarpath.toFile())) {
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
String name = e.getName();
if (name.endsWith(".class")) {
ClassFile cf = ClassFile.read(jf.getInputStream(e));
for (Dependency d : finder.findDependencies(cf)) {
String origin = toClassName(d.getOrigin().getName());
String target = toClassName(d.getTarget().getName());
// origin is now known
unknownRefs.remove(origin);
knownTypes.add(origin);
// if the target is not known then record the reference
if (!knownTypes.contains(target)) {
Set<String> refs = unknownRefs.get(target);
if (refs == null) {
// first time seeing this unknown type
refs = new HashSet<>();
unknownRefs.put(target, refs);
}
refs.add(origin);
}
}
}
}
}
}
/**
* We have closure (no references to types that do not exist) if
* unknownRefs is empty. When unknownRefs is not empty then it should
* only contain references that are allowed to be present (these are
* loaded from the refs.allowed properties file).
*
* @param the profile that is being tested, this determines the exceptions
* in {@code allowedBadRefs} that apply.
*
* @return {@code true} if there are no missing types or the only references
* to missing types are described by {@code allowedBadRefs}.
*/
static boolean checkClosure(String profile) {
// process the references to types that do not exist.
boolean fail = false;
for (Map.Entry<String,Set<String>> entry: unknownRefs.entrySet()) {
String target = entry.getKey();
for (String origin: entry.getValue()) {
// check if origin -> target allowed
String value = allowedBadRefs.getProperty(target);
if (value == null) {
System.err.format("%s -> %s (unknown type)%n", origin, target);
fail = true;
} else {
// target is known, check if the origin is one that we
// expect and that the exception applies to the profile.
boolean found = false;
boolean applicable = false;
for (String s: value.split(",")) {
s = s.trim();
if (s.equals(origin))
found = true;
if (s.equals(profile))
applicable = true;
}
if (!found || !applicable) {
if (!found) {
System.err.format("%s -> %s (not allowed)%n", origin, target);
} else {
System.err.format("%s -> %s (reference not applicable to %s)%n",
origin, target, profile);
}
fail = true;
}
}
}
}
return !fail;
}
static void fail(URL url) throws Exception {
System.err.println("One or more unexpected references encountered");
if (url != null)
System.err.format("Check %s is up to date%n", Paths.get(url.toURI()));
System.exit(-1);
}
public static void main(String[] args) throws Exception {
// load properties file so that we know what missing types that are
// allowed to be referenced.
URL url = CheckDeps.class.getResource("refs.allowed");
if (url != null) {
try (InputStream in = url.openStream()) {
allowedBadRefs.load(new InputStreamReader(in, StandardCharsets.UTF_8));
}
}
if (args.length != 2) {
System.err.println("Usage: java CheckDeps <image> <profile>");
System.exit(-1);
}
String image = args[0];
String profile = args[1];
// process JAR files on boot class path
Path lib = Paths.get(image, "lib");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(lib, "*.jar")) {
for (Path jarpath: stream) {
analyzeDependencies(jarpath);
}
}
// classes on boot class path should not reference other types
boolean okay = checkClosure(profile);
if (!okay)
fail(url);
// process JAR files in the extensions directory
try (DirectoryStream<Path> stream = Files.newDirectoryStream(lib.resolve("ext"), "*.jar")) {
for (Path jarpath: stream) {
analyzeDependencies(jarpath);
}
}
// re-check to ensure that the extensions doesn't reference types that
// do not exist.
okay = checkClosure(profile);
if (!okay)
fail(url);
}
}
#
# This properties-formatted file contains the names of the non-existent types
# that are allowed to be referenced from classes in a profiles image.
#
# The property key is a type that does not exist. The property value is one or
# more types that reference the missing type. The property value also encodes
# the names of the profiles where this reference is allowed.
# jsse.jar is not subsetted by the profiles build. For compact1 and compact2
# then this means that there are references to Kerberos types that do not
# exist. These references are harmless.
#
javax.security.auth.kerberos.KerberosKey=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,sun.security.ssl.krb5.Krb5ProxyImpl,compact1,compact2
javax.security.auth.kerberos.KerberosPrincipal=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,sun.security.ssl.krb5.Krb5ProxyImpl,compact1,compact2
javax.security.auth.kerberos.KerberosTicket=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
javax.security.auth.kerberos.ServicePermission=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,sun.security.ssl.krb5.Krb5ProxyImpl,compact1,compact2
sun.security.jgss.GSSCaller=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,sun.security.ssl.krb5.Krb5ProxyImpl,compact1,compact2
sun.security.jgss.krb5.Krb5Util=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,sun.security.ssl.krb5.Krb5ProxyImpl,compact1,compact2
sun.security.jgss.krb5.ServiceCreds=sun.security.ssl.krb5.Krb5ProxyImpl,compact1,compact2
sun.security.krb5.EncryptedData= sun.security.ssl.krb5.KerberosPreMasterSecret,sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.EncryptionKey=sun.security.ssl.krb5.KerberosPreMasterSecret,sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.internal.crypto.KeyUsage=sun.security.ssl.krb5.KerberosPreMasterSecret,sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.internal.EncTicketPart=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.internal.Krb5=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.internal.Ticket=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.KrbException=sun.security.ssl.krb5.KerberosPreMasterSecret,sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.PrincipalName=sun.security.ssl.krb5.Krb5ProxyImpl,sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
sun.security.krb5.Realm=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,compact1,compact2
# Residual references to java.beans.
# The RemoveMethods tool does not yet purge the constant pool.
# Rhino is due to be replaced so not worth addressing this dependency now.
#
java.beans.PropertyChangeListener=java.util.logging.LogManager,sun.org.mozilla.javascript.internal.Context,compact1,compact2,compact3
java.beans.PropertyChangeEvent=sun.org.mozilla.javascript.internal.Context,compact3
# JFR traces even in builds with JFR disabled
com.oracle.jrockit.jfr.FlightRecorder: com.sun.management.MissionControl, compact3
com.oracle.jrockit.jfr.management.FlightRecorderMBean: com.sun.management.MissionControl, compact3
......@@ -162,8 +162,9 @@ public class JarReorder {
for (int i = orderList.size() - 1; i >= 0; --i) {
String s = orderList.get(i);
if (allFilesExcluded.contains(s)) {
System.err.println("Included order file " + s
+ " is also excluded, skipping.");
// Disable this warning until 8005688 is fixed
// System.err.println("Included order file " + s
// + " is also excluded, skipping.");
} else if (new File(s).exists()) {
allFiles.add(s);
} else {
......
......@@ -39,6 +39,12 @@ include NativeCompilation.gmk
# Setup the java compilers for the JDK build.
include Setup.gmk
# Include Profile information
include ProfileNames.gmk
# Include the corresponding custom file, if present.
-include $(CUSTOM_MAKE_DIR)/BuildJdk.gmk
import: import-only
import-only:
# Import (corba jaxp jaxws langtools hotspot)
......@@ -85,10 +91,11 @@ demos:
+$(MAKE) -f CopySamples.gmk
# Create the final jdk and jre images, to be wrapped up
# into packages, or installed.
# into packages, or installed. Ensure PROFILE is not set
# in these cases.
images:
+$(MAKE) -f CreateJars.gmk
+$(MAKE) -f Images.gmk
+$(MAKE) PROFILE="" -f CreateJars.gmk
+$(MAKE) PROFILE="" -f Images.gmk
ifeq ($(OPENJDK_TARGET_OS), macosx)
+$(MAKE) -f Bundles.gmk
endif
......@@ -97,6 +104,13 @@ overlay-images:
+$(MAKE) -f CompileLaunchers.gmk OVERLAY_IMAGES=true
+$(MAKE) -f Images.gmk overlay-images
# Create Compact Profile images
$(ALL_PROFILES):
+$(MAKE) PROFILE=$@ -f CreateJars.gmk
+$(MAKE) PROFILE=$@ JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/j2re-$(word $(call profile_number,$@),$(PROFILE_NAMES))-image -f Images.gmk profile-image
profiles: $(ALL_PROFILES)
sign-jars:
+$(MAKE) -f SignJars.gmk
......@@ -121,3 +135,4 @@ all: jdk
.PHONY: import gensrc gendata classes libs launchers genclasses
.PHONY: import-only gensrc-only gendata-only classes-only libs-only launchers-only genclasses-only
.PHONY: all jdk demos images overlay-images bundles install
.PHONY: profiles $(ALL_PROFILES)
......@@ -421,6 +421,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBPOLLER,\
CFLAGS:=$(CFLAGS_JDKLIB) $(SHARED_LIBRARY_FLAGS) \
-I$(JDK_OUTPUTDIR)/democlasses/jni/Poller, \
LDFLAGS:=$(LDFLAGS_JDKLIB), \
LDFLAGS_SUFFIX_solaris:=-lc,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/demoobjs/jni/Poller,\
OUTPUT_DIR:=$(JDK_OUTPUTDIR)/demoobjs, \
LIBRARY:=Poller))
......
......@@ -2188,6 +2188,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJFR,\
MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libjfr/mapfile-vers, \
LDFLAGS:=$(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN),\
LDFLAGS_SUFFIX_solaris:=-lc,\
VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
RC_FLAGS:=$(RC_FLAGS)\
-D "JDK_FNAME=jfr.dll" \
......@@ -2236,6 +2237,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBKCMS,\
LDFLAGS:=$(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN),\
LDFLAGS_SUFFIX_linux:=-lc -lpthread,\
LDFLAGS_SUFFIX_solaris:=-lc,\
LDFLAGS_SUFFIX_windows:=$(WIN_JAVA_LIB) advapi32.lib user32.lib version.lib, \
LDFLAGS_SUFFIX_posix:=-lm -ljava -ljvm,\
VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\
......@@ -2939,6 +2941,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2UCRYPTO,\
MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libj2ucrypto/mapfile-vers, \
LDFLAGS:=$(LDFLAGS_JDKLIB),\
LDFLAGS_SUFFIX:=$(LIBDL),\
LDFLAGS_SUFFIX_solaris:=-lc,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto))
$(BUILD_LIBJ2UCRYPTO) : $(BUILD_LIBJAVA)
......
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2013, 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
......@@ -35,16 +35,19 @@ $(eval $(call FillCacheFind,$(JDK_OUTPUTDIR)/classes))
include Tools.gmk
include Profiles.gmk
#
# This makefile...so that altering will trigger rebuilding include/exclude-lists => jars
#
MAKEFILE=$(JDK_TOPDIR)/makefiles/CreateJars.gmk
#
# And similarly for the Profiles
PROFILE_MAKEFILES=$(JDK_TOPDIR)/makefiles/Profiles.gmk $(JDK_TOPDIR)/makefiles/profile-rtjar-includes.txt
MAINMANIFEST := $(JDK_TOPDIR)/make/tools/manifest.mf
BEANMANIFEST := $(JDK_TOPDIR)/make/javax/swing/beaninfo/manifest
JARS:=
$(eval $(call MakeDir,$(IMAGES_OUTPUTDIR)/lib))
##########################################################################################
......@@ -57,7 +60,6 @@ $(eval $(call SetupArchive,BUILD_JCONSOLE_JAR,,\
JAR:=$(IMAGES_OUTPUTDIR)/lib/jconsole.jar,\
SKIP_METAINF:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/jconsole.jar
##########################################################################################
......@@ -68,7 +70,6 @@ $(eval $(call SetupArchive,BUILD_DNS_JAR,,\
JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/dnsns.jar,\
SKIP_METAINF:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/ext/dnsns.jar
##########################################################################################
......@@ -127,15 +128,20 @@ $(eval $(call SetupArchive,BUILD_LOCALEDATA_JAR,,\
JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/localedata.jar,\
SKIP_METAINF:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/ext/localedata.jar
##########################################################################################
# rt.jar and resources.jar are being built in the same way as in the old build. They require
# the files to be in a certain order and converting that is not easy and will not be needed
# in jigsaw anyway.
#
# Different variants of rt.jar are built based on the current profile. The output
# directory is augmented with the profile name so that the final jar file and all the
# intermediary list files will be in directory. This has the form lib$PROFILE rather than
# lib/$PROFILE so that it won't get copied as part of the image generation process.
# Each profile customizes the RT_JAR_EXCLUDES variable.
#
##########################################################################################
# Exclude list for rt.jar and resources.jar
RT_JAR_EXCLUDES := \
# Full JRE exclude list for rt.jar and resources.jar
# This value should exclude types destined for jars other than rt.jar and resources.jar.
# When building a Profile this value augments the profile specific exclusions
RT_JAR_EXCLUDES += \
com/oracle/security \
com/sun/codemodel \
com/sun/crypto/provider \
......@@ -258,24 +264,9 @@ RT_JAR_EXCLUDES := \
sun/tools/util \
sun/util/cldr/CLDRLocaleDataMetaInfo.class \
sun/util/resources/cldr \
$(LOCALEDATA_INCLUDES)
# These files should never be put into rt.jar
# but due to a misstake...some are put there if embedded
#
ifneq ($(JAVASE_EMBEDDED), true)
# normal (correct) case
RT_JAR_EXCLUDES += \
$(LOCALEDATA_INCLUDES) \
com/oracle/jrockit/jfr \
oracle/jrockit/jfr
else
# embedded (broken) case
RT_JAR_EXCLUDES += \
oracle/jrockit/jfr/parser \
oracle/jrockit/jfr/tools \
oracle/jrockit/jfr/NativeOptions.class \
oracle/jrockit/jfr/RepositoryChunkHandler.class
endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
RT_JAR_EXCLUDES += com/sun/nio/sctp \
......@@ -286,8 +277,8 @@ endif
ALL_FILES_IN_CLASSES := $(call not-containing,_the.,$(filter-out %javac_state,\
$(call CacheFind,$(JDK_OUTPUTDIR)/classes)))
RT_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib/_the.rt.jar_manifest
RESOURCE_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib/_the.resources.jar_manifest
RT_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar_manifest
RESOURCE_JAR_MANIFEST_FILE := $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar_manifest
$(RT_JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
$(MKDIR) -p $(@D)
......@@ -307,7 +298,7 @@ $(RESOURCE_JAR_MANIFEST_FILE): $(MAINMANIFEST)
$(MAINMANIFEST) >> $@.tmp
$(MV) $@.tmp $@
$(IMAGES_OUTPUTDIR)/lib/_the.jars.exclude: $(MAKEFILE)
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude: $(MAKEFILE) $(PROFILE_MAKEFILES)
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(call ListPathsSafely,RT_JAR_EXCLUDES,\n, >> $@.tmp)
......@@ -320,55 +311,115 @@ $(IMAGES_OUTPUTDIR)/lib/classlist : $(JDK_TOPDIR)/make/tools/sharing/classlist.$
$(TOOL_ADDJSUM) $< $@.tmp
$(MV) $@.tmp $@
$(IMAGES_OUTPUTDIR)/lib/_the.jars.contents: $(BUILD_TOOLS) $(IMAGES_OUTPUTDIR)/lib/_the.jars.exclude \
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents: $(BUILD_TOOLS) $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude \
$(ALL_FILES_IN_CLASSES) $(IMAGES_OUTPUTDIR)/lib/classlist
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
($(CD) $(JDK_OUTPUTDIR)/classes && \
$(TOOL_JARREORDER) \
-o $@.tmp $(IMAGES_OUTPUTDIR)/lib/classlist $(IMAGES_OUTPUTDIR)/lib/_the.jars.exclude . )
-o $@.tmp $(IMAGES_OUTPUTDIR)/lib/classlist $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.exclude . )
$(MV) $@.tmp $@
$(IMAGES_OUTPUTDIR)/lib/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents > $@.tmp
$(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
ifneq ($(PROFILE),)
# # Add back classes from excluded packages (fixing the $ substitution in the process)
for type in $(subst \$$,\, $(RT_JAR_INCLUDE_TYPES)) ; do \
$(ECHO) $$type >> $@.tmp ; \
done
endif
$(MV) $@.tmp $@
$(IMAGES_OUTPUTDIR)/lib/_the.resources.jar.contents: $(IMAGES_OUTPUTDIR)/lib/_the.jars.contents
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(GREP) -v -e '\.class$$' \
-e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' \
$(IMAGES_OUTPUTDIR)/lib/_the.jars.contents > $@.tmp
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp
ifneq ($(PROFILE),)
# # Strip out all META-INF/services/ entries
$(GREP) -v -e 'META-INF/services/' $@.tmp > $@.tmp2
# # Add back the required services
# # FIXME: On Solaris if PROFILE_INCLUDE_METAINF_SERVICES is not defined
# # we get a syntax error from sh. That doesn't happen on linux
for service in $(PROFILE_INCLUDE_METAINF_SERVICES) ; do \
$(ECHO) $$service >> $@.tmp2; \
done
$(MV) $@.tmp2 $@.tmp
endif
$(MV) $@.tmp $@
# This is a hack but I don't know how to make this fit into the existing scheme
$(PROFILE_VERSION_CLASS_TARGETS) : $(PROFILE_VERSION_JAVA_TARGETS)
@$(JAVAC) -d $(@D)/../../ $(@D)/$(VERSION_JAVA_FILE)
# Support for removing the addPropertyChangeListener and removePropertyChangeListener
# methods from classes that only go into the profile builds. For now the Pack200.Packer
# and Packer200.Unpacker classes have special handling because of the $ in the file
# name.
BEANLESS_CLASSES = $(IMAGES_OUTPUTDIR)/beanless
$(BEANLESS_CLASSES)/%: $(JDK_OUTPUTDIR)/classes/%
$(MKDIR) -p $(@D)
$(TOOL_REMOVEMETHODS) $< $@ addPropertyChangeListener removePropertyChangeListener
CLASSES_TO_DEBEAN = \
java/util/logging/LogManager.class \
com/sun/java/util/jar/pack/PackerImpl.class \
com/sun/java/util/jar/pack/UnpackerImpl.class
BEANLESS_CLASSES_TARGETS =
ifneq ($(PROFILE),)
BEANLESS_CLASSES_TARGETS := $(foreach c, $(CLASSES_TO_DEBEAN), $(BEANLESS_CLASSES)/$c)
endif
RT_JAR_CREATE_OPTIONS := c0fm
RT_JAR_UPDATE_OPTIONS := u0f
ifeq ($(COMPRESS_JARS), true)
RT_JAR_CREATE_OPTIONS := cfm
RT_JAR_UPDATE_OPTIONS := uf
endif
$(IMAGES_OUTPUTDIR)/lib/rt.jar: $(IMAGES_OUTPUTDIR)/lib/_the.rt.jar.contents $(RT_JAR_MANIFEST_FILE)
$(ECHO) Creating rt.jar
# This defines a target-specific variables to make the shell logic easier to see.
# We need to find the Version.class file for the profile currently being built
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: \
CLASS_FILE = $(if $(PROFILE),$(strip $(foreach class,$(PROFILE_VERSION_CLASS_TARGETS),$(if $(findstring $(PROFILE),$(class)),$(class)))), NO_SUCH_FILE)
# This is the real target
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/rt.jar: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents $(RT_JAR_MANIFEST_FILE) $(PROFILE_VERSION_CLASS_TARGETS) $(BEANLESS_CLASSES_TARGETS)
$(ECHO) Creating rt.jar $(PROFILE) Compressed=$(COMPRESS_JARS)
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(CD) $(JDK_OUTPUTDIR)/classes && \
$(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RT_JAR_MANIFEST_FILE) \
@$(IMAGES_OUTPUTDIR)/lib/_the.rt.jar.contents
@$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents && \
if [ -f $(CLASS_FILE) ]; then \
$(ECHO) Updating rt.jar $(PROFILE) && \
$(CD) $(patsubst %$(VERSION_CLASS_PATH),%,$(CLASS_FILE)) && \
$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(VERSION_CLASS_PATH); \
$(MKDIR) -p $(BEANLESS_CLASSES)/java/util/jar; \
$(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Packer.class \
$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Packer.class addPropertyChangeListener removePropertyChangeListener; \
$(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Unpacker.class \
$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Unpacker.class addPropertyChangeListener removePropertyChangeListener; \
$(CD) $(BEANLESS_CLASSES) && \
$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN) java/util/jar/* ; \
fi
$(MV) $@.tmp $@
$(IMAGES_OUTPUTDIR)/lib/resources.jar: $(IMAGES_OUTPUTDIR)/lib/_the.resources.jar.contents \
$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/resources.jar: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents \
$(RESOURCE_JAR_MANIFEST_FILE)
$(ECHO) Creating resources.jar
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(CD) $(JDK_OUTPUTDIR)/classes && \
$(JAR) $(RT_JAR_CREATE_OPTIONS) $@.tmp $(RESOURCE_JAR_MANIFEST_FILE) \
@$(IMAGES_OUTPUTDIR)/lib/_the.resources.jar.contents
@$(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents
$(MV) $@.tmp $@
JARS+=$(IMAGES_OUTPUTDIR)/lib/rt.jar $(IMAGES_OUTPUTDIR)/lib/resources.jar
##########################################################################################
ifneq ($(OPENJDK_TARGET_OS), windows)
......@@ -393,8 +444,6 @@ $(eval $(call SetupArchive,BUILD_CHARSETS_JAR,,\
SKIP_METAINF := true, \
CHECK_COMPRESS_JAR:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/charsets.jar
##########################################################################################
ifndef OPENJDK
......@@ -408,7 +457,6 @@ ifeq ($(ENABLE_JFR), true)
MANIFEST:=$(MAINMANIFEST), \
CHECK_COMPRESS_JAR:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/jfr.jar
endif
endif
......@@ -425,8 +473,6 @@ $(eval $(call SetupArchive,BUILD_JSSE_JAR,,\
MANIFEST:=$(MAINMANIFEST), \
CHECK_COMPRESS_JAR:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/jsse.jar
##########################################################################################
# Create manifest for security jars
......@@ -446,7 +492,8 @@ $(JCE_MANIFEST): $(MAINMANIFEST)
##########################################################################################
# For all security jars, always build the jar, but for closed, install the prebuilt signed
# version instead of the newly built jar. For open, signing is not needed. See SignJars.gmk
# version instead of the newly built jar. Unsigned jars are treated as intermediate targets
# and explicitly added to the JARS list. For open, signing is not needed. See SignJars.gmk
# for more information.
SUNPKCS11_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunpkcs11.jar
......@@ -472,7 +519,7 @@ else
$(install-file)
endif
JARS += $(SUNPKCS11_JAR_DST) $(SUNPKCS11_JAR_UNSIGNED)
JARS += $(SUNPKCS11_JAR_UNSIGNED)
##########################################################################################
......@@ -499,7 +546,7 @@ else
$(install-file)
endif
JARS += $(SUNEC_JAR_DST) $(SUNEC_JAR_UNSIGNED)
JARS += $(SUNEC_JAR_UNSIGNED)
##########################################################################################
......@@ -512,8 +559,6 @@ $(eval $(call SetupArchive,BUILD_SWINGBEANS_JAR,,\
JAR:=$(IMAGES_OUTPUTDIR)/lib/dt.jar,\
SKIP_METAINF:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/dt.jar
##########################################################################################
SUNJCE_PROVIDER_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunjce_provider.jar
......@@ -539,7 +584,7 @@ else
$(install-file)
endif
JARS += $(SUNJCE_PROVIDER_JAR_DST) $(SUNJCE_PROVIDER_JAR_UNSIGNED)
JARS += $(SUNJCE_PROVIDER_JAR_UNSIGNED)
##########################################################################################
......@@ -566,7 +611,7 @@ else
$(install-file)
endif
JARS += $(JCE_JAR_DST) $(JCE_JAR_UNSIGNED)
JARS += $(JCE_JAR_UNSIGNED)
##########################################################################################
......@@ -604,7 +649,7 @@ else
$(install-file)
endif
JARS += $(US_EXPORT_POLICY_JAR_DST) $(US_EXPORT_POLICY_JAR_UNSIGNED)
JARS += $(US_EXPORT_POLICY_JAR_UNSIGNED)
##########################################################################################
......@@ -647,7 +692,7 @@ else
$(install-file)
endif
JARS += $(LOCAL_POLICY_JAR_DST) $(LOCAL_POLICY_JAR_UNSIGNED)
JARS += $(LOCAL_POLICY_JAR_UNSIGNED)
##########################################################################################
......@@ -676,7 +721,7 @@ else
$(install-file)
endif
JARS += $(SUNMSCAPI_JAR_DST) $(SUNMSCAPI_JAR_UNSIGNED)
JARS += $(SUNMSCAPI_JAR_UNSIGNED)
endif
......@@ -703,7 +748,7 @@ $(UCRYPTO_JAR_DST) : $(UCRYPTO_JAR_SRC)
@$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt OracleUcrypto provider..."
$(install-file)
JARS += $(UCRYPTO_JAR_DST) $(UCRYPTO_JAR_UNSIGNED)
JARS += $(UCRYPTO_JAR_UNSIGNED)
endif
endif
......@@ -726,8 +771,6 @@ $(eval $(call SetupArchive,BUILD_CLDRDATA_JAR,,\
EXTRA_MANIFEST_ATTR:=CLDR-Version: $(CLDRVERSION),\
SKIP_METAINF:=true))
JARS += $(CLDRDATA_JAR_DST)
##########################################################################################
TOOLS_JAR_INCLUDES := \
......@@ -801,7 +844,6 @@ $(eval $(call SetupArchive,BUILD_TOOLS_JAR,,\
SKIP_METAINF:=true, \
CHECK_COMPRESS_JAR:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/tools.jar
##########################################################################################
......@@ -842,6 +884,7 @@ $(IMAGES_OUTPUTDIR)/symbols/_the.symbols: $(IMAGES_OUTPUTDIR)/lib/rt.jar
-processor com.sun.tools.javac.sym.CreateSymbols \
-Acom.sun.tools.javac.sym.Jar=$(IMAGES_OUTPUTDIR)/lib/rt.jar \
-Acom.sun.tools.javac.sym.Dest=$(IMAGES_OUTPUTDIR)/symbols/META-INF/sym/rt.jar \
-Acom.sun.tools.javac.sym.Profiles=profile-rtjar-includes.txt \
$(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS) $(EXPORTED_PRIVATE_PKGS)
$(TOUCH) $@
......@@ -852,7 +895,6 @@ $(eval $(call SetupArchive,BUILD_CT_SYM,$(IMAGES_OUTPUTDIR)/symbols/_the.symbols
JAR:=$(IMAGES_OUTPUTDIR)/lib/ct.sym, \
CHECK_COMPRESS_JAR:=true))
JARS+=$(IMAGES_OUTPUTDIR)/lib/ct.sym
##########################################################################################
......@@ -938,8 +980,6 @@ $(eval $(call SetupZipArchive,BUILD_SRC_ZIP,\
ZIP:=$(IMAGES_OUTPUTDIR)/src.zip,\
EXTRA_DEPS:=$(LAUNCHER_ZIP_SRC)))
JARS+=$(IMAGES_OUTPUTDIR)/src.zip
##########################################################################################
ifndef OPENJDK
......@@ -990,15 +1030,11 @@ endif
$(IMAGES_OUTPUTDIR)/lib/management-agent.jar : $(JDK_TOPDIR)/src/share/classes/sun/management/manifest
$(JAR) cfm $@ $<
JARS += $(IMAGES_OUTPUTDIR)/lib/management-agent.jar
##########################################################################################
$(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar : $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar
$(install-file)
JARS += $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar
##########################################################################################
ifeq ($(OPENJDK_TARGET_OS),macosx)
......@@ -1006,8 +1042,6 @@ ifeq ($(OPENJDK_TARGET_OS),macosx)
SRCS:=$(JDK_OUTPUTDIR)/jobjc_classes,\
JAR:=$(IMAGES_OUTPUTDIR)/lib/JObjC.jar, \
JARINDEX:=true))
JARS += $(IMAGES_OUTPUTDIR)/lib/JObjC.jar
endif
##########################################################################################
......@@ -1017,7 +1051,6 @@ ifndef OPENJDK
SRCS:=$(JDK_OUTPUTDIR)/altclasses_classes,\
JAR:=$(IMAGES_OUTPUTDIR)/lib/alt-rt.jar))
JARS += $(IMAGES_OUTPUTDIR)/lib/alt-rt.jar
endif
##########################################################################################
......@@ -1028,8 +1061,6 @@ endif
$(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar: $(JDK_OUTPUTDIR)/lib/sa-jdi.jar
$(install-file)
JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
##########################################################################################
#
# sec-bin.zip is used by builds where the corresponding sources are not available
......
......@@ -23,24 +23,29 @@
# questions.
#
include ProfileNames.gmk
##########################################################################################
# Install the launcher name, release version string, full version
# string and the runtime name into the Version.java file.
# To be printed by java -version
$(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java: \
$(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template
$(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \
$(PROFILE_VERSION_JAVA_TARGETS): \
$(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template
$(MKDIR) -p $(@D)
$(RM) $@ $@.tmp
$(ECHO) $(LOG_INFO) Generating sun/misc/Version.java
$(ECHO) Generating sun/misc/Version.java $(call profile_version_name, $@)
$(SED) -e 's/@@launcher_name@@/$(LAUNCHER_NAME)/g' \
-e 's/@@java_version@@/$(RELEASE)/g' \
-e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \
-e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \
-e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \
$< > $@.tmp
$(MV) $@.tmp $@
GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java
GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \
$(PROFILE_VERSION_JAVA_TARGETS)
##########################################################################################
# Version file for jconsole
......
......@@ -41,6 +41,8 @@ $(eval $(call FillCacheFind,\
include Tools.gmk
include Profiles.gmk
# Note: This double-colon rule is intentional, to support
# custom make file integration.
images:: jre-image jdk-image
......@@ -84,7 +86,7 @@ endef
################################################################################
#
# Variable prefixes explained:
# JRE_ refers to files in the j2re-image.
# JRE_ refers to files in the j2re-*-image.
# JDK_ refers to files in the j2sdk-image outside of the jre subdir.
# JDKJRE_ refers to files in the j2sdk-image inside the jre subdir.
#
......@@ -92,7 +94,8 @@ endef
################################################################################
# /bin dir
NOT_JRE_BIN_FILES := \
ifeq ($(PROFILE),)
NOT_JRE_BIN_FILES := \
appletviewer$(EXE_SUFFIX) \
extcheck$(EXE_SUFFIX) \
idlj$(EXE_SUFFIX) \
......@@ -125,6 +128,7 @@ NOT_JRE_BIN_FILES := \
schemagen$(EXE_SUFFIX) \
jsadebugd$(EXE_SUFFIX) \
jhat$(EXE_SUFFIX)
endif
WINDOWS_JDK_BIN_FILES = \
$(EXE_SUFFIX) \
......@@ -196,7 +200,8 @@ ifneq ($(OPENJDK_TARGET_OS), macosx)
$(SALIB_NAME)
endif
NOT_JRE_LIB_FILES := \
ifeq ($(PROFILE),)
NOT_JRE_LIB_FILES := \
tools.jar \
jconsole.jar \
sa-jdi.jar \
......@@ -205,8 +210,9 @@ NOT_JRE_LIB_FILES := \
ir.idl \
ct.sym
ifeq ($(OPENJDK_TARGET_OS), windows)
NOT_JRE_LIB_FILES += jawt.lib jvm.lib
ifeq ($(OPENJDK_TARGET_OS), windows)
NOT_JRE_LIB_FILES += jawt.lib jvm.lib
endif
endif
JDK_LIB_FILES := $(NOT_JRE_LIB_FILES)
......@@ -607,6 +613,9 @@ ALL_SOURCE_TIPS = $(shell \
$(JRE_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
$(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
$(call create-info-file)
ifneq ($(PROFILE),)
$(call info-file-item, "JAVA_PROFILE", "$(call profile_name, $(call profile_number, $(PROFILE)))")
endif
$(JDK_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
$(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
......@@ -648,7 +657,7 @@ ifneq ($(POST_STRIP_CMD),)
EXEC_LIST_OVERLAY:=$(filter $(OVERLAY_FILTER),$(EXEC_LIST_BIN)) $(EXEC_LIST_LIB)
# Filter out non JRE files and convert to unique touch files to depend on
JRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped,\
JRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre$(PROFILE)/%.stripped,\
$(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
$(EXEC_LIST)))
......@@ -688,7 +697,7 @@ ifneq ($(POST_STRIP_CMD),)
endef
# Setup a rule for stripping files based on touch files
$(IMAGES_OUTPUTDIR)/_strip_jre/%.stripped: $(JRE_IMAGE_DIR)/%
$(IMAGES_OUTPUTDIR)/_strip_jre$(PROFILE)/%.stripped: $(JRE_IMAGE_DIR)/%
$(call strip-file)
$(IMAGES_OUTPUTDIR)/_strip_jdk/%.stripped: $(JDK_IMAGE_DIR)/%
......@@ -728,6 +737,29 @@ jdk-overlay-image: $(JDK_OVERLAY_BIN_TARGETS) $(JDKJRE_OVERLAY_BIN_TARGETS) \
$(JDK_OVERLAY_DEMO_TARGETS) $(JDK_OVERLAY_INFO_FILE) \
$(JDKJRE_OVERLAY_STRIP_LIST) $(JDK_OVERLAY_BIN_STRIP_LIST)
ifneq ($(PROFILE),)
# Files in lib$(PROFILE) are excluded from the generic copying routines so
# we have to add them back in here
$(foreach f,$(CUSTOM_PROFILE_JARS),\
$(eval $(call AddFileToCopy,$(IMAGES_OUTPUTDIR)/lib$(PROFILE),$(JRE_IMAGE_DIR)/lib,$f,JRE_LIB_TARGETS)))
PROFILE_IMAGE_JARS := $(filter %.jar, $(JRE_LIB_TARGETS))
PROFILE_IMAGE_JARS_CHECKED := $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_jars_checked
$(PROFILE_IMAGE_JARS_CHECKED) : $(PROFILE_IMAGE_JARS)
$(TOOL_CHECKDEPS) $(JRE_IMAGE_DIR) \
$(call profile_name, $(call profile_number, $(PROFILE)))
$(TOUCH) $@
profile-image: $(JRE_BIN_TARGETS) $(JRE_LIB_TARGETS) \
$(JRE_IMAGE_DIR)/lib/meta-index $(JRE_IMAGE_DIR)/lib/ext/meta-index \
$(JRE_INFO_FILE) $(JRE_STRIP_LIST) $(PROFILE_IMAGE_JARS_CHECKED)
.PHONY: profile-image
endif # Profile
################################################################################
.PHONY: default images jre-image jdk-image
......@@ -100,33 +100,13 @@ IMPORT_TARGET_FILES += $(IMPORT_TARGET_CLASSES) $(IMPORT_TARGET_SOURCES) $(IMPOR
#######
ifeq ($(OPENJDK_TARGET_OS),solaris)
define do-install-file
$(MKDIR) -p '$$(@D)'
$(RM) '$$@'
$(CP) -r -P '$$<' '$$(@D)'
endef
else ifeq ($(OPENJDK_TARGET_OS),macosx)
define do-install-file
$(MKDIR) -p '$$(@D)'
$(RM) '$$@'
$(CP) -pRP '$$<' '$$@'
endef
else
define do-install-file
$(MKDIR) -p '$$(@D)'
$(RM) '$$@'
$(CP) -P '$$<' '$$@'
endef
endif
define CopyDir
$1_SRC_FILES := $(shell $(FIND) $2 -type f -a \( -name DUMMY $(addprefix -o$(SPACE)-name$(SPACE),$4) \))
$1_DST_FILES := $$(patsubst $2/%,$3/%,$$($1_SRC_FILES))
IMPORT_TARGET_FILES += $$($1_DST_FILES)
$3/% : $2/%
$(ECHO) $(LOG_INFO) Copying $$(@F)
$(do-install-file)
$$(install-file)
endef
#######
......@@ -155,6 +135,12 @@ ifneq ($(OPENJDK_TARGET_OS), windows)
IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/client/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
endif
endif
ifeq ($(JVM_VARIANT_MINIMAL1), true)
IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX)
ifneq (,$(JSIG_DEBUGINFO))
IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/minimal/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I))
endif
endif
endif
$(INSTALL_LIBRARIES_HERE)/server/%$(SHARED_LIBRARY_SUFFIX) : $(INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
......@@ -195,27 +181,24 @@ $(INSTALL_LIBRARIES_HERE)/client/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz
$(RM) $(basename $@).debuginfo
$(MV) $@.tmp $@
#######
$(INSTALL_LIBRARIES_HERE)/minimal/%$(SHARED_LIBRARY_SUFFIX) : $(INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX)
$(MKDIR) -p $(@D)
$(RM) $@
$(LN) -s ../$(@F) $@
ifeq ($(OPENJDK_TARGET_OS),solaris)
define install-file
$(MKDIR) -p '$(@D)'
$(RM) '$@'
$(CP) -r -P '$<' '$(@D)'
endef
else ifeq ($(OPENJDK_TARGET_OS),macosx)
define install-file
$(MKDIR) -p '$(@D)'
$(RM) '$@'
$(CP) -pRP '$<' '$@'
endef
else
define install-file
$(MKDIR) -p '$(@D)'
$(RM) '$@'
$(CP) -P '$<' '$@'
endef
endif
$(INSTALL_LIBRARIES_HERE)/minimal/%.debuginfo : $(INSTALL_LIBRARIES_HERE)/%.debuginfo
$(MKDIR) -p $(@D)
$(RM) $@
$(LN) -s ../$(@F) $@
$(INSTALL_LIBRARIES_HERE)/minimal/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz
$(MKDIR) -p $(@D)
$(RM) $@
$(RM) $@.tmp $(basename $@).debuginfo
$(LN) -s ../$(basename $(@F)).debuginfo $(basename $@).debuginfo
$(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F)).debuginfo
$(RM) $(basename $@).debuginfo
$(MV) $@.tmp $@
#######
......
#
# Copyright (c) 2012, 2013, 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. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# This was split out from Profiles.gmk to allow GenSrcMisc.gmk to include it
# without attempting to generate lists for output files that don't exist yet
# These are the external names of each profile
PROFILE_NAMES := compact1 compact2 compact3
# The include files use 1,2,3,4 for simplicity and conciseness. Internally we
# use profile_1, profile_2 and profile_3. Note that profile_4 is a full JRE so
# we never have to use it directly.
ALL_PROFILES := profile_1 profile_2 profile_3
# This defines targets to generate per-profile Version.java/class files into
# distinct locations
VERSION_JAVA_DIR := sun/misc
VERSION_JAVA_FILE := Version.java
VERSION_JAVA_PATH := $(VERSION_JAVA_DIR)/$(VERSION_JAVA_FILE)
VERSION_CLASS_PATH := $(VERSION_JAVA_PATH:.java=.class)
PROFILE_VERSION_JAVA_TARGETS := $(foreach i, $(ALL_PROFILES), $(subst XXX,$i, $(JDK_OUTPUTDIR)/gen_XXX/$(VERSION_JAVA_PATH)))
PROFILE_VERSION_CLASS_TARGETS := $(foreach i, $(PROFILE_VERSION_JAVA_TARGETS), $(i:.java=.class))
# Function to map from profile designator, profile_1 etc, to its number
profile_number = $(if $(patsubst profile_%,%, $(1)),$(patsubst profile_%,%, $(1)), $(words $(PROFILE_NAMES) extra))
# Function to map from profile number, 1, 2 etc, to the corresponding name
# An invalid number maps to an empty name
profile_name = $(word $(1), $(PROFILE_NAMES))
# Function to isolate a profile number from a Version.java target
# Evaluates to the arg if the arg is not a profile version target
profile_version_number = $(patsubst $(JDK_OUTPUTDIR)/gen_profile_%/$(VERSION_JAVA_PATH), %, $(1))
# Function to go from a profile Version.java target to profile name. If not
# a profile version target then we need a number that maps to an empty name
profile_version_name = $(word $(if $(filter-out $(call profile_version_number, $(1)), $(1)), $(call profile_version_number, $(1)), $(words $(PROFILE_NAMES) extra)), $(PROFILE_NAMES))
#
# Copyright (c) 2012, 2013, 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. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include ProfileNames.gmk
# This defines the include lists for each profile, categorized as lib, bin
# and other. We can use these to define the file lists for each profile
# directly, rather than constructing a set of files to exclude from the
# set of all files. But initially we will stick with generating exclude lists
# as that is how the main build process already works.
include profile-includes.txt
###############################################################################
# Per profile Jar lists
#
# These are the jar files to be built. In some builds these have to be
# imported (signed jars) rather than built.
#
# The incoming lists, eg PROFILE_1_JRE_JARS_FILES, are the jars to be
# included in this profile. They have the jar name relative to the lib
# directory. We have to turn these into targets by adding the
# $(IMAGES_OUTPUTDIR)/lib prefix
#
# Note that some jars may be optional depending on the type of build (jdk vs.
# openjdk) and the platform.
#
# WARNING: incoming lists are currently validated for linux only!
###############################################################################
# These are jar files for which the contents vary depending on the profile
CUSTOM_JARS := rt.jar resources.jar
# This is used in Images.gmk
CUSTOM_PROFILE_JARS := $(addprefix $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/, $(CUSTOM_JARS))
# These are the common jar files built for and included with this profile
# Filter out the custom jars and turn them into targets.
PROFILE_1_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(filter-out $(CUSTOM_JARS), $(PROFILE_1_JRE_JAR_FILES)))
PROFILE_2_JARS := \
$(if $(PROFILE_2_JRE_JAR_FILES), $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_2_JRE_JAR_FILES))) \
$(PROFILE_1_JARS)
ifneq ($(ENABLE_JFR), true)
PROFILE_3_JRE_JAR_FILES := $(filter-out jfr.jar, $(PROFILE_3_JRE_JAR_FILES))
endif
PROFILE_3_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_3_JRE_JAR_FILES)) \
$(PROFILE_2_JARS)
ifdef OPENJDK
PROFILE_4_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(PROFILE_4_JRE_JAR_FILES))
endif
PROFILE_4_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_4_JRE_JAR_FILES)) \
$(PROFILE_3_JARS)
# The full set of "jar" files needed for a complete JDK (ct.sym and src.zip
# are also included.)
# Note we need to add back the regular form of all the custom profile jars e.g.
# rt.jar and resources.jar
ALL_JARS := $(PROFILE_4_JARS) \
$(IMAGES_OUTPUTDIR)/lib/rt.jar \
$(IMAGES_OUTPUTDIR)/lib/resources.jar \
$(IMAGES_OUTPUTDIR)/lib/jconsole.jar \
$(IMAGES_OUTPUTDIR)/lib/dt.jar \
$(IMAGES_OUTPUTDIR)/lib/tools.jar \
$(IMAGES_OUTPUTDIR)/lib/ct.sym \
$(IMAGES_OUTPUTDIR)/src.zip \
$(IMAGES_OUTPUTDIR)/lib/ext/cldrdata.jar \
$(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar
ifeq ($(OPENJDK_TARGET_OS),solaris)
ifndef OPENJDK
ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/ext/ucrypto.jar
endif
endif
ifeq ($(OPENJDK_TARGET_OS),windows)
ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/ext/sunmscapi.jar
endif
ifeq ($(OPENJDK_TARGET_OS),macosx)
ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/JObjC.jar
endif
ifeq ($(PROFILE), profile_1)
PROFILE_JARS := $(PROFILE_1_JARS)
else ifeq ($(PROFILE), profile_2)
PROFILE_JARS := $(PROFILE_2_JARS)
else ifeq ($(PROFILE), profile_3)
PROFILE_JARS := $(PROFILE_3_JARS)
endif
ifneq ($(PROFILE),)
JARS := $(CUSTOM_PROFILE_JARS) $(PROFILE_JARS)
else
JARS := $(ALL_JARS)
endif
###############################################################################
# JRE contents
###############################################################################
# we don't need to do anything if not building a profile
ifneq ($(PROFILE),)
# Need all files to generate the exclude lists
NEW_ALL_BIN_LIST := $(patsubst $(JDK_OUTPUTDIR)/bin/%,%,$(shell $(FIND) $(JDK_OUTPUTDIR)/bin \( -type f -o -type l \) ! -name "sjavac"))
ALL_JRE_BIN_FILES := \
$(PROFILE_1_JRE_BIN_FILES) \
$(PROFILE_2_JRE_BIN_FILES) \
$(PROFILE_3_JRE_BIN_FILES) \
$(PROFILE_4_JRE_BIN_FILES)
NOT_JRE_BIN_FILES := $(filter-out $(ALL_JRE_BIN_FILES), $(NEW_ALL_BIN_LIST))
# Additional exclusions for profile JRE
ifeq ($(PROFILE), profile_1)
NOT_JRE_BIN_FILES += \
$(PROFILE_2_JRE_BIN_FILES) \
$(PROFILE_3_JRE_BIN_FILES) \
$(PROFILE_4_JRE_BIN_FILES)
endif
ifeq ($(PROFILE), profile_2)
NOT_JRE_BIN_FILES += \
$(PROFILE_3_JRE_BIN_FILES) \
$(PROFILE_4_JRE_BIN_FILES)
endif
ifeq ($(PROFILE), profile_3)
NOT_JRE_BIN_FILES += \
$(PROFILE_4_JRE_BIN_FILES)
endif
NOT_JRE_BIN_FILES := $(addprefix $(JDK_OUTPUTDIR)/bin/, $(NOT_JRE_BIN_FILES))
# Need all files to generate the exclude lists
NEW_ALL_LIB_LIST := $(patsubst $(JDK_OUTPUTDIR)/lib/%,%,$(shell $(FIND) $(JDK_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \( -name "_the*" -o -name "javac_state " \) ))
NEW_ALL_LIB_LIST += $(patsubst $(IMAGES_OUTPUTDIR)/lib/%,%,$(shell $(FIND) $(IMAGES_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \( -name "_the*" -o -name "javac_state " \) ))
ALL_JRE_LIB_FILES := \
$(PROFILE_1_JRE_LIB_FILES) \
$(PROFILE_2_JRE_LIB_FILES) \
$(PROFILE_3_JRE_LIB_FILES) \
$(PROFILE_4_JRE_LIB_FILES)
NOT_JRE_LIB_FILES := $(filter-out $(ALL_JRE_LIB_FILES), $(NEW_ALL_LIB_LIST))
# Although these are NOT JRE lib files we have to filter them from the list
# (ie cause them to be added them back in here) because the logic in
# Images.gmk expects them to be there and handles them differently.
# If we don't, they end up in the wrong place in the JDK image.
# This needs fixing.
NOT_JRE_LIB_FILES := $(filter-out $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(SALIB_NAME), $(NOT_JRE_LIB_FILES))
# Additional exclusions for profile JREs
ifeq ($(PROFILE), profile_1)
NOT_JRE_LIB_FILES += \
$(PROFILE_2_JRE_LIB_FILES) \
$(PROFILE_3_JRE_LIB_FILES) \
$(PROFILE_4_JRE_LIB_FILES)
endif
ifeq ($(PROFILE), profile_2)
NOT_JRE_LIB_FILES += \
$(PROFILE_3_JRE_LIB_FILES) \
$(PROFILE_4_JRE_LIB_FILES)
endif
ifeq ($(PROFILE), profile_3)
NOT_JRE_LIB_FILES += \
$(PROFILE_4_JRE_LIB_FILES)
endif
# Exclude the custom jar files as these will be added back via a special rule
NOT_JRE_LIB_FILES += $(CUSTOM_JARS)
###############################################################################
# Customization of rt.jar file contents
# These are expressed as exclusions from everything found in the
# JDK_OUTPUTDIR/classes directory
###############################################################################
# The main set of excluded types/packages (ie everything not destined to be
# part of rt.jar or resources.jar is captured in the CreateJars.gmk RT_JAR_EXCLUDES
# variable. We add to that for the per-profile exclusion lists
# For each profile we have four variables:
#
# - PROFILE_n_RTJAR_INCLUDE_PACKAGES
#
# This is a package prefix indicating that all classes in that package
# and conditionally its subpackages are included in rt.jar for this profile.
# The subpackages will be included as long as they do not appear in the
# include list of a higher profile
#
# - PROFILE_n_RTJAR_INCLUDE_TYPES
#
# These are specific types that must be included within a package.
# There are two cases:
# - individual types in a package that is otherwise excluded at this
# profile level. The only arises if there are split packages.
#
# - A higher-level package is included in a high profile where a subpackage
# is included in a lower profile. Including the package in the high profile
# would exclude it and all subpackages from the lower profile, so instead
# the classes in the package are listed for that higher profile (as *.class)
#
# These types are explicitly added back into the rt.jar content lists.
#
# - PROFILE_n_RTJAR_EXCLUDE_TYPES
#
# These are specific types that must be excluded even though most of the
# containing package is include. Again this occurs with split packges.
#
# So the exclude list for each profile consists of the include lists
# for all profiles above it, together with any explicitly excluded types.
# This is then combined with the overall RT_JAR_EXCLUDES list (which covers
# things that go into other jar files).
#
# We also have to define the types to be explicitly included. This
# accumulates up the profiles ie profile 3 has to include the types
# that profiles 1 and 2 had to include. This is unnecessary if, for example,
# profile 3 includes the entire package, but it is harmless to add them
# explicitly, and complex to determine if we still need to include them.
#
# Need a way to express:
# for (int i = profile+1; i < 4; i++)
# RT_JAR_EXCLUDES += PROFILE_$i_RTJAR_INCLUDE_PACKAGES
#
# Do it the long way for now
#
# - PROFILE_n_INCLUDE_METAINF_SERVICES
#
# These are META-INF/services/ entries found in resources.jar. Together
# resources.jar and rt.jar hold the contents of the classes directory, (the
# classes in rt.jar and everything else in resources.jar).Hence the
# include/exclude information for resources.jar is tied to that of rt.jar
include profile-rtjar-includes.txt
# Function to expand foo/*.class into the set of classes
# NOTE: Classfiles with $ in their name are problematic as that is the
# meta-character for both make and the shell! Hence the \$$$$ substitution.
# But note that if you echo these values they will NOT display as expected.
class_list = $(patsubst $(JDK_OUTPUTDIR)/classes/%,%,\
$(foreach i,$(1), $(subst $$,\$$$$, $(wildcard $(JDK_OUTPUTDIR)/classes/$i))))
ifeq ($(PROFILE), profile_1)
RT_JAR_EXCLUDES += \
$(PROFILE_1_RTJAR_EXCLUDE_TYPES) \
$(PROFILE_2_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
$(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
$(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
RT_JAR_INCLUDE_TYPES := \
$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES))
PROFILE_INCLUDE_METAINF_SERVICES := \
$(PROFILE_1_INCLUDE_METAINF_SERVICES)
endif
ifeq ($(PROFILE), profile_2)
RT_JAR_EXCLUDES += \
$(PROFILE_2_RTJAR_EXCLUDE_TYPES) \
$(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
$(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
RT_JAR_INCLUDE_TYPES := \
$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES))
PROFILE_INCLUDE_METAINF_SERVICES := \
$(PROFILE_1_INCLUDE_METAINF_SERVICES) \
$(PROFILE_2_INCLUDE_METAINF_SERVICES)
endif
ifeq ($(PROFILE), profile_3)
RT_JAR_EXCLUDES += \
$(PROFILE_3_RTJAR_EXCLUDE_TYPES) \
$(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
$(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
RT_JAR_INCLUDE_TYPES := \
$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
$(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES))
PROFILE_INCLUDE_METAINF_SERVICES := \
$(PROFILE_1_INCLUDE_METAINF_SERVICES) \
$(PROFILE_2_INCLUDE_METAINF_SERVICES) \
$(PROFILE_3_INCLUDE_METAINF_SERVICES)
endif
# Filter out non-OpenJDK services
ifdef OPENJDK
EXCLUDED_SERVICES := META-INF/services/javax.script.ScriptEngineFactory
PROFILE_INCLUDE_METAINF_SERVICES := $(filter-out $(EXCLUDED_SERVICES),$(PROFILE_INCLUDE_METAINF_SERVICES))
endif
endif # profile
......@@ -53,6 +53,14 @@ $(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/%.template : \
BUILD_TOOLS += $(foreach i,$(wildcard $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/*.template),$(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/$(notdir $i))
# Resources used by CheckDeps tool
$(JDK_OUTPUTDIR)/btclasses/build/tools/deps/% : \
$(JDK_TOPDIR)/make/tools/src/build/tools/deps/%
$(MKDIR) -p $(@D)
$(CP) $< $@
BUILD_TOOLS += $(JDK_OUTPUTDIR)/btclasses/build/tools/deps/refs.allowed
# Add a checksum ("jsum") to the end of a text file. Prevents trivial tampering with class lists.
TOOL_ADDJSUM=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.addjsum.AddJsum
......@@ -137,6 +145,14 @@ TOOL_OSX_TOBIN=$(JAVA) -Djava.awt.headless=true -cp $(JDK_OUTPUTDIR)/btclasses \
TOOL_CLDRCONVERTER=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.cldrconverter.CLDRConverter
TOOL_REMOVEMETHODS=$(JAVA) -Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
-cp $(JDK_OUTPUTDIR)/btclasses:$(JDK_OUTPUTDIR) \
build.tools.classfile.RemoveMethods
TOOL_CHECKDEPS=$(JAVA) -Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
-cp $(JDK_OUTPUTDIR)/btclasses:$(JDK_OUTPUTDIR) \
build.tools.deps.CheckDeps
##########################################################################################
# Tools needed on solaris because OBJCOPY is broken.
......
#
# Copyright (c) 2012, 2013, 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. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
PROFILE_1_JRE_BIN_FILES := \
java$(EXE_SUFFIX) \
keytool$(EXE_SUFFIX)
PROFILE_1_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)net$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)nio$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)verify$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)verify.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)zip$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/client/Xusage.txt \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/jli/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/jvm.cfg \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/minimal/Xusage.txt \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jsig.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
calendars.properties \
classlist \
content-types.properties \
currency.data \
ext/localedata.jar \
ext/meta-index \
ext/sunjce_provider.jar \
jce.jar \
jsse.jar \
logging.properties \
meta-index \
net.properties \
resources.jar \
rt.jar \
security/US_export_policy.jar \
security/blacklist \
security/cacerts \
security/java.policy \
security/java.security \
security/local_policy.jar \
security/trusted.libraries \
tzdb.jar
PROFILE_1_JRE_OTHER_FILES := \
COPYRIGHT \
LICENSE \
README \
THIRDPARTYLICENSEREADME.txt \
Welcome.html \
release
PROFILE_1_JRE_JAR_FILES := \
ext/localedata.jar \
ext/sunjce_provider.jar \
jce.jar \
jsse.jar \
resources.jar \
rt.jar \
security/US_export_policy.jar \
security/local_policy.jar \
tzdb.jar
PROFILE_2_JRE_BIN_FILES := \
rmid$(EXE_SUFFIX) \
rmiregistry$(EXE_SUFFIX)
PROFILE_2_JRE_LIB_FILES :=
PROFILE_2_JRE_OTHER_FILES :=
PROFILE_2_JRE_JAR_FILES :=
PROFILE_3_JRE_BIN_FILES :=
PROFILE_3_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)hprof$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)hprof.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)instrument$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)instrument.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2gss$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2pcsc$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jaas_unix$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java_crw_demo$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)java_crw_demo.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jfr$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsdt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsdt.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX) \
jfr.jar \
jvm.hprof.txt \
management-agent.jar \
management/jmxremote.access \
management/jmxremote.password.template \
management/management.properties \
management/snmp.acl.template
PROFILE_3_JRE_OTHER_FILES :=
PROFILE_3_JRE_JAR_FILES := \
jfr.jar \
management-agent.jar
PROFILE_4_JRE_BIN_FILES := \
orbd$(EXE_SUFFIX) \
pack200$(EXE_SUFFIX) \
policytool$(EXE_SUFFIX) \
servertool$(EXE_SUFFIX) \
tnameserv$(EXE_SUFFIX) \
unpack200$(EXE_SUFFIX)
PROFILE_4_JRE_LIB_FILES := \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dcpr$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dt_socket$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)dt_socket.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)fontmanager$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)j2pkcs11$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jawt$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jdwp$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jpeg$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsound$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)jsoundalsa$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)kcms$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)mlib_image$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)splashscreen$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sunec$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)t2k$(SHARED_LIBRARY_SUFFIX) \
alt-rt.jar \
charsets.jar \
cmm/CIEXYZ.pf \
cmm/GRAY.pf \
cmm/LINEAR_RGB.pf \
cmm/PYCC.pf \
cmm/sRGB.pf \
ext/cldrdata.jar \
ext/dnsns.jar \
ext/sunec.jar \
ext/sunpkcs11.jar \
ext/zipfs.jar \
flavormap.properties \
fontconfig.RedHat.5.bfc \
fontconfig.RedHat.5.properties.src \
fontconfig.RedHat.6.bfc \
fontconfig.RedHat.6.properties.src \
fontconfig.SuSE.10.bfc \
fontconfig.SuSE.10.properties.src \
fontconfig.SuSE.11.bfc \
fontconfig.SuSE.11.properties.src \
fontconfig.Turbo.bfc \
fontconfig.Turbo.properties.src \
fontconfig.bfc \
fontconfig.properties.src \
fonts/LucidaBrightDemiBold.ttf \
fonts/LucidaBrightDemiItalic.ttf \
fonts/LucidaBrightItalic.ttf \
fonts/LucidaBrightRegular.ttf \
fonts/LucidaSansDemiBold.ttf \
fonts/LucidaSansRegular.ttf \
fonts/LucidaTypewriterBold.ttf \
fonts/LucidaTypewriterRegular.ttf \
fonts/fonts.dir \
images/cursors/cursors.properties \
images/cursors/invalid32x32.gif \
images/cursors/motif_CopyDrop32x32.gif \
images/cursors/motif_CopyNoDrop32x32.gif \
images/cursors/motif_LinkDrop32x32.gif \
images/cursors/motif_LinkNoDrop32x32.gif \
images/cursors/motif_MoveDrop32x32.gif \
images/cursors/motif_MoveNoDrop32x32.gif \
jexec \
oblique-fonts/LucidaSansDemiOblique.ttf \
oblique-fonts/LucidaSansOblique.ttf \
oblique-fonts/LucidaTypewriterBoldOblique.ttf \
oblique-fonts/LucidaTypewriterOblique.ttf \
oblique-fonts/fonts.dir \
psfont.properties.ja \
psfontj2d.properties \
servicetag/jdk_header.png \
sound.properties
PROFILE_4_JRE_OTHER_FILES := \
man/ja_JP.UTF-8/man1/java.1 \
man/ja_JP.UTF-8/man1/javaws.1 \
man/ja_JP.UTF-8/man1/keytool.1 \
man/ja_JP.UTF-8/man1/orbd.1 \
man/ja_JP.UTF-8/man1/pack200.1 \
man/ja_JP.UTF-8/man1/policytool.1 \
man/ja_JP.UTF-8/man1/rmid.1 \
man/ja_JP.UTF-8/man1/rmiregistry.1 \
man/ja_JP.UTF-8/man1/servertool.1 \
man/ja_JP.UTF-8/man1/tnameserv.1 \
man/ja_JP.UTF-8/man1/unpack200.1 \
man/man1/java.1 \
man/man1/javaws.1 \
man/man1/keytool.1 \
man/man1/orbd.1 \
man/man1/pack200.1 \
man/man1/policytool.1 \
man/man1/rmid.1 \
man/man1/rmiregistry.1 \
man/man1/servertool.1 \
man/man1/tnameserv.1 \
man/man1/unpack200.1
PROFILE_4_JRE_JAR_FILES := \
alt-rt.jar \
charsets.jar \
ext/cldrdata.jar \
ext/dnsns.jar \
ext/sunec.jar \
ext/sunpkcs11.jar \
ext/zipfs.jar
此差异已折叠。
......@@ -57,6 +57,12 @@ import sun.security.util.SecurityConstants;
* <p>
* The classes that are loaded are by default granted permission only to
* access the URLs specified when the URLClassLoader was created.
* <p>
* Where a JAR file contains the {@link Name#PROFILE Profile} attribute
* then its value is the name of the Java SE profile that the library
* minimally requires. If this runtime does not support the profile then
* it causes {@link java.util.jar.UnsupportedProfileException} to be
* thrown at some unspecified time.
*
* @author David Connelly
* @since 1.2
......
......@@ -564,6 +564,15 @@ public class Attributes implements Map<Object,Object>, Cloneable {
*/
public static final Name MAIN_CLASS = new Name("Main-Class");
/**
* {@code Name} object for {@code Profile} manifest attribute used by
* applications or libraries packaged as JAR files to indicate the
* minimum profile required to execute the application.
* @since 1.8
* @see UnsupportedProfileException
*/
public static final Name PROFILE = new Name("Profile");
/**
* <code>Name</code> object for <code>Sealed</code> manifest attribute
* used for sealing.
......
......@@ -574,6 +574,13 @@ public abstract class Pack200 {
* Registers a listener for PropertyChange events on the properties map.
* This is typically used by applications to update a progress bar.
*
* <p> The default implementation of this method does nothing and has
* no side-effects.</p>
*
* <p><b>WARNING:</b> This method is omitted from the interface
* declaration in all subset Profiles of Java SE that do not include
* the {@code java.beans} package. </p>
* @see #properties
* @see #PROGRESS
* @param listener An object to be invoked when a property is changed.
......@@ -586,12 +593,20 @@ public abstract class Pack200 {
* property instead.
*/
@Deprecated
void addPropertyChangeListener(PropertyChangeListener listener) ;
default void addPropertyChangeListener(PropertyChangeListener listener) {
}
/**
* Remove a listener for PropertyChange events, added by
* the {@link #addPropertyChangeListener}.
*
* <p> The default implementation of this method does nothing and has
* no side-effects.</p>
*
* <p><b>WARNING:</b> This method is omitted from the interface
* declaration in all subset Profiles of Java SE that do not include
* the {@code java.beans} package. </p>
*
* @see #addPropertyChangeListener
* @param listener The PropertyChange listener to be removed.
* @deprecated The dependency on {@code PropertyChangeListener} creates
......@@ -600,8 +615,8 @@ public abstract class Pack200 {
* release.
*/
@Deprecated
void removePropertyChangeListener(PropertyChangeListener listener);
default void removePropertyChangeListener(PropertyChangeListener listener) {
}
}
/**
......@@ -718,6 +733,13 @@ public abstract class Pack200 {
* Registers a listener for PropertyChange events on the properties map.
* This is typically used by applications to update a progress bar.
*
* <p> The default implementation of this method does nothing and has
* no side-effects.</p>
*
* <p><b>WARNING:</b> This method is omitted from the interface
* declaration in all subset Profiles of Java SE that do not include
* the {@code java.beans} package. </p>
*
* @see #properties
* @see #PROGRESS
* @param listener An object to be invoked when a property is changed.
......@@ -730,12 +752,20 @@ public abstract class Pack200 {
* PROGRESS} property instead.
*/
@Deprecated
void addPropertyChangeListener(PropertyChangeListener listener) ;
default void addPropertyChangeListener(PropertyChangeListener listener) {
}
/**
* Remove a listener for PropertyChange events, added by
* the {@link #addPropertyChangeListener}.
*
* <p> The default implementation of this method does nothing and has
* no side-effects.</p>
*
* <p><b>WARNING:</b> This method is omitted from the interface
* declaration in all subset Profiles of Java SE that do not include
* the {@code java.beans} package. </p>
*
* @see #addPropertyChangeListener
* @param listener The PropertyChange listener to be removed.
* @deprecated The dependency on {@code PropertyChangeListener} creates
......@@ -744,7 +774,8 @@ public abstract class Pack200 {
* release.
*/
@Deprecated
void removePropertyChangeListener(PropertyChangeListener listener);
default void removePropertyChangeListener(PropertyChangeListener listener) {
}
}
// Private stuff....
......
/*
* Copyright (c) 2012, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.util.jar;
/**
* Thrown to indicate an attempt to access a JAR file with a {@link
* Attributes.Name#PROFILE Profile} attribute that names a profile that
* is not supported by this runtime.
*
* @since 1.8
*/
public class UnsupportedProfileException extends RuntimeException {
private static final long serialVersionUID = -1834773870678792406L;
/**
* Constructs an {@code UnsupportedProfileException} with no detail
* message.
*/
public UnsupportedProfileException() {
}
/**
* Constructs an {@code UnsupportedProfileException} with the
* specified detail message.
*
* @param message the detail message
*/
public UnsupportedProfileException(String message) {
super(message);
}
}
......@@ -302,6 +302,10 @@ public class LogManager {
* the same event Listener results in multiple entries
* in the property event listener table.
*
* <p><b>WARNING:</b> This method is omitted from this class in all subset
* Profiles of Java SE that do not include the {@code java.beans} package.
* </p>
*
* @param l event listener
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
......@@ -335,6 +339,10 @@ public class LogManager {
* <P>
* Returns silently if the given listener is not found.
*
* <p><b>WARNING:</b> This method is omitted from this class in all subset
* Profiles of Java SE that do not include the {@code java.beans} package.
* </p>
*
* @param l event listener (can be null)
* @exception SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
......
......@@ -65,10 +65,14 @@ import java.util.TreeSet;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import sun.misc.Version;
import sun.misc.URLClassPath;
public enum LauncherHelper {
INSTANCE;
private static final String MAIN_CLASS = "Main-Class";
private static final String PROFILE = "Profile";
private static StringBuilder outBuf = new StringBuilder();
private static final String INDENT = " ";
......@@ -409,6 +413,28 @@ public enum LauncherHelper {
if (mainValue == null) {
abort(null, "java.launcher.jar.error3", jarname);
}
/*
* If this is not a full JRE then the Profile attribute must be
* present with the Main-Class attribute so as to indicate the minimum
* profile required. Note that we need to suppress checking of the Profile
* attribute after we detect an error. This is because the abort may
* need to lookup resources and this may involve opening additional JAR
* files that would result in errors that suppress the main error.
*/
String profile = mainAttrs.getValue(PROFILE);
if (profile == null) {
if (!Version.isFullJre()) {
URLClassPath.suppressProfileCheckForLauncher();
abort(null, "java.launcher.jar.error4", jarname);
}
} else {
if (!Version.supportsProfile(profile)) {
URLClassPath.suppressProfileCheckForLauncher();
abort(null, "java.launcher.jar.error5", profile, jarname);
}
}
/*
* Hand off to FXHelper if it detects a JavaFX application
* This must be done after ensuring a Main-Class entry
......@@ -418,6 +444,7 @@ public enum LauncherHelper {
new Attributes.Name(FXHelper.JAVAFX_APPLICATION_MARKER))) {
return FXHelper.class.getName();
}
return mainValue.trim();
} catch (IOException ioe) {
abort(ioe, "java.launcher.jar.error1", jarname);
......
......@@ -139,6 +139,8 @@ java.launcher.jar.error1=\
Error: An unexpected error occurred while trying to open file {0}
java.launcher.jar.error2=manifest not found in {0}
java.launcher.jar.error3=no main manifest attribute, in {0}
java.launcher.jar.error4=no Profile manifest attribute in {0}
java.launcher.jar.error5=Profile {0} required by {1} not supported by this runtime
java.launcher.init.error=initialization error
java.launcher.javafx.error1=\
Error: The JavaFX launchApplication method has the wrong signature, it\n\
......
......@@ -35,6 +35,7 @@ import java.util.jar.JarEntry;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.UnsupportedProfileException;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
......@@ -64,6 +65,12 @@ public class URLClassPath {
final static String JAVA_VERSION;
private static final boolean DEBUG;
/**
* Used by launcher to indicate that checking of the JAR file "Profile"
* attribute has been suppressed.
*/
private static boolean profileCheckSuppressedByLauncher;
static {
JAVA_VERSION = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.version"));
......@@ -582,6 +589,15 @@ public class URLClassPath {
}
}
/**
* Used by the launcher to suppress further checking of the JAR file Profile
* attribute (necessary when the launcher is aborting as the abort involves
* a resource lookup that may involve opening additional JAR files)
*/
public static void suppressProfileCheckForLauncher() {
profileCheckSuppressedByLauncher = true;
}
/*
* Inner class used to represent a Loader of resources from a JAR URL.
*/
......@@ -789,6 +805,28 @@ public class URLClassPath {
return false;
}
/**
* If the Profile attribute is present then this method checks that the runtime
* supports that profile.
*
* ## Add a fast path like Class-Path to avoid reading the manifest when the attribute
* is not present.
*/
void checkProfileAttribute() throws IOException {
Manifest man = jar.getManifest();
if (man != null) {
Attributes attr = man.getMainAttributes();
if (attr != null) {
String value = attr.getValue(Name.PROFILE);
if (value != null && !Version.supportsProfile(value)) {
String prefix = Version.profileName().length() > 0 ?
"This runtime implements " + Version.profileName() + ", " : "";
throw new UnsupportedProfileException(prefix + csu + " requires " + value);
}
}
}
}
/*
* Returns the URL for a resource with the specified name
*/
......@@ -958,6 +996,12 @@ public class URLClassPath {
ensureOpen();
parseExtensionsDependencies();
// check Profile attribute if present
if (!profileCheckSuppressedByLauncher) {
checkProfileAttribute();
}
if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) { // Only get manifest when necessary
Manifest man = jar.getManifest();
if (man != null) {
......
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2012, 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
......@@ -36,8 +36,11 @@ public class Version {
"@@java_version@@";
private static final String java_runtime_name =
"@@java_runtime_name@@";
"@@java_runtime_name@@";
private static final String java_profile_name =
"@@java_profile_name@@";
private static final String java_runtime_version =
"@@java_runtime_version@@";
......@@ -49,6 +52,8 @@ public class Version {
System.setProperty("java.version", java_version);
System.setProperty("java.runtime.version", java_runtime_version);
System.setProperty("java.runtime.name", java_runtime_name);
if (java_profile_name.length() > 0)
System.setProperty("java.runtime.profile", java_profile_name);
}
private static boolean versionsInitialized = false;
......@@ -90,23 +95,28 @@ public class Version {
boolean isHeadless = false;
/* Report that we're running headless if the property is true */
String headless = System.getProperty("java.awt.headless");
if ( (headless != null) && (headless.equalsIgnoreCase("true")) ) {
String headless = System.getProperty("java.awt.headless");
if ( (headless != null) && (headless.equalsIgnoreCase("true")) ) {
isHeadless = true;
}
}
/* First line: platform version. */
ps.println(launcher_name + " version \"" + java_version + "\"");
/* Second line: runtime version (ie, libraries). */
ps.print(java_runtime_name + " (build " + java_runtime_version);
ps.print(java_runtime_name + " (build " + java_runtime_version);
if (java_profile_name.length() > 0) {
// profile name
ps.print(", profile " + java_profile_name);
}
if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) {
// embedded builds report headless state
ps.print(", headless");
}
ps.println(')');
if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) {
// embedded builds report headless state
ps.print(", headless");
}
ps.println(')');
/* Third line: JVM information. */
String java_vm_name = System.getProperty("java.vm.name");
......@@ -332,6 +342,67 @@ public class Version {
private static native boolean getJvmVersionInfo();
private static native void getJdkVersionInfo();
// Possible runtime profiles, ordered from small to large
private final static String[] PROFILES = { "compact1", "compact2", "compact3" };
/**
* Returns the name of the profile that this runtime implements. The empty
* string is returned for the full Java Runtime.
*/
public static String profileName() {
return java_profile_name;
}
/**
* Indicates if this runtime implements the full Java Runtime.
*/
public static boolean isFullJre() {
return java_profile_name.length() == 0;
}
// cached index of this profile's name in PROFILES (1-based)
private static int thisRuntimeIndex;
/**
* Indicates if this runtime supports the given profile. Profile names are
* case sensitive.
*
* @return {@code true} if the given profile is supported
*/
public static boolean supportsProfile(String requiredProfile) {
int x = thisRuntimeIndex - 1;
if (x < 0) {
String profile = profileName();
if (profile.length() > 0) {
x = 0;
while (x < PROFILES.length) {
if (PROFILES[x].equals(profile))
break;
x++;
}
if (x >= PROFILES.length)
throw new InternalError(profile + " not known to sun.misc.Version");
// okay if another thread has already set it
thisRuntimeIndex = x + 1;
}
// else we are a full JRE
}
int y = 0;
while (y < PROFILES.length) {
if (PROFILES[y].equals(requiredProfile))
break;
y++;
}
if (y >= PROFILES.length) {
// profile not found so caller has requested something that is not defined
return false;
}
return x < 0 || x >= y;
}
}
// Help Emacs a little because this file doesn't end in .java.
......
......@@ -47,7 +47,7 @@ public
class Main {
String program;
PrintStream out, err;
String fname, mname, ename;
String fname, mname, ename, pname;
String zname = "";
String[] files;
String rootjar = null;
......@@ -78,6 +78,9 @@ class Main {
static final String MANIFEST_DIR = "META-INF/";
static final String VERSION = "1.0";
// valid values for Profile attribute
private static final String[] PROFILES = { "compact1", "compact2", "compact3" };
private static ResourceBundle rsrc;
/**
......@@ -184,6 +187,14 @@ class Main {
if (ename != null) {
addMainClass(manifest, ename);
}
if (pname != null) {
if (!addProfileName(manifest, pname)) {
if (in != null) {
in.close();
}
return false;
}
}
}
OutputStream out;
if (fname != null) {
......@@ -230,7 +241,7 @@ class Main {
if (manifest != null) {
manifest.close();
}
if (fname != null) {
if (ok && fname != null) {
// on Win32, we need this delete
inputFile.delete();
if (!tmpFile.renameTo(inputFile)) {
......@@ -361,6 +372,9 @@ class Main {
case 'e':
ename = args[count++];
break;
case 'p':
pname = args[count++];
break;
default:
error(formatMsg("error.illegal.option",
String.valueOf(flags.charAt(i))));
......@@ -410,7 +424,7 @@ class Main {
usageError();
return false;
} else if (uflag) {
if ((mname != null) || (ename != null)) {
if ((mname != null) || (ename != null) || (pname != null)) {
/* just want to update the manifest */
return true;
} else {
......@@ -544,7 +558,7 @@ class Main {
|| (Mflag && isManifestEntry)) {
continue;
} else if (isManifestEntry && ((newManifest != null) ||
(ename != null))) {
(ename != null) || (pname != null))) {
foundManifest = true;
if (newManifest != null) {
// Don't read from the newManifest InputStream, as we
......@@ -563,7 +577,9 @@ class Main {
if (newManifest != null) {
old.read(newManifest);
}
updateManifest(old, zos);
if (!updateManifest(old, zos)) {
return false;
}
} else {
if (!entryMap.containsKey(name)) { // copy the old stuff
// do our own compression
......@@ -596,10 +612,14 @@ class Main {
Manifest m = new Manifest(newManifest);
updateOk = !isAmbiguousMainClass(m);
if (updateOk) {
updateManifest(m, zos);
if (!updateManifest(m, zos)) {
updateOk = false;
}
}
} else if (ename != null || pname != null) {
if (!updateManifest(new Manifest(), zos)) {
updateOk = false;
}
} else if (ename != null) {
updateManifest(new Manifest(), zos);
}
}
zis.close();
......@@ -623,7 +643,7 @@ class Main {
zos.closeEntry();
}
private void updateManifest(Manifest m, ZipOutputStream zos)
private boolean updateManifest(Manifest m, ZipOutputStream zos)
throws IOException
{
addVersion(m);
......@@ -631,6 +651,11 @@ class Main {
if (ename != null) {
addMainClass(m, ename);
}
if (pname != null) {
if (!addProfileName(m, pname)) {
return false;
}
}
ZipEntry e = new ZipEntry(MANIFEST_NAME);
e.setTime(System.currentTimeMillis());
if (flag0) {
......@@ -641,6 +666,7 @@ class Main {
if (vflag) {
output(getMsg("out.update.manifest"));
}
return true;
}
......@@ -687,6 +713,28 @@ class Main {
global.put(Attributes.Name.MAIN_CLASS, mainApp);
}
private boolean addProfileName(Manifest m, String profile) {
// check profile name
boolean found = false;
int i = 0;
while (i < PROFILES.length) {
if (profile.equals(PROFILES[i])) {
found = true;
break;
}
i++;
}
if (!found) {
error(formatMsg("error.bad.pvalue", profile));
return false;
}
// overrides any existing Profile attribute
Attributes global = m.getMainAttributes();
global.put(Attributes.Name.PROFILE, profile);
return true;
}
private boolean isAmbiguousMainClass(Manifest m) {
if (ename != null) {
Attributes global = m.getMainAttributes();
......
......@@ -36,6 +36,8 @@ error.bad.uflag=\
error.bad.eflag=\
'e' flag and manifest with the 'Main-Class' attribute cannot be specified \n\
together!
error.bad.pvalue=\
bad value for 'Profile' attribute: {0}
error.nosuch.fileordir=\
{0} : no such file or directory
error.write.file=\
......@@ -77,6 +79,7 @@ Options:\n\
\ \ -m include manifest information from specified manifest file\n\
\ \ -e specify application entry point for stand-alone application \n\
\ \ bundled into an executable jar file\n\
\ \ -p specify profile name\n\
\ \ -0 store only; use no ZIP compression\n\
\ \ -M do not create a manifest file for the entries\n\
\ \ -i generate index information for the specified jar files\n\
......
/*
* Copyright (c) 2013, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004502
* @summary Sanity check that SecurityManager methods that check AWTPermission
* behave as expected when AWT is not present
*/
public class NoAWT {
public static void main(String[] args) {
SecurityManager sm = new SecurityManager();
try {
sm.checkAwtEventQueueAccess();
throw new RuntimeException("SecurityException expected");
} catch (SecurityException expected) { }
try {
sm.checkSystemClipboardAccess();
throw new RuntimeException("SecurityException expected");
} catch (SecurityException expected) { }
try {
sm.checkTopLevelWindow(null);
throw new RuntimeException("NullPointException expected");
} catch (NullPointerException expected) { }
if (sm.checkTopLevelWindow(new Object())) {
throw new RuntimeException("checkTopLevelWindow expected to return false");
}
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.net.*;
import java.io.File;
import java.util.jar.*;
/**
* Attempts to load classes or resources from a JAR file. The load should succeed
* if the runtime supports the profile indicated by the Profile attribute, fail
* with UnsupportedProfileException otherwise.
*/
public class Basic {
static int indexOf(String profile) {
if (profile == null || "compact1".equals(profile)) return 1;
if ("compact2".equals(profile)) return 2;
if ("compact3".equals(profile)) return 3;
if ("".equals(profile)) return 4;
return Integer.MAX_VALUE; // unknown profile name
}
public static void main(String[] args) throws Exception {
if (args.length < 2)
throw new RuntimeException("Usage: java <jarfile> <classname>");
String jar = args[0];
String cn = args[1];
File lib = new File(jar);
URL url = lib.toURI().toURL();
URL urls[] = { url };
// ## replace this if there is a standard way to determine the profile
String thisProfile = sun.misc.Version.profileName();
String jarProfile = null;
try (JarFile jf = new JarFile(lib)) {
Manifest manifest = jf.getManifest();
if (manifest != null) {
Attributes mainAttrs = manifest.getMainAttributes();
if (mainAttrs != null) {
jarProfile = mainAttrs.getValue(Attributes.Name.PROFILE);
}
}
}
boolean shouldFail = indexOf(thisProfile) < indexOf(jarProfile);
try (URLClassLoader cl = new URLClassLoader(urls)) {
System.out.format("Loading %s from %s ...%n", cn, jar);
Class<?> c = Class.forName(cn, true, cl);
System.out.println(c);
if (shouldFail)
throw new RuntimeException("UnsupportedProfileException expected");
} catch (UnsupportedProfileException x) {
if (!shouldFail)
throw x;
System.out.println("UnsupportedProfileException thrown as expected");
}
try (URLClassLoader cl = new URLClassLoader(urls)) {
System.out.format("Loading resource from %s ...%n", jar);
URL r = cl.findResource("META-INF/MANIFEST.MF");
System.out.println(r);
if (shouldFail)
throw new RuntimeException("UnsupportedProfileException expected");
} catch (UnsupportedProfileException x) {
if (!shouldFail)
throw x;
System.out.println("UnsupportedProfileException thrown as expected");
}
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package lib;
public class Lib {
private Lib() { }
public static void doSomething() { }
}
#
# Copyright (c) 2012, 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.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 8003255
# @compile -XDignore.symbol.file Basic.java Lib.java
# @summary Test that UnsupportedProfileException thrown when attempting to
# load classes or resources from a JAR file with the Profile attribute
# @run shell basic.sh
if [ -z "$TESTJAVA" ]; then
if [ $# -lt 1 ]; then exit 1; fi
TESTJAVA=$1; shift
COMPILEJAVA=$TESTJAVA
TESTSRC=`pwd`
TESTCLASSES=`pwd`
fi
echo "Creating GoodLib.jar ..."
echo "Profile: compact3" > good.mf
$COMPILEJAVA/bin/jar cvfm GoodLib.jar good.mf -C $TESTCLASSES lib
echo "Create BadLib.jar ..."
echo "Profile: badname" > bad.mf
$COMPILEJAVA/bin/jar cvfm BadLib.jar bad.mf -C $TESTCLASSES lib
# remove classes so that they aren't on the classpath
rm -rf $TESTCLASSES/lib
echo "Test with GoodLib.jar ..."
$TESTJAVA/bin/java -cp $TESTCLASSES Basic GoodLib.jar lib.Lib
echo "Test with BadLib.jar ..."
$TESTJAVA/bin/java -cp $TESTCLASSES Basic BadLib.jar lib.Lib
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004502
* @summary Sanity check that NoSuchAlgorithmException is thrown when requesting
* a CertStore of type "LDAP" and LDAP is not available.
*/
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertStore;
import java.security.cert.LDAPCertStoreParameters;
public class NoLDAP {
public static void main(String[] args) throws Exception {
try {
Class.forName("javax.naming.ldap.LdapName");
System.out.println("LDAP is present, test skipped");
return;
} catch (ClassNotFoundException ignore) { }
try {
CertStore.getInstance("LDAP", new LDAPCertStoreParameters());
throw new RuntimeException("NoSuchAlgorithmException expected");
} catch (NoSuchAlgorithmException x) {
System.out.println("NoSuchAlgorithmException thrown as expected");
}
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004931
* @summary Invoke getDeclaredMethods on LogManager to ensure that
* all types referenced in the method signatures is present.
*/
import java.util.logging.LogManager;
import java.lang.reflect.Method;
public class Reflect {
static void printMethods(Class<?> c) {
System.out.println(c);
for (Method m: c.getDeclaredMethods()) {
System.out.println(" " + m);
}
}
public static void main(String[] args) {
printMethods(java.util.logging.LogManager.class);
printMethods(java.util.logging.LogManager.getLogManager().getClass());
}
}
/*
* Copyright (c) 2013, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004502
* @summary Sanity check that attempts to use the IIOP transport or
* RMIIIOPServerImpl when RMI/IIOP not present throws the expected exceptions
*/
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.remote.*;
import javax.management.remote.rmi.*;
import java.net.MalformedURLException;
import java.io.IOException;
import javax.security.auth.Subject;
import java.rmi.NoSuchObjectException;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXConnectorServerFactory;
public class NoIIOP {
/**
* RMIIIOPServerImpl implementation for testing purposes (methods are
* overridden to be public to allow for testing)
*/
static class MyRMIIIOPServerImpl extends RMIIIOPServerImpl {
MyRMIIIOPServerImpl() throws IOException {
super(null);
}
@Override
public void export() throws IOException {
super.export();
}
@Override
public String getProtocol() {
return super.getProtocol();
}
@Override
public RMIConnection makeClient(String connectionId, Subject subject)
throws IOException
{
return super.makeClient(connectionId, subject);
}
@Override
public void closeClient(RMIConnection client) throws IOException {
super.closeClient(client);
}
@Override
public void closeServer() throws IOException {
super.closeServer();
}
}
public static void main(String[] args) throws Exception {
try {
Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
System.out.println("RMI/IIOP appears to be supported, test skipped");
return;
} catch (ClassNotFoundException okay) { }
JMXServiceURL url = new JMXServiceURL("service:jmx:iiop://");
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// test JMXConnectorFactory/JMXConnectorServerFactory
try {
JMXConnectorFactory.connect(url);
throw new RuntimeException("connect did not throw MalformedURLException");
} catch (MalformedURLException expected) { }
try {
JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
throw new RuntimeException("newJMXConnectorServer did not throw MalformedURLException");
} catch (MalformedURLException expected) { }
// test RMIConnector/RMIConnectorServer
RMIConnector connector = new RMIConnector(url, null);
try {
connector.connect();
throw new RuntimeException("connect did not throw IOException");
} catch (IOException expected) { }
RMIConnectorServer server = new RMIConnectorServer(url, null, mbs);
try {
server.start();
throw new RuntimeException("start did not throw IOException");
} catch (IOException expected) { }
// test RMIIIOPServerImpl
MyRMIIIOPServerImpl impl = new MyRMIIIOPServerImpl();
impl.setMBeanServer(mbs);
System.out.println(impl.getProtocol());
try {
impl.export();
throw new RuntimeException("export did not throw IOException");
} catch (IOException expected) { }
try {
impl.newClient(null);
throw new RuntimeException("newClient did not throw IOException");
} catch (IOException expected) { }
try {
impl.toStub();
throw new RuntimeException("toStub did not throw NoSuchObjectException");
} catch (NoSuchObjectException expected) { }
try {
impl.closeServer();
throw new RuntimeException("closeServer did not throw NoSuchObjectException");
} catch (NoSuchObjectException expected) { }
}
}
/*
* Copyright (c) 2013, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004502
* @summary Sanity check that specifying the APPLET property when creating an
* InitialContext behaves as expected when java.awt.Applet is not present
*/
import javax.naming.*;
import java.util.Hashtable;
public class NoApplet {
public static void main(String[] args) throws NamingException {
Hashtable<Object,Object> env = new Hashtable<>();
env.put(Context.APPLET, new Object());
try {
Context ctxt = new InitialContext(env);
throw new RuntimeException("ClassCastException expected");
} catch (ClassCastException expected) { }
}
}
/*
* Copyright (c) 2013, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004502
* @summary Sanity check that NTLM will not be selected by the http protocol
* handler when running on a profile that does not support NTLM
* @run main/othervm NoNTLM
*/
import java.net.*;
import java.io.*;
import sun.net.www.MessageHeader;
public class NoNTLM {
static final String CRLF = "\r\n";
static final String OKAY =
"HTTP/1.1 200" + CRLF +
"Content-Length: 0" + CRLF +
"Connection: close" + CRLF +
CRLF;
static class Client implements Runnable {
private final URL url;
private volatile IOException ioe;
private volatile int respCode;
Client(int port) throws IOException {
this.url = new URL("http://127.0.0.1:" + port + "/foo.html");
}
public void run() {
try {
HttpURLConnection uc =
(HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
try {
uc.getInputStream();
} catch (IOException x) {
respCode = uc.getResponseCode();
throw x;
}
uc.disconnect();
} catch (IOException x) {
if (respCode == 0)
respCode = -1;
ioe = x;
}
}
IOException ioException() {
return ioe;
}
int respCode() {
return respCode;
}
static void start(int port) throws IOException {
Client client = new Client(port);
new Thread(client).start();
}
}
/**
* Return the http response with WWW-Authenticate headers for the given
* authentication schemes.
*/
static String authReplyFor(String... schemes) {
// construct the server reply
String reply = "HTTP/1.1 401 Unauthorized" + CRLF +
"Content-Length: 0"+ CRLF +
"Connection: close" + CRLF;
for (String s: schemes) {
switch (s) {
case "Basic" :
reply += "WWW-Authenticate: Basic realm=\"wallyworld\"" + CRLF;
break;
case "Digest" :
reply += "WWW-Authenticate: Digest" +
" realm=\"wallyworld\"" +
" domain=/" +
" nonce=\"abcdefghijklmnopqrstuvwxyz\"" +
" qop=\"auth\"" + CRLF;
break;
case "NTLM" :
reply += "WWW-Authenticate: NTLM" + CRLF;
break;
default :
throw new RuntimeException("Should not get here");
}
}
reply += CRLF;
return reply;
}
/**
* Test the http protocol handler with the given authentication schemes
* in the WWW-Authenticate header.
*/
static void test(String... schemes) throws IOException {
// the authentication scheme that the client is expected to choose
String expected = null;
for (String s: schemes) {
if (expected == null) {
expected = s;
} else if (s.equals("Digest")) {
expected = s;
}
}
// server reply
String reply = authReplyFor(schemes);
System.out.println("====================================");
System.out.println("Expect client to choose: " + expected);
System.out.println(reply);
try (ServerSocket ss = new ServerSocket(0)) {
Client.start(ss.getLocalPort());
// client ---- GET ---> server
// client <--- 401 ---- server
try (Socket s = ss.accept()) {
new MessageHeader().parseHeader(s.getInputStream());
s.getOutputStream().write(reply.getBytes("US-ASCII"));
}
// client ---- GET ---> server
// client <--- 200 ---- server
String auth;
try (Socket s = ss.accept()) {
MessageHeader mh = new MessageHeader();
mh.parseHeader(s.getInputStream());
s.getOutputStream().write(OKAY.getBytes("US-ASCII"));
auth = mh.findValue("Authorization");
}
// check Authorization header
if (auth == null)
throw new RuntimeException("Authorization header not found");
System.out.println("Server received Authorization header: " + auth);
String[] values = auth.split(" ");
if (!values[0].equals(expected))
throw new RuntimeException("Unexpected value");
}
}
/**
* Test the http protocol handler with one WWW-Authenticate header with
* the value "NTLM".
*/
static void testNTLM() throws Exception {
// server reply
String reply = authReplyFor("NTLM");
System.out.println("====================================");
System.out.println("Expect client to fail with 401 Unauthorized");
System.out.println(reply);
try (ServerSocket ss = new ServerSocket(0)) {
Client client = new Client(ss.getLocalPort());
Thread thr = new Thread(client);
thr.start();
// client ---- GET ---> server
// client <--- 401 ---- client
try (Socket s = ss.accept()) {
new MessageHeader().parseHeader(s.getInputStream());
s.getOutputStream().write(reply.getBytes("US-ASCII"));
}
// the client should fail with 401
System.out.println("Waiting for client to terminate");
thr.join();
IOException ioe = client.ioException();
if (ioe != null)
System.out.println("Client failed: " + ioe);
int respCode = client.respCode();
if (respCode != 0 && respCode != -1)
System.out.println("Client received HTTP response code: " + respCode);
if (respCode != HttpURLConnection.HTTP_UNAUTHORIZED)
throw new RuntimeException("Unexpected response code");
}
}
public static void main(String[] args) throws Exception {
// assume NTLM is not supported when Kerberos is not available
try {
Class.forName("javax.security.auth.kerberos.KerberosPrincipal");
System.out.println("Kerberos is present, assuming NTLM is supported too");
return;
} catch (ClassNotFoundException okay) { }
// setup Authenticator
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("user", "pass".toCharArray());
}
});
// test combinations of authentication schemes
test("Basic");
test("Digest");
test("Basic", "Digest");
test("Basic", "NTLM");
test("Digest", "NTLM");
test("Basic", "Digest", "NTLM");
// test NTLM only, this should fail with "401 Unauthorized"
testNTLM();
System.out.println();
System.out.println("TEST PASSED");
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004502
* @summary Sanity check to ensure that Kerberos cipher suites cannot be
* negotiated when running on a compact profile that does not include Kerberos
*/
import java.net.*;
import java.util.*;
import javax.net.ssl.*;
public class NoKerberos {
static final List<String> KERBEROS_CIPHER_SUITES = Arrays.asList(
"TLS_KRB5_WITH_RC4_128_SHA",
"TLS_KRB5_WITH_RC4_128_MD5",
"TLS_KRB5_WITH_3DES_EDE_CBC_SHA",
"TLS_KRB5_WITH_3DES_EDE_CBC_MD5",
"TLS_KRB5_WITH_DES_CBC_SHA",
"TLS_KRB5_WITH_DES_CBC_MD5",
"TLS_KRB5_EXPORT_WITH_RC4_40_SHA",
"TLS_KRB5_EXPORT_WITH_RC4_40_MD5",
"TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA",
"TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5"
);
/**
* Checks that the given array of supported cipher suites does not include
* any Kerberos cipher suites.
*/
static void checkNotSupported(String[] supportedSuites) {
for (String suites: supportedSuites) {
if (KERBEROS_CIPHER_SUITES.contains(suites)) {
throw new RuntimeException("Supported list of cipher suites " +
" should not include Kerberos cipher suites");
}
}
}
public static void main(String[] args) throws Exception {
try {
Class.forName("javax.security.auth.kerberos.KerberosPrincipal");
System.out.println("Kerberos is present, nothing to test");
return;
} catch (ClassNotFoundException okay) { }
// test SSLSocket
try (Socket s = SSLSocketFactory.getDefault().createSocket()) {
SSLSocket sslSocket = (SSLSocket)s;
checkNotSupported(sslSocket.getSupportedCipherSuites());
// attempt to enable each of the Kerberos cipher suites
for (String kcs: KERBEROS_CIPHER_SUITES) {
String[] suites = { kcs };
try {
sslSocket.setEnabledCipherSuites(suites);
throw new RuntimeException("SSLSocket.setEnabledCipherSuitessuites allowed " +
kcs + " but Kerberos not supported");
} catch (IllegalArgumentException expected) { }
}
}
// test SSLServerSocket
try (ServerSocket ss = SSLServerSocketFactory.getDefault().createServerSocket()) {
SSLServerSocket sslSocket = (SSLServerSocket)ss;
checkNotSupported(sslSocket.getSupportedCipherSuites());
// attempt to enable each of the Kerberos cipher suites
for (String kcs: KERBEROS_CIPHER_SUITES) {
String[] suites = { kcs };
try {
sslSocket.setEnabledCipherSuites(suites);
throw new RuntimeException("SSLSocket.setEnabledCipherSuitessuites allowed " +
kcs + " but Kerberos not supported");
} catch (IllegalArgumentException expected) { }
}
}
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8003255
* @compile -XDignore.symbol.file AddAndUpdateProfile.java
* @run main AddAndUpdateProfile
* @summary Basic test of jar tool "p" option to add or update the Profile
* attribute in the main manifest of a JAR file
*/
import java.util.jar.*;
import static java.util.jar.Attributes.Name.*;
import java.nio.file.*;
import java.io.IOException;
import sun.tools.jar.Main;
public class AddAndUpdateProfile {
static boolean doJar(String... args) {
System.out.print("jar");
for (String arg: args)
System.out.print(" " + arg);
System.out.println("");
Main jartool = new Main(System.out, System.err, "jar");
return jartool.run(args);
}
static void jar(String... args) {
if (!doJar(args))
throw new RuntimeException("jar command failed");
}
static void jarExpectingFail(String... args) {
if (doJar(args))
throw new RuntimeException("jar command not expected to succeed");
}
static void checkMainAttribute(String jarfile, Attributes.Name name,
String expectedValue)
throws IOException
{
try (JarFile jf = new JarFile(jarfile)) {
Manifest mf = jf.getManifest();
if (mf == null && expectedValue != null)
throw new RuntimeException("Manifest not found");
if (mf != null) {
String actual = mf.getMainAttributes().getValue(name);
if (actual != null) {
if (!actual.equals(expectedValue))
throw new RuntimeException("Profile attribute has unexpected value");
} else {
if (expectedValue != null)
throw new RuntimeException("Profile attribute should not be present");
}
}
}
}
public static void main(String[] args) throws Exception {
Path entry = Files.createFile(Paths.get("xfoo"));
String jarfile = "xFoo.jar";
try {
// create JAR file with Profile attribute
jar("cfp", jarfile, "compact1", entry.toString());
checkMainAttribute(jarfile, PROFILE, "compact1");
// attempt to create JAR file with Profile attribute and bad value
jarExpectingFail("cfp", jarfile, "garbage", entry.toString());
jarExpectingFail("cfp", jarfile, "Compact1", entry.toString());
jarExpectingFail("cfp", jarfile, "COMPACT1", entry.toString());
// update value of Profile attribute
jar("ufp", jarfile, "compact2");
checkMainAttribute(jarfile, PROFILE, "compact2");
// attempt to update value of Profile attribute to bad value
// (update should not change the JAR file)
jarExpectingFail("ufp", jarfile, "garbage");
checkMainAttribute(jarfile, PROFILE, "compact2");
jarExpectingFail("ufp", jarfile, "COMPACT1");
checkMainAttribute(jarfile, PROFILE, "compact2");
// create JAR file with both a Main-Class and Profile attribute
jar("cfep", jarfile, "Foo", "compact1", entry.toString());
checkMainAttribute(jarfile, MAIN_CLASS, "Foo");
checkMainAttribute(jarfile, PROFILE, "compact1");
// update value of Profile attribute
jar("ufp", jarfile, "compact2");
checkMainAttribute(jarfile, PROFILE, "compact2");
// create JAR file without Profile attribute
jar("cf", jarfile, entry.toString());
checkMainAttribute(jarfile, PROFILE, null);
// update value of Profile attribute
jar("ufp", jarfile, "compact3");
checkMainAttribute(jarfile, PROFILE, "compact3");
} finally {
Files.deleteIfExists(Paths.get(jarfile));
Files.delete(entry);
}
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8003255
* @compile -XDignore.symbol.file Basic.java Main.java Logging.java
* @run main Basic
* @summary Test the launcher checks the Profile attribute of executable JAR
* files. Also checks that libraries that specify the Profile attribute
* are not loaded if the runtime does not support the required profile.
*/
import java.io.*;
import java.util.jar.*;
import static java.util.jar.JarFile.MANIFEST_NAME;
import java.util.zip.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
public class Basic {
static final String MANIFEST_DIR = "META-INF/";
static final String JAVA_HOME = System.getProperty("java.home");
static final String OS_NAME = System.getProperty("os.name");
static final String OS_ARCH = System.getProperty("os.arch");
static final String JAVA_CMD =
OS_NAME.startsWith("Windows") ? "java.exe" : "java";
static final boolean NEED_D64 =
OS_NAME.equals("SunOS") &&
(OS_ARCH.equals("sparcv9") || OS_ARCH.equals("amd64"));
/**
* Creates a JAR file with the given attributes and the given entries.
* Class files are assumed to be in ${test.classes}. Note that this this
* method cannot use the "jar" tool as it may not be present in the image.
*/
static void createJarFile(String jarfile,
String mainAttributes,
String... entries)
throws IOException
{
// create Manifest
Manifest manifest = new Manifest();
Attributes jarAttrs = manifest.getMainAttributes();
jarAttrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
if (mainAttributes.length() > 0) {
for (String attr: mainAttributes.split(",")) {
String[] s = attr.split("=");
jarAttrs.put(new Attributes.Name(s[0]), s[1]);
}
}
try (OutputStream out = Files.newOutputStream(Paths.get(jarfile));
ZipOutputStream zos = new JarOutputStream(out))
{
// add manifest directory and manifest file
ZipEntry e = new JarEntry(MANIFEST_DIR);
e.setTime(System.currentTimeMillis());
e.setSize(0);
e.setCrc(0);
zos.putNextEntry(e);
e = new ZipEntry(MANIFEST_NAME);
e.setTime(System.currentTimeMillis());
zos.putNextEntry(e);
manifest.write(zos);
zos.closeEntry();
// entries in JAR file
for (String entry: entries) {
e = new JarEntry(entry);
Path path;
if (entry.endsWith(".class")) {
path = Paths.get(System.getProperty("test.classes"), entry);
} else {
path = Paths.get(entry);
}
BasicFileAttributes attrs =
Files.readAttributes(path, BasicFileAttributes.class);
e.setTime(attrs.lastModifiedTime().toMillis());
if (attrs.size() == 0) {
e.setMethod(ZipEntry.STORED);
e.setSize(0);
e.setCrc(0);
}
zos.putNextEntry(e);
if (attrs.isRegularFile())
Files.copy(path, zos);
zos.closeEntry();
}
}
}
/**
* Execute the given executable JAR file with the given arguments. This
* method blocks until the launched VM terminates. Any output or error
* message from the launched VM are printed to System.out. Returns the
* exit value.
*/
static int exec(String jf, String... args) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append(Paths.get(JAVA_HOME, "bin", JAVA_CMD).toString());
if (NEED_D64)
sb.append(" -d64");
sb.append(" -jar ");
sb.append(Paths.get(jf).toAbsolutePath());
for (String arg: args) {
sb.append(' ');
sb.append(arg);
}
String[] cmd = sb.toString().split(" ");
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
try {
return p.waitFor();
} catch (InterruptedException e) {
throw new RuntimeException("Should not happen");
}
}
static void checkRun(String jf, String... args) throws IOException {
if (exec(jf) != 0)
throw new RuntimeException(jf + " failed!!!");
}
static void checkRunFail(String jf, String... args) throws IOException {
if (exec(jf) == 0)
throw new RuntimeException(jf + " did not fail!!!");
System.out.println("Failed as expected");
}
public static void main(String[] args) throws IOException {
// ## replace this if there is a standard way to determine the profile
String profile = sun.misc.Version.profileName();
int thisProfile = 4;
if ("compact1".equals(profile)) thisProfile = 1;
if ("compact2".equals(profile)) thisProfile = 2;
if ("compact3".equals(profile)) thisProfile = 3;
// "library" JAR file used by the test
createJarFile("Logging.jar", "", "Logging.class");
// Executable JAR file without the Profile attribute
if (thisProfile <= 3) {
createJarFile("Main.jar",
"Main-Class=Main,Class-Path=Logging.jar",
"Main.class");
checkRunFail("Main.jar");
}
// Executable JAR file with Profile attribute, Library JAR file without
for (int p=1; p<=3; p++) {
String attrs = "Main-Class=Main,Class-Path=Logging.jar" +
",Profile=compact" + p;
createJarFile("Main.jar", attrs, "Main.class");
if (p <= thisProfile) {
checkRun("Main.jar");
} else {
checkRunFail("Main.jar");
}
}
// Executable JAR file with Profile attribute that has invalid profile
// name, including incorrect case.
createJarFile("Main.jar",
"Main-Class=Main,Class-Path=Logging.jar,Profile=BadName",
"Main.class");
checkRunFail("Main.jar");
createJarFile("Main.jar",
"Main-Class=Main,Class-Path=Logging.jar,Profile=Compact1",
"Main.class");
checkRunFail("Main.jar");
// Executable JAR file and Librrary JAR file with Profile attribute
createJarFile("Main.jar",
"Main-Class=Main,Class-Path=Logging.jar,Profile=compact1",
"Main.class");
for (int p=1; p<=3; p++) {
String attrs = "Profile=compact" + p;
createJarFile("Logging.jar", attrs, "Logging.class");
if (p <= thisProfile) {
checkRun("Main.jar");
} else {
checkRunFail("Main.jar");
}
}
// Executable JAR file and Library JAR with Profile attribute, value
// of Profile not recognized
createJarFile("Logging.jar", "Profile=BadName", "Logging.class");
createJarFile("Main.jar",
"Main-Class=Main,Class-Path=Logging.jar,Profile=compact1",
"Main.class");
checkRunFail("Main.jar");
System.out.println("TEST PASSED.");
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class Logging {
private Logging() { }
public static void log(String msg) {
System.out.println(msg);
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class Main {
private Main() { }
public static void main(String[] args) {
Logging.log("main running");
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8003256
* @compile -XDignore.symbol.file VersionCheck.java
* @run main VersionCheck
* @summary Tests that "java -version" includes the name of the profile and that
* it matches the name in the release file
*/
import java.nio.file.*;
import java.io.*;
import java.util.Properties;
public class VersionCheck {
static final String JAVA_HOME = System.getProperty("java.home");
static final String OS_NAME = System.getProperty("os.name");
static final String OS_ARCH = System.getProperty("os.arch");
static final String JAVA_CMD =
OS_NAME.startsWith("Windows") ? "java.exe" : "java";
static final boolean NEED_D64 =
OS_NAME.equals("SunOS") &&
(OS_ARCH.equals("sparcv9") || OS_ARCH.equals("amd64"));
/**
* Returns {@code true} if the given class is present.
*/
static boolean isPresent(String cn) {
try {
Class.forName(cn);
return true;
} catch (ClassNotFoundException ignore) {
return false;
}
}
/**
* Determines the profile by checking whether specific classes are present.
* Returns the empty string if this runtime does not appear to be a profile
* of Java SE.
*/
static String probeProfile() {
if (isPresent("java.awt.Window"))
return "";
if (isPresent("java.lang.management.ManagementFactory"))
return "compact3";
if (isPresent("java.sql.DriverManager"))
return "compact2";
return "compact1";
}
/**
* Execs java with the given parameters. The method blocks until the
* process terminates. Returns a {@code ByteArrayOutputStream} with any
* stdout or stderr from the process.
*/
static ByteArrayOutputStream execJava(String... args)
throws IOException
{
StringBuilder sb = new StringBuilder();
sb.append(Paths.get(JAVA_HOME, "bin", JAVA_CMD).toString());
if (NEED_D64)
sb.append(" -d64");
for (String arg: args) {
sb.append(' ');
sb.append(arg);
}
String[] cmd = sb.toString().split(" ");
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.redirectErrorStream(true);
Process p = pb.start();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n;
do {
n = p.getInputStream().read(buf);
if (n > 0)
baos.write(buf, 0, n);
} while (n > 0);
try {
int exitCode = p.waitFor();
if (exitCode != 0)
throw new RuntimeException("Exit code: " + exitCode);
} catch (InterruptedException e) {
throw new RuntimeException("Should not happen");
}
return baos;
}
public static void main(String[] args) throws IOException {
String reported = sun.misc.Version.profileName();
String probed = probeProfile();
if (!reported.equals(probed)) {
throw new RuntimeException("sun.misc.Version reports: " + reported
+ ", but probing reports: " + probed);
}
String profile = probed;
boolean isFullJre = (profile.length() == 0);
// check that java -version includes "profile compactN"
String expected = "profile " + profile;
System.out.println("Checking java -version ...");
ByteArrayOutputStream baos = execJava("-version");
ByteArrayInputStream bain = new ByteArrayInputStream(baos.toByteArray());
BufferedReader reader = new BufferedReader(new InputStreamReader(bain));
boolean found = false;
String line;
while ((line = reader.readLine()) != null) {
if (line.contains(expected)) {
found = true;
break;
}
}
if (found && isFullJre)
throw new RuntimeException(expected + " found in java -version output");
if (!found && !isFullJre)
throw new RuntimeException("java -version did not include " + expected);
// check that the profile name matches the release file
System.out.println("Checking release file ...");
Properties props = new Properties();
Path home = Paths.get(JAVA_HOME);
if (home.getFileName().toString().equals("jre"))
home = home.getParent();
Path release = home.resolve("release");
try (InputStream in = Files.newInputStream(release)) {
props.load(in);
}
String value = props.getProperty("JAVA_PROFILE");
if (isFullJre) {
if (value != null)
throw new RuntimeException("JAVA_PROFILE should not be present");
} else {
if (value == null)
throw new RuntimeException("JAVA_PROFILE not present in release file");
if (!value.equals("\"" + profile + "\""))
throw new RuntimeException("Unexpected value of JAVA_PROFILE: " + value);
}
System.out.println("Test passed.");
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8004931
* @compile NoBeans.java
* @summary A compile-only test to ensure that implementations of Packer
* and Unpacker can be compiled without implementating the
* addPropertyChangeListener and removePropertyChangeListener methods.
*/
import java.io.*;
import java.util.*;
import java.util.jar.*;
public class NoBeans {
static class MyPacker implements Pack200.Packer {
public SortedMap<String,String> properties() { return null; }
public void pack(JarFile in, OutputStream out) { }
public void pack(JarInputStream in, OutputStream out) { }
}
static class MyUnpacker implements Pack200.Unpacker {
public SortedMap<String,String> properties() { return null; }
public void unpack(InputStream in, JarOutputStream out) { }
public void unpack(File in, JarOutputStream out) { }
}
}
/*
* Copyright (c) 2012, 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @summary Invoke getDeclaredMethods on Packer and Unpacker to ensure
* that all types referenced in the method signatures is present.
*/
import java.util.jar.Pack200;
import java.util.jar.Pack200.Packer;
import java.util.jar.Pack200.Unpacker;
import java.lang.reflect.Method;
public class Reflect {
static void printMethods(Class<?> c) {
System.out.println(c);
for (Method m: c.getDeclaredMethods()) {
System.out.println(" " + m);
}
}
public static void main(String[] args) {
printMethods(Pack200.Packer.class);
printMethods(Pack200.Unpacker.class);
printMethods(Pack200.newPacker().getClass());
printMethods(Pack200.newUnpacker().getClass());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册