1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-22 20:41:26 +00:00

Revert lang/openjdk6 to b28.

With hat:	portmgr-lurker
This commit is contained in:
Mathieu Arnold 2014-01-04 14:33:12 +00:00
parent efcabcf699
commit f9902a1f64
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=338646
107 changed files with 41295 additions and 264 deletions

View File

@ -1,6 +1,6 @@
# $FreeBSD$
PORTREVISION= 0
PORTREVISION= 7
CATEGORIES= java devel
PKGNAMESUFFIX= -jre

View File

@ -2,12 +2,13 @@
# $FreeBSD$
PORTNAME= openjdk6
PORTVERSION= b29
PORTREVISION?= 0
PORTVERSION= b28
PORTREVISION?= 7
PORTEPOCH= 1
CATEGORIES= java devel
MASTER_SITES= ${MASTER_SITE_APACHE:S,%SUBDIR%/,ant/binaries/:ant,} \
http://download.java.net/openjdk/jtreg/promoted/4.1/b05/:jtreg \
https://java.net/downloads/openjdk6/ \
https://java.net/projects/openjdk6/downloads/download/ \
LOCAL
MASTER_SITE_SUBDIR= jkim
DISTNAME= openjdk-6-src-${PORTVERSION}-${OPENJDK_BUILDDATE}
@ -18,8 +19,6 @@ EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} ${ANTFILE}
MAINTAINER= java@FreeBSD.org
COMMENT?= Oracle's Java 6 virtual machine release under the GPL v2
FORBIDDEN= Triggering a nasty FreeBSD bug
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/LICENSE
LICENSE_DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
@ -31,7 +30,7 @@ LIB_DEPENDS= libfreetype.so:${PORTSDIR}/print/freetype2
RUN_DEPENDS= javavm:${PORTSDIR}/java/javavmwrapper \
${LOCALBASE}/lib/X11/fonts/dejavu:${PORTSDIR}/x11-fonts/dejavu
OPENJDK_BUILDDATE= 05_dec_2013
OPENJDK_BUILDDATE= 04_oct_2013
OPTIONS_DEFINE= ICEDTEA IPV6 POLICY SOUND TZUPDATE
OPTIONS_DEFAULT=ICEDTEA IPV6 TZUPDATE
@ -229,12 +228,6 @@ post-patch:
@${REINPLACE_CMD} -e "s|%%CXX_LIBS%%|${CXX_LIBS}|" \
${WRKSRC}/corba/make/common/Defs-bsd.gmk \
${WRKSRC}/jdk/make/common/Defs-bsd.gmk
.if ${COMPILER_TYPE} == "clang"
@${REINPLACE_CMD} -e "s|-fno-omit-frame-pointer|-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer|" \
${WRKSRC}/corba/make/common/Defs-bsd.gmk \
${WRKSRC}/hotspot/make/bsd/makefiles/amd64.make \
${WRKSRC}/jdk/make/common/Defs-bsd.gmk
.endif
@${REINPLACE_CMD} -e "s|%%ICONV_INC%%|${ICONV_INCLUDE}|" \
-e "s|%%ICONV_LIB%%|${ICONV_LIBS}|" \
${WRKSRC}/Makefile ${WRKSRC}/jdk/make/java/instrument/Makefile \

View File

@ -1,6 +1,108 @@
# $FreeBSD$
_PATCHES=
_PATCHES= \
openjdk/8017196-ensure_proxies_are_handled_appropriately.patch \
openjdk/8011157-improve_corba_portability.patch \
openjdk/8022940-enhance_corba_translations.patch \
openjdk/8013503-improve_stream_factories.patch \
openjdk/8012425-transform_transformfactory.patch \
openjdk/8017298-better_xml_support.patch \
openjdk/8014530-better_dsp.patch \
openjdk/8021366-jaxp_test_fix-01.patch \
openjdk/8021933-jaxp_test_fix-02.patch \
openjdk/8022682-supporting_xom.patch \
openjdk/8015978-incorrect_transformation.patch \
openjdk/oj6-20-merge.patch \
openjdk/8024914-swapped_usage.patch \
openjdk/8017505-better_client_service.patch \
openjdk/8015614-update_build.patch \
openjdk/8016256-finalization_final.patch \
openjdk/8023683-enhance_class_file_parsing.patch \
openjdk/8023457-tracing_mutex.patch \
openjdk/8020943-memory_leak.patch \
openjdk/8023478-hs_crash.patch \
openjdk/4075303-javap_update.patch \
openjdk/6819246-javap_instruction_decoding.patch \
openjdk/6715767-javap_crash.patch \
openjdk/6841420-classfile_methods.patch \
openjdk/6841419-classfile_iterator.patch \
openjdk/4111861-static_fields.patch \
openjdk/4884240-javap_additional_option.patch \
openjdk/6852856-javap_subclasses.patch \
openjdk/6867671-javap_whitespace.patch \
openjdk/6868539-constant_pool_tags.patch \
openjdk/4501661-disallow_mixing.patch \
openjdk/6824493-experimental.patch \
openjdk/6843013-missing_experimental.patch \
openjdk/6902264-fix_indentation.patch \
openjdk/8016675-robust_javadoc.patch \
openjdk/8016653-ignoreable_characters.patch \
openjdk/7196533-timezone_bottleneck.patch \
openjdk/8006900-new_date_time.patch \
openjdk/8008589-better_mbean_permission_validation.patch \
openjdk/8011071-better_crypto_provider_handling.patch \
openjdk/8011081-improve_jhat.patch \
openjdk/8011157-improve_corba_portability-jdk.patch \
openjdk/8012071-better_bean_building.patch \
openjdk/8012147-improve_tool.patch \
openjdk/8012277-improve_dataflavour.patch \
openjdk/8013506-better_pack200.patch \
openjdk/8013510-augment_image_writing.patch \
openjdk/8013514-improve_cmap_stability.patch \
openjdk/8013744-better_tabling.patch \
openjdk/8014085-better_serialization.patch \
openjdk/8014093-improve_image_parsing.patch \
openjdk/8014102-improve_image_conversion.patch \
openjdk/8014341-better_kerberos_service.patch \
openjdk/8014534-better_profiling.patch \
openjdk/8014987-augment_serialization.patch \
openjdk/8015731-auth_improvements.patch \
openjdk/8015743-address_internet_addresses.patch \
openjdk/8016357-update_hs_diagnostic_class.patch \
openjdk/8002070-remove_logger_stack_search.patch \
openjdk/6708729-javap_makefile_update.patch \
openjdk/8010118-caller_sensitive.patch \
openjdk/oj6-19-fix_8010118_test_cases.patch \
openjdk/8010727-empty_logger_name.patch \
openjdk/8010939-logmanager_deadlock.patch \
openjdk/8011990-logger_test_urls.patch \
openjdk/8013380-logger_stack_walk_glassfish.patch \
openjdk/8014745-logger_stack_walk_switch.patch \
openjdk/8012243-serial_regression.patch \
openjdk/8014718-remove_logging_suntoolkit.patch \
openjdk/8011139-revise_checking_getenclosingclass.patch \
openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch \
openjdk/8017287-better_resource_disposal.patch \
openjdk/8017291-cast_proxies_aside.patch \
openjdk/7146431-java.security_files.patch \
openjdk/8006882-jmockit.patch \
openjdk/8000450-restrict_access.patch \
openjdk/8019979-better_access_test.patch \
openjdk/8004188-rename_java.security.patch \
openjdk/8017566-backout_part_of_8000450.patch \
openjdk/8017300-improve_interface_implementation.patch \
openjdk/8019292-better_attribute_value_exceptions.patch \
openjdk/8019617-better_view_of_objects.patch \
openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch \
openjdk/8020293-jvm_crash.patch \
openjdk/8013739-better_ldap_resource_management.patch \
openjdk/8014349-getdeclaredclass_fix.patch \
openjdk/6954275-big_xml_signatures.patch \
openjdk/8021290-signature_validation.patch \
openjdk/8012453-runtime.exec.patch \
openjdk/8015965-typo_in_property_name.patch \
openjdk/8015144-performance_regression.patch \
openjdk/8019969-inet6_test_case_fix.patch \
openjdk/8019584-invalid_notification_fix.patch \
openjdk/8021577-bean_serialization_fix.patch \
openjdk/8021969-jnlp_load_failure.patch \
openjdk/8021355-splashscreen_regression.patch \
openjdk/8022661-writeobject_flush.patch \
openjdk/8023964-ignore_test.patch \
openjdk/8003992-embedded_nulls.patch \
openjdk/8013827-createtempfile_hang.patch \
openjdk/8025128-createtempfile_absolute_prefix.patch \
openjdk/oj6-21-overrides.patch
.if ${PORT_OPTIONS:MICEDTEA}
_PATCHES+= \

View File

@ -1,6 +1,6 @@
SHA256 (apache-ant-1.9.2-bin.tar.bz2) = bfe3a90de898d583510d670ae9ea2adb2874aa1567e21a83de2f363474fc9a24
SIZE (apache-ant-1.9.2-bin.tar.bz2) = 4310740
SHA256 (openjdk-6-src-b29-05_dec_2013.tar.gz) = a9b1b0a48fb52aef82bbe5db33b1dae1672fc8a5f456451f2e300158fc7a7d6b
SIZE (openjdk-6-src-b29-05_dec_2013.tar.gz) = 53754194
SHA256 (openjdk-6-src-b28-04_oct_2013.tar.gz) = ac4fceed060ad61dab938c41181455fb0910f58f6944f820f0637b0f0c64bf75
SIZE (openjdk-6-src-b28-04_oct_2013.tar.gz) = 53599044
SHA256 (jtreg-4.1-bin-b05_29_nov_2012.zip) = 9291eb4a14501232b35614e88686ff66ad8b69d0098dbd4322b28f97b672653d
SIZE (jtreg-4.1-bin-b05_29_nov_2012.zip) = 5993382

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,280 @@
# HG changeset patch
# User jjg
# Date 1217887742 25200
# Mon Aug 04 15:09:02 2008 -0700
# Node ID 6134c146043a3e9dd12ee73ca32ce56ac1c95e3a
# Parent 17dfaebe23044c48bcd5ed0730ce2358543ac459
4111861: static final field contents are not displayed
Reviewed-by: ksrini
diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/ClassWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue May 19 11:43:50 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 15:09:02 2008 -0700
@@ -35,6 +35,7 @@
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.ConstantPool;
import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.ConstantValue_attribute;
import com.sun.tools.classfile.Descriptor;
import com.sun.tools.classfile.DescriptorException;
import com.sun.tools.classfile.Exceptions_attribute;
@@ -189,6 +190,14 @@
}
print(" ");
print(getFieldName(f));
+ if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
+ Attribute a = f.attributes.get(Attribute.ConstantValue);
+ if (a instanceof ConstantValue_attribute) {
+ print(" = ");
+ ConstantValue_attribute cv = (ConstantValue_attribute) a;
+ print(getConstantValue(f.descriptor, cv.constantvalue_index));
+ }
+ }
print(";");
println();
@@ -485,6 +494,81 @@
}
}
+ /**
+ * Get the value of an entry in the constant pool as a Java constant.
+ * Characters and booleans are represented by CONSTANT_Intgere entries.
+ * Character and string values are processed to escape characters outside
+ * the basic printable ASCII set.
+ * @param d the descriptor, giving the expected type of the constant
+ * @param index the index of the value in the constant pool
+ * @return a printable string containing the value of the constant.
+ */
+ String getConstantValue(Descriptor d, int index) {
+ try {
+ ConstantPool.CPInfo cpInfo = constant_pool.get(index);
+
+ switch (cpInfo.getTag()) {
+ case ConstantPool.CONSTANT_Integer: {
+ ConstantPool.CONSTANT_Integer_info info =
+ (ConstantPool.CONSTANT_Integer_info) cpInfo;
+ String t = d.getValue(constant_pool);
+ if (t.equals("C")) { // character
+ return getConstantCharValue((char) info.value);
+ } else if (t.equals("Z")) { // boolean
+ return String.valueOf(info.value == 1);
+ } else { // other: assume integer
+ return String.valueOf(info.value);
+ }
+ }
+
+ case ConstantPool.CONSTANT_String: {
+ ConstantPool.CONSTANT_String_info info =
+ (ConstantPool.CONSTANT_String_info) cpInfo;
+ return getConstantStringValue(info.getString());
+ }
+
+ default:
+ return constantWriter.stringValue(cpInfo);
+ }
+ } catch (ConstantPoolException e) {
+ return "#" + index;
+ }
+ }
+
+ private String getConstantCharValue(char c) {
+ StringBuilder sb = new StringBuilder();
+ sb.append('\'');
+ sb.append(esc(c, '\''));
+ sb.append('\'');
+ return sb.toString();
+ }
+
+ private String getConstantStringValue(String s) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("\"");
+ for (int i = 0; i < s.length(); i++) {
+ sb.append(esc(s.charAt(i), '"'));
+ }
+ sb.append("\"");
+ return sb.toString();
+ }
+
+ private String esc(char c, char quote) {
+ if (32 <= c && c <= 126 && c != quote)
+ return String.valueOf(c);
+ else switch (c) {
+ case '\b': return "\\b";
+ case '\n': return "\\n";
+ case '\t': return "\\t";
+ case '\f': return "\\f";
+ case '\r': return "\\r";
+ case '\\': return "\\\\";
+ case '\'': return "\\'";
+ case '\"': return "\\\"";
+ default: return String.format("\\u%04x", (int) c);
+ }
+ }
+
private Options options;
private AttributeWriter attrWriter;
private CodeWriter codeWriter;
diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/JavapTask.java
--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue May 19 11:43:50 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 15:09:02 2008 -0700
@@ -222,6 +222,12 @@
void process(JavapTask task, String opt, String arg) {
task.options.ignoreSymbolFile = true;
}
+ },
+
+ new Option(false, "-constants") {
+ void process(JavapTask task, String opt, String arg) {
+ task.options.showConstants = true;
+ }
}
};
diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/Options.java
--- langtools/src/share/classes/com/sun/tools/javap/Options.java Tue May 19 11:43:50 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 15:09:02 2008 -0700
@@ -77,6 +77,7 @@
public boolean showDisassembled;
public boolean showInternalSignatures;
public boolean showAllAttrs;
+ public boolean showConstants;
public boolean compat; // bug-for-bug compatibility mode with old javap
public boolean jsr277;
diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/resources/javap.properties
--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue May 19 11:43:50 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 15:09:02 2008 -0700
@@ -58,5 +58,9 @@
main.opt.bootclasspath=\
\ -bootclasspath <path> Override location of bootstrap class files
+main.opt.constants=\
+\ -constants Show static final constants
+
+
diff -r 17dfaebe2304 -r 6134c146043a test/tools/javap/4111861/A.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/test/tools/javap/4111861/A.java Mon Aug 04 15:09:02 2008 -0700
@@ -0,0 +1,14 @@
+class A {
+ public static final int i = 42;
+ public static final boolean b = true;
+ public static final float f = 1.0f;
+ public static final double d = 1.0d;
+ public static final short s = 1;
+ public static final long l = 1l;
+ public static final char cA = 'A';
+ public static final char c0 = '\u0000';
+ public static final char cn = '\n';
+ public static final char cq1 = '\'';
+ public static final char cq2 = '"';
+ public static final java.lang.String t1 = "abc \u0000 \f\n\r\t'\"";
+}
diff -r 17dfaebe2304 -r 6134c146043a test/tools/javap/4111861/T4111861.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/test/tools/javap/4111861/T4111861.java Mon Aug 04 15:09:02 2008 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.io.*;
+
+/*
+ * @test
+ * @bug 4111861
+ * @summary static final field contents are not displayed
+ */
+public class T4111861 {
+ public static void main(String... args) throws Exception {
+ new T4111861().run();
+ }
+
+ void run() throws Exception {
+ File testSrc = new File(System.getProperty("test.src", "."));
+ File a_java = new File(testSrc, "A.java");
+ javac("-d", ".", a_java.getPath());
+
+ String out = javap("-classpath", ".", "-constants", "A");
+
+ String a = read(a_java);
+
+ if (!filter(out).equals(filter(read(a_java)))) {
+ System.out.println(out);
+ throw new Exception("unexpected output");
+ }
+ }
+
+ String javac(String... args) throws Exception {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javac.Main.compile(args, pw);
+ if (rc != 0)
+ throw new Exception("javac failed, rc=" + rc);
+ return sw.toString();
+ }
+
+ String javap(String... args) throws Exception {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javap.Main.run(args, pw);
+ if (rc != 0)
+ throw new Exception("javap failed, rc=" + rc);
+ return sw.toString();
+ }
+
+ String read(File f) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader in = new BufferedReader(new FileReader(f));
+ try {
+ String line;
+ while ((line = in.readLine()) != null) {
+ sb.append(line);
+ sb.append('\n');
+ }
+ } finally {
+ in.close();
+ }
+ return sb.toString();
+ }
+
+ // return those lines beginning "public static final"
+ String filter(String s) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader in = new BufferedReader(new StringReader(s));
+ try {
+ String line;
+ while ((line = in.readLine()) != null) {
+ if (line.indexOf("public static final") > 0) {
+ sb.append(line);
+ sb.append('\n');
+ }
+ }
+ } finally {
+ in.close();
+ }
+ return sb.toString();
+ }
+}

View File

@ -0,0 +1,222 @@
# HG changeset patch
# User jjg
# Date 1215565579 25200
# Tue Jul 08 18:06:19 2008 -0700
# Node ID 8f5d8429b3f18ee4c9820ac1fb597f63c55911f3
# Parent 4f38abed863c89ee101a3af495e7293df04a4a0e
4501661: disallow mixing -public, -private, and -protected options at the same time
Reviewed-by: ksrini
diff -r 4f38abed863c -r 8f5d8429b3f1 src/share/classes/com/sun/tools/javap/JavapTask.java
--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Sat Aug 08 17:56:37 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jul 08 18:06:19 2008 -0700
@@ -145,24 +145,31 @@
new Option(false, "-public") {
void process(JavapTask task, String opt, String arg) {
+ task.options.accessOptions.add(opt);
task.options.showAccess = AccessFlags.ACC_PUBLIC;
}
},
new Option(false, "-protected") {
void process(JavapTask task, String opt, String arg) {
+ task.options.accessOptions.add(opt);
task.options.showAccess = AccessFlags.ACC_PROTECTED;
}
},
new Option(false, "-package") {
void process(JavapTask task, String opt, String arg) {
+ task.options.accessOptions.add(opt);
task.options.showAccess = 0;
}
},
new Option(false, "-p", "-private") {
void process(JavapTask task, String opt, String arg) {
+ if (!task.options.accessOptions.contains("-p") &&
+ !task.options.accessOptions.contains("-private")) {
+ task.options.accessOptions.add(opt);
+ }
task.options.showAccess = AccessFlags.ACC_PRIVATE;
}
},
@@ -422,6 +429,16 @@
throw new BadArgs("err.unknown.option", arg).showUsage(true);
}
+ if (!options.compat && options.accessOptions.size() > 1) {
+ StringBuilder sb = new StringBuilder();
+ for (String opt: options.accessOptions) {
+ if (sb.length() > 0)
+ sb.append(" ");
+ sb.append(opt);
+ }
+ throw new BadArgs("err.incompatible.options", sb);
+ }
+
if (options.ignoreSymbolFile && fileManager instanceof JavapFileManager)
((JavapFileManager) fileManager).setIgnoreSymbolFile(true);
diff -r 4f38abed863c -r 8f5d8429b3f1 src/share/classes/com/sun/tools/javap/Options.java
--- langtools/src/share/classes/com/sun/tools/javap/Options.java Sat Aug 08 17:56:37 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/Options.java Tue Jul 08 18:06:19 2008 -0700
@@ -25,6 +25,8 @@
package com.sun.tools.javap;
+import java.util.HashSet;
+import java.util.Set;
import com.sun.tools.classfile.AccessFlags;
/*
@@ -74,6 +76,7 @@
public boolean showFlags;
public boolean showLineAndLocalVariableTables;
public int showAccess;
+ public Set<String> accessOptions = new HashSet<String>();
public boolean showDisassembled;
public boolean showInternalSignatures;
public boolean showAllAttrs;
diff -r 4f38abed863c -r 8f5d8429b3f1 src/share/classes/com/sun/tools/javap/resources/javap.properties
--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Sat Aug 08 17:56:37 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Jul 08 18:06:19 2008 -0700
@@ -7,6 +7,7 @@
err.end.of.file=unexpected end of file while reading {0}
err.file.not.found=file not found: {0}
err.h.not.supported=-h is no longer available - use the 'javah' program
+err.incompatible.options=bad combination of options: {0}
err.internal.error=internal error: {0} {1} {2}
err.ioerror=IO error reading {0}: {1}
err.missing.arg=no value given for {0}
diff -r 4f38abed863c -r 8f5d8429b3f1 test/tools/javap/T4501661.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/test/tools/javap/T4501661.java Tue Jul 08 18:06:19 2008 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.io.*;
+import java.util.*;
+
+/*
+ * @test
+ * @bug 4501661
+ * @summary disallow mixing -public, -private, and -protected
+ */
+public class T4501661 {
+ public static void main(String... args) throws Exception {
+ new T4501661().run();
+ }
+
+ void run() throws Exception {
+ File javaFile = writeTestFile();
+ File classFile = compileTestFile(javaFile);
+ boolean[] values = { false, true };
+ for (boolean priv: values) {
+ for (boolean prot: values) {
+ for (boolean publ: values) {
+ test(priv, prot, publ, classFile);
+ }
+ }
+ }
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
+ }
+
+ void test(boolean priv, boolean prot, boolean publ, File classFile) {
+ List<String> args = new ArrayList<String>();
+ if (priv)
+ args.add("-private");
+ if (prot)
+ args.add("-protected");
+ if (publ)
+ args.add("-public");
+ boolean expectOK = (args.size() <= 1);
+ args.add(classFile.getPath());
+ String out = javap(args, expectOK);
+ if (out == null)
+ return;
+ if (!priv && !prot && !publ)
+ checkNone(out, "private");
+ if (prot)
+ checkNone(out, "private", "package");
+ if (publ)
+ checkNone(out, "private", "package", "protected");
+ }
+
+ File writeTestFile() throws IOException {
+ File f = new File("Test.java");
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+ out.println("abstract class Test { ");
+ out.println(" public void public_m() { }");
+ out.println(" protected void protected_m() { }");
+ out.println(" private void private_m() { }");
+ out.println(" void package_m() { }");
+ out.println("}");
+ out.close();
+ return f;
+ }
+
+ File compileTestFile(File f) {
+ int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
+ if (rc != 0)
+ throw new Error("compilation failed. rc=" + rc);
+ String path = f.getPath();
+ return new File(path.substring(0, path.length() - 5) + ".class");
+ }
+
+ String javap(List<String> args, boolean expectOK) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+ System.err.println(args);
+ System.err.println(sw);
+ if (expectOK) {
+ if (rc == 0)
+ return sw.toString();
+ else
+ error("javap failed unexpectedly; rc=" + rc + "\n" + sw);
+ } else {
+ if (rc == 0)
+ error("javap succeeded unexpectedly");
+ }
+ return null;
+ }
+
+ void checkNone(String log, String... words) {
+ for (String word: words) {
+ if (log.indexOf(word) != -1)
+ error("\"" + word + "\" unexpectedly found in output");
+ }
+ }
+
+ void error(String msg) {
+ System.err.println("error: " + msg);
+ errors++;
+ }
+
+ int errors;
+}

View File

@ -0,0 +1,288 @@
# HG changeset patch
# User jjg
# Date 1217897655 25200
# Mon Aug 04 17:54:15 2008 -0700
# Node ID dca34170f5f80bf30228c12a647b3f1a492b3eeb
# Parent 6134c146043a3e9dd12ee73ca32ce56ac1c95e3a
4884240: additional option required for javap
Reviewed-by: ksrini
diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/ClassWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 15:09:02 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 17:54:15 2008 -0700
@@ -25,6 +25,7 @@
package com.sun.tools.javap;
+import java.net.URI;
import java.util.Collection;
import java.util.List;
@@ -46,6 +47,8 @@
import com.sun.tools.classfile.SourceFile_attribute;
import com.sun.tools.classfile.Type;
+import java.text.DateFormat;
+import java.util.Date;
import static com.sun.tools.classfile.AccessFlags.*;
/*
@@ -73,6 +76,23 @@
constantWriter = ConstantWriter.instance(context);
}
+ void setDigest(String name, byte[] digest) {
+ this.digestName = name;
+ this.digest = digest;
+ }
+
+ void setFile(URI uri) {
+ this.uri = uri;
+ }
+
+ void setFileSize(int size) {
+ this.size = size;
+ }
+
+ void setLastModified(long lastModified) {
+ this.lastModified = lastModified;
+ }
+
ClassFile getClassFile() {
return classFile;
}
@@ -85,6 +105,32 @@
classFile = cf;
constant_pool = classFile.constant_pool;
+ if ((options.sysInfo || options.verbose) && !options.compat) {
+ if (uri != null) {
+ if (uri.getScheme().equals("file"))
+ println("Classfile " + uri.getPath());
+ else
+ println("Classfile " + uri);
+ }
+ if (lastModified != -1) {
+ Date lm = new Date(lastModified);
+ DateFormat df = DateFormat.getDateInstance();
+ if (size > 0) {
+ println("Last modified " + df.format(lm) + "; size " + size + " bytes");
+ } else {
+ println("Last modified " + df.format(lm));
+ }
+ } else if (size > 0) {
+ println("Size " + size + " bytes");
+ }
+ if (digestName != null && digest != null) {
+ StringBuilder sb = new StringBuilder();
+ for (byte b: digest)
+ sb.append(String.format("%02x", b));
+ println(digestName + " checksum " + sb);
+ }
+ }
+
Attribute sfa = cf.getAttribute(Attribute.SourceFile);
if (sfa instanceof SourceFile_attribute) {
println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
@@ -574,6 +620,11 @@
private CodeWriter codeWriter;
private ConstantWriter constantWriter;
private ClassFile classFile;
+ private URI uri;
+ private long lastModified;
+ private String digestName;
+ private byte[] digest;
+ private int size;
private ConstantPool constant_pool;
private Method method;
private static final String NEWLINE = System.getProperty("line.separator", "\n");
diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/JavapTask.java
--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 15:09:02 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 17:54:15 2008 -0700
@@ -27,11 +27,15 @@
import java.io.EOFException;
import java.io.FileNotFoundException;
+import java.io.FilterInputStream;
+import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -192,6 +196,12 @@
}
},
+ new Option(false, "-sysinfo") {
+ void process(JavapTask task, String opt, String arg) {
+ task.options.sysInfo = true;
+ }
+ },
+
new Option(false, "-Xold") {
void process(JavapTask task, String opt, String arg) throws BadArgs {
// -Xold is only supported as first arg when invoked from
@@ -457,8 +467,27 @@
Attribute.Factory attributeFactory = new Attribute.Factory();
attributeFactory.setCompat(options.compat);
attributeFactory.setJSR277(options.jsr277);
- ClassFile cf = ClassFile.read(fo.openInputStream(), attributeFactory);
+
+ InputStream in = fo.openInputStream();
+ SizeInputStream sizeIn = null;
+ MessageDigest md = null;
+ if (options.sysInfo || options.verbose) {
+ md = MessageDigest.getInstance("MD5");
+ in = new DigestInputStream(in, md);
+ in = sizeIn = new SizeInputStream(in);
+ }
+
+ ClassFile cf = ClassFile.read(in, attributeFactory);
+
+ if (options.sysInfo || options.verbose) {
+ classWriter.setFile(fo.toUri());
+ classWriter.setLastModified(fo.getLastModified());
+ classWriter.setDigest("MD5", md.digest());
+ classWriter.setFileSize(sizeIn.size());
+ }
+
classWriter.write(cf);
+
} catch (ConstantPoolException e) {
diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
ok = false;
@@ -628,4 +657,31 @@
Map<Locale, ResourceBundle> bundles;
private static final String progname = "javap";
+
+ private static class SizeInputStream extends FilterInputStream {
+ SizeInputStream(InputStream in) {
+ super(in);
+ }
+
+ int size() {
+ return size;
+ }
+
+ @Override
+ public int read(byte[] buf, int offset, int length) throws IOException {
+ int n = super.read(buf, offset, length);
+ if (n > 0)
+ size += n;
+ return n;
+ }
+
+ @Override
+ public int read() throws IOException {
+ int b = super.read();
+ size += 1;
+ return b;
+ }
+
+ private int size;
+ }
}
diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/Options.java
--- langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 15:09:02 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 17:54:15 2008 -0700
@@ -78,6 +78,7 @@
public boolean showInternalSignatures;
public boolean showAllAttrs;
public boolean showConstants;
+ public boolean sysInfo;
public boolean compat; // bug-for-bug compatibility mode with old javap
public boolean jsr277;
diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/resources/javap.properties
--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 15:09:02 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 17:54:15 2008 -0700
@@ -62,5 +62,6 @@
\ -constants Show static final constants
-
-
+main.opt.sysinfo=\
+\ -sysinfo Show system info (path, size, date, MD5 hash)\n\
+\ of class being processed
diff -r 6134c146043a -r dca34170f5f8 test/tools/javap/T4884240.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/test/tools/javap/T4884240.java Mon Aug 04 17:54:15 2008 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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-15301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4884240
+ * @summary additional option required for javap
+ */
+
+import java.io.*;
+
+public class T4884240 {
+ public static void main(String... args) throws Exception {
+ new T4884240().run();
+ }
+
+ public void run() throws Exception {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String[] args = { "-sysinfo", "java.lang.Object" };
+ int rc = com.sun.tools.javap.Main.run(args, pw);
+ if (rc != 0)
+ throw new Exception("unexpected return code: " + rc);
+ pw.close();
+ String[] lines = sw.toString().split("\n");
+ if (lines.length < 3
+ || !lines[0].startsWith("Classfile")
+ || !lines[1].startsWith("Last modified")
+ || !lines[2].startsWith("MD5")) {
+ System.out.println(sw);
+ throw new Exception("unexpected output");
+ }
+ }
+}
diff -r 6134c146043a -r dca34170f5f8 test/tools/javap/T6622260.java
--- langtools/test/tools/javap/T6622260.java Mon Aug 04 15:09:02 2008 -0700
+++ langtools/test/tools/javap/T6622260.java Mon Aug 04 17:54:15 2008 -0700
@@ -189,6 +189,10 @@
void verify(String output) {
System.out.println(output);
+ if (output.startsWith("Classfile")) {
+ // make sure to ignore filename
+ output = output.substring(output.indexOf('\n'));
+ }
if (output.indexOf("-") >= 0)
throw new Error("- found in output");
if (output.indexOf("FFFFFF") >= 0)

View File

@ -0,0 +1,59 @@
# HG changeset patch
# User jjg
# Date 1212524896 25200
# Tue Jun 03 13:28:16 2008 -0700
# Node ID 566f427de7079a0ed32c2f625c952dcc45c348e3
# Parent d206cb658a9907c7842c8920f141b3c4eb5efc1f
6708729: update jdk Makefiles for new javap
Reviewed-by: ohair
diff -r d206cb658a99 -r 566f427de707 make/common/Release.gmk
--- jdk/make/common/Release.gmk Mon Oct 21 18:05:56 2013 +0100
+++ jdk/make/common/Release.gmk Tue Jun 03 13:28:16 2008 -0700
@@ -357,6 +357,7 @@
com/sun/jarsigner \
com/sun/mirror \
com/sun/source \
+ com/sun/tools/classfile \
com/sun/tools/doclets \
com/sun/tools/example/debug/expr \
com/sun/tools/example/debug/tty \
@@ -366,6 +367,7 @@
com/sun/tools/javadoc \
com/sun/tools/apt \
com/sun/tools/javah \
+ com/sun/tools/javap \
com/sun/tools/corba \
com/sun/tools/internal/xjc \
com/sun/tools/internal/ws \
@@ -558,6 +560,8 @@
$(ECHO) "sun/tools/java/" >> $@
$(ECHO) "sun/tools/javac/" >> $@
$(ECHO) "sun/tools/javap/" >> $@
+ $(ECHO) "com/sun/tools/classfile/" >> $@
+ $(ECHO) "com/sun/tools/javap/" >> $@
$(ECHO) "sun/tools/jconsole/" >> $@
$(ECHO) "sun/tools/jps/" >> $@
$(ECHO) "sun/tools/jstat/" >> $@
diff -r d206cb658a99 -r 566f427de707 make/common/internal/Defs-langtools.gmk
--- jdk/make/common/internal/Defs-langtools.gmk Mon Oct 21 18:05:56 2013 +0100
+++ jdk/make/common/internal/Defs-langtools.gmk Tue Jun 03 13:28:16 2008 -0700
@@ -31,13 +31,15 @@
javax/tools
IMPORT_TOOLS_PACKAGES += \
+ com/sun/javadoc \
com/sun/mirror \
com/sun/source \
com/sun/tools/apt \
+ com/sun/tools/classfile \
+ com/sun/tools/doclets \
com/sun/tools/javac \
+ com/sun/tools/javadoc \
com/sun/tools/javah \
- com/sun/tools/javadoc \
- com/sun/tools/doclets \
- com/sun/javadoc \
+ com/sun/tools/javap \
sun/tools/javap

View File

@ -0,0 +1,135 @@
# HG changeset patch
# User jjg
# Date 1213833188 25200
# Wed Jun 18 16:53:08 2008 -0700
# Node ID c9b0fee44d446f902102462387c40ca9d1020b6e
# Parent 3cbaa3d49584846d4fd8459edeb696b02de5499b
6715767: javap on java.lang.ClassLoader crashes
Reviewed-by: ksrini
diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/classfile/ConstantPool.java
--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Thu Oct 24 02:40:06 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Wed Jun 18 16:53:08 2008 -0700
@@ -153,7 +153,7 @@
break;
case CONSTANT_String:
- pool[i] = new CONSTANT_String_info(cr);
+ pool[i] = new CONSTANT_String_info(this, cr);
break;
case CONSTANT_Utf8:
@@ -509,7 +509,8 @@
}
public static class CONSTANT_String_info extends CPInfo {
- CONSTANT_String_info(ClassReader cr) throws IOException {
+ CONSTANT_String_info(ConstantPool cp, ClassReader cr) throws IOException {
+ super(cp);
string_index = cr.readUnsignedShort();
}
diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/javap/AttributeWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Thu Oct 24 02:40:06 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jun 18 16:53:08 2008 -0700
@@ -259,7 +259,7 @@
return null;
}
- String getJavaException(Exceptions_attribute attr, int index) {
+ private String getJavaException(Exceptions_attribute attr, int index) {
try {
return getJavaName(attr.getException(index, constant_pool));
} catch (ConstantPoolException e) {
diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/javap/ClassWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu Oct 24 02:40:06 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Jun 18 16:53:08 2008 -0700
@@ -291,7 +291,7 @@
for (int i = 0; i < exceptions.number_of_exceptions; i++) {
if (i > 0)
print(", ");
- print(attrWriter.getJavaException(exceptions, i));
+ print(getJavaException(exceptions, i));
}
}
} else {
@@ -441,6 +441,14 @@
}
}
+ String getJavaException(Exceptions_attribute attr, int index) {
+ try {
+ return getJavaName(attr.getException(index, constant_pool));
+ } catch (ConstantPoolException e) {
+ return report(e);
+ }
+ }
+
String getValue(Descriptor d) {
try {
return d.getValue(constant_pool);
diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/javap/JavapTask.java
--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Thu Oct 24 02:40:06 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Wed Jun 18 16:53:08 2008 -0700
@@ -475,6 +475,7 @@
t.printStackTrace(pw);
pw.close();
diagnosticListener.report(createDiagnostic("err.crash", t.toString(), sw.toString()));
+ ok = false;
}
}
diff -r 3cbaa3d49584 -r c9b0fee44d44 test/tools/javap/T6715767.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/test/tools/javap/T6715767.java Wed Jun 18 16:53:08 2008 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6715767
+ * @summary javap on java.lang.ClassLoader crashes
+ */
+
+import java.io.*;
+
+public class T6715767 {
+ public static void main(String... args) throws Exception {
+ new T6715767().run();
+ }
+
+ void run() throws Exception {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String[] args = { "java.lang.ClassLoader" };
+ int rc = com.sun.tools.javap.Main.run(args, pw);
+ if (rc != 0 ||
+ sw.toString().indexOf("at com.sun.tools.javap.JavapTask.run") != -1) {
+ System.err.println("rc: " + rc);
+ System.err.println("log:\n" + sw);
+ throw new Exception("unexpected result");
+ }
+ }
+}
+

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,142 @@
# HG changeset patch
# User jjg
# Date 1242758630 25200
# Tue May 19 11:43:50 2009 -0700
# Node ID 17dfaebe23044c48bcd5ed0730ce2358543ac459
# Parent 00870be9028f778a169bf9b843a994ec44258c22
6841419: classfile: add constant pool iterator
Reviewed-by: mcimadamore
diff -r 00870be9028f -r 17dfaebe2304 src/share/classes/com/sun/tools/classfile/ClassTranslator.java
--- langtools/src/share/classes/com/sun/tools/classfile/ClassTranslator.java Tue May 19 11:33:13 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/ClassTranslator.java Tue May 19 11:43:50 2009 -0700
@@ -95,7 +95,7 @@
if (cp2 == null) {
ConstantPool.CPInfo[] pool2 = new ConstantPool.CPInfo[cp.size()];
boolean eq = true;
- for (int i = 0; i < cp.size(); i++) {
+ for (int i = 0; i < cp.size(); ) {
ConstantPool.CPInfo cpInfo;
try {
cpInfo = cp.get(i);
@@ -107,11 +107,7 @@
pool2[i] = cpInfo2;
if (cpInfo.getTag() != cpInfo2.getTag())
throw new IllegalStateException();
- switch (cpInfo.getTag()) {
- case ConstantPool.CONSTANT_Double:
- case ConstantPool.CONSTANT_Long:
- i += 1;
- }
+ i += cpInfo.size();
}
if (eq)
diff -r 00870be9028f -r 17dfaebe2304 src/share/classes/com/sun/tools/classfile/ClassWriter.java
--- langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Tue May 19 11:33:13 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Tue May 19 11:43:50 2009 -0700
@@ -118,13 +118,8 @@
ConstantPool pool = classFile.constant_pool;
int size = pool.size();
out.writeShort(size);
- try {
- for (int i = 1; i < size; ) {
- i += constantPoolWriter.write(pool.get(i), out);
- }
- } catch (ConstantPoolException e) {
- throw new Error(e); // ??
- }
+ for (CPInfo cpInfo: pool.entries())
+ constantPoolWriter.write(cpInfo, out);
}
protected void writeFields() throws IOException {
diff -r 00870be9028f -r 17dfaebe2304 src/share/classes/com/sun/tools/classfile/ConstantPool.java
--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue May 19 11:33:13 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue May 19 11:43:50 2009 -0700
@@ -26,6 +26,7 @@
package com.sun.tools.classfile;
import java.io.IOException;
+import java.util.Iterator;
/**
* See JVMS3, section 4.5.
@@ -219,6 +220,40 @@
throw new EntryNotFound(value);
}
+ public Iterable<CPInfo> entries() {
+ return new Iterable<CPInfo>() {
+ public Iterator<CPInfo> iterator() {
+ return new Iterator<CPInfo>() {
+
+ public boolean hasNext() {
+ return next < pool.length;
+ }
+
+ public CPInfo next() {
+ current = pool[next];
+ switch (current.getTag()) {
+ case CONSTANT_Double:
+ case CONSTANT_Long:
+ next += 2;
+ break;
+ default:
+ next += 1;
+ }
+ return current;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private CPInfo current;
+ private int next = 1;
+
+ };
+ }
+ };
+ }
+
private CPInfo[] pool;
public interface Visitor<R,P> {
@@ -246,6 +281,12 @@
public abstract int getTag();
+ /** The number of slots in the constant pool used by this entry.
+ * 2 for CONSTANT_Double and CONSTANT_Long; 1 for everything else. */
+ public int size() {
+ return 1;
+ }
+
public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
protected final ConstantPool cp;
@@ -346,6 +387,11 @@
}
@Override
+ public int size() {
+ return 2;
+ }
+
+ @Override
public String toString() {
return "CONSTANT_Double_info[value: " + value + "]";
}
@@ -459,6 +505,11 @@
}
@Override
+ public int size() {
+ return 2;
+ }
+
+ @Override
public String toString() {
return "CONSTANT_Long_info[value: " + value + "]";
}

View File

@ -0,0 +1,34 @@
# HG changeset patch
# User jjg
# Date 1242757993 25200
# Tue May 19 11:33:13 2009 -0700
# Node ID 00870be9028f778a169bf9b843a994ec44258c22
# Parent c9b0fee44d446f902102462387c40ca9d1020b6e
6841420: classfile: add new methods to ConstantClassInfo
Reviewed-by: mcimadamore
Contributed-by: kevin.t.looney@sun.com
diff -r c9b0fee44d44 -r 00870be9028f src/share/classes/com/sun/tools/classfile/ConstantPool.java
--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Wed Jun 18 16:53:08 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue May 19 11:33:13 2009 -0700
@@ -306,6 +306,20 @@
return cp.getUTF8Value(name_index);
}
+ public String getBaseName() throws ConstantPoolException {
+ String name = getName();
+ int index = name.indexOf("[L") + 1;
+ return name.substring(index);
+ }
+
+ public int getDimensionCount() throws ConstantPoolException {
+ String name = getName();
+ int count = 0;
+ while (name.charAt(count) == '[')
+ count++;
+ return count;
+ }
+
@Override
public String toString() {
return "CONSTANT_Class_info[name_index: " + name_index + "]";

View File

@ -0,0 +1,334 @@
# HG changeset patch
# User jjg
# Date 1242766380 25200
# Tue May 19 13:53:00 2009 -0700
# Node ID a7567fdabf3eae2c495726e6c25e2364e175261f
# Parent 4b55db11179d066331b829ca5c4722c33287deea
6843013: missing files in fix for 6824493
Reviewed-by: darcy
diff -r 4b55db11179d -r a7567fdabf3e src/share/classes/com/sun/tools/javap/LocalVariableTableWriter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/src/share/classes/com/sun/tools/javap/LocalVariableTableWriter.java Tue May 19 13:53:00 2009 -0700
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.tools.javap;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.LocalVariableTable_attribute;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * Annotate instructions with details about local variables.
+ *
+ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
+ * you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class LocalVariableTableWriter extends InstructionDetailWriter {
+ public enum NoteKind {
+ START("start") {
+ public boolean match(LocalVariableTable_attribute.Entry entry, int pc) {
+ return (pc == entry.start_pc);
+ }
+ },
+ END("end") {
+ public boolean match(LocalVariableTable_attribute.Entry entry, int pc) {
+ return (pc == entry.start_pc + entry.length);
+ }
+ };
+ NoteKind(String text) {
+ this.text = text;
+ }
+ public abstract boolean match(LocalVariableTable_attribute.Entry entry, int pc);
+ public final String text;
+ };
+
+ static LocalVariableTableWriter instance(Context context) {
+ LocalVariableTableWriter instance = context.get(LocalVariableTableWriter.class);
+ if (instance == null)
+ instance = new LocalVariableTableWriter(context);
+ return instance;
+ }
+
+ protected LocalVariableTableWriter(Context context) {
+ super(context);
+ context.put(LocalVariableTableWriter.class, this);
+ classWriter = ClassWriter.instance(context);
+ }
+
+ public void reset(Code_attribute attr) {
+ codeAttr = attr;
+ pcMap = new HashMap<Integer, List<LocalVariableTable_attribute.Entry>>();
+ LocalVariableTable_attribute lvt =
+ (LocalVariableTable_attribute) (attr.attributes.get(Attribute.LocalVariableTable));
+ if (lvt == null)
+ return;
+
+ for (int i = 0; i < lvt.local_variable_table.length; i++) {
+ LocalVariableTable_attribute.Entry entry = lvt.local_variable_table[i];
+ put(entry.start_pc, entry);
+ put(entry.start_pc + entry.length, entry);
+ }
+ }
+
+ public void writeDetails(Instruction instr) {
+ int pc = instr.getPC();
+ writeLocalVariables(pc, NoteKind.END);
+ writeLocalVariables(pc, NoteKind.START);
+ }
+
+ @Override
+ public void flush() {
+ int pc = codeAttr.code_length;
+ writeLocalVariables(pc, NoteKind.END);
+ }
+
+ public void writeLocalVariables(int pc, NoteKind kind) {
+ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
+ String indent = space(2); // get from Options?
+ List<LocalVariableTable_attribute.Entry> entries = pcMap.get(pc);
+ if (entries != null) {
+ for (ListIterator<LocalVariableTable_attribute.Entry> iter =
+ entries.listIterator(kind == NoteKind.END ? entries.size() : 0);
+ kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) {
+ LocalVariableTable_attribute.Entry entry =
+ kind == NoteKind.END ? iter.previous() : iter.next();
+ if (kind.match(entry, pc)) {
+ print(indent);
+ print(kind.text);
+ print(" local ");
+ print(entry.index);
+ print(" // ");
+ Descriptor d = new Descriptor(entry.descriptor_index);
+ try {
+ print(d.getFieldType(constant_pool));
+ } catch (InvalidDescriptor e) {
+ print(report(e));
+ } catch (ConstantPoolException e) {
+ print(report(e));
+ }
+ print(" ");
+ try {
+ print(constant_pool.getUTF8Value(entry.name_index));
+ } catch (ConstantPoolException e) {
+ print(report(e));
+ }
+ println();
+ }
+ }
+ }
+ }
+
+ private void put(int pc, LocalVariableTable_attribute.Entry entry) {
+ List<LocalVariableTable_attribute.Entry> list = pcMap.get(pc);
+ if (list == null) {
+ list = new ArrayList<LocalVariableTable_attribute.Entry>();
+ pcMap.put(pc, list);
+ }
+ if (!list.contains(entry))
+ list.add(entry);
+ }
+
+ private ClassWriter classWriter;
+ private Code_attribute codeAttr;
+ private Map<Integer, List<LocalVariableTable_attribute.Entry>> pcMap;
+}
diff -r 4b55db11179d -r a7567fdabf3e src/share/classes/com/sun/tools/javap/LocalVariableTypeTableWriter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/src/share/classes/com/sun/tools/javap/LocalVariableTypeTableWriter.java Tue May 19 13:53:00 2009 -0700
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.tools.javap;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
+import com.sun.tools.classfile.Signature;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * Annotate instructions with details about local variables.
+ *
+ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
+ * you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class LocalVariableTypeTableWriter extends InstructionDetailWriter {
+ public enum NoteKind {
+ START("start") {
+ public boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc) {
+ return (pc == entry.start_pc);
+ }
+ },
+ END("end") {
+ public boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc) {
+ return (pc == entry.start_pc + entry.length);
+ }
+ };
+ NoteKind(String text) {
+ this.text = text;
+ }
+ public abstract boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc);
+ public final String text;
+ };
+
+ static LocalVariableTypeTableWriter instance(Context context) {
+ LocalVariableTypeTableWriter instance = context.get(LocalVariableTypeTableWriter.class);
+ if (instance == null)
+ instance = new LocalVariableTypeTableWriter(context);
+ return instance;
+ }
+
+ protected LocalVariableTypeTableWriter(Context context) {
+ super(context);
+ context.put(LocalVariableTypeTableWriter.class, this);
+ classWriter = ClassWriter.instance(context);
+ }
+
+ public void reset(Code_attribute attr) {
+ codeAttr = attr;
+ pcMap = new HashMap<Integer, List<LocalVariableTypeTable_attribute.Entry>>();
+ LocalVariableTypeTable_attribute lvt =
+ (LocalVariableTypeTable_attribute) (attr.attributes.get(Attribute.LocalVariableTypeTable));
+ if (lvt == null)
+ return;
+
+ for (int i = 0; i < lvt.local_variable_table.length; i++) {
+ LocalVariableTypeTable_attribute.Entry entry = lvt.local_variable_table[i];
+ put(entry.start_pc, entry);
+ put(entry.start_pc + entry.length, entry);
+ }
+ }
+
+ public void writeDetails(Instruction instr) {
+ int pc = instr.getPC();
+ writeLocalVariables(pc, NoteKind.END);
+ writeLocalVariables(pc, NoteKind.START);
+ }
+
+ @Override
+ public void flush() {
+ int pc = codeAttr.code_length;
+ writeLocalVariables(pc, NoteKind.END);
+ }
+
+ public void writeLocalVariables(int pc, NoteKind kind) {
+ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
+ String indent = space(2); // get from Options?
+ List<LocalVariableTypeTable_attribute.Entry> entries = pcMap.get(pc);
+ if (entries != null) {
+ for (ListIterator<LocalVariableTypeTable_attribute.Entry> iter =
+ entries.listIterator(kind == NoteKind.END ? entries.size() : 0);
+ kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) {
+ LocalVariableTypeTable_attribute.Entry entry =
+ kind == NoteKind.END ? iter.previous() : iter.next();
+ if (kind.match(entry, pc)) {
+ print(indent);
+ print(kind.text);
+ print(" generic local ");
+ print(entry.index);
+ print(" // ");
+ Descriptor d = new Signature(entry.signature_index);
+ try {
+ print(d.getFieldType(constant_pool));
+ } catch (InvalidDescriptor e) {
+ print(report(e));
+ } catch (ConstantPoolException e) {
+ print(report(e));
+ }
+ print(" ");
+ try {
+ print(constant_pool.getUTF8Value(entry.name_index));
+ } catch (ConstantPoolException e) {
+ print(report(e));
+ }
+ println();
+ }
+ }
+ }
+ }
+
+ private void put(int pc, LocalVariableTypeTable_attribute.Entry entry) {
+ List<LocalVariableTypeTable_attribute.Entry> list = pcMap.get(pc);
+ if (list == null) {
+ list = new ArrayList<LocalVariableTypeTable_attribute.Entry>();
+ pcMap.put(pc, list);
+ }
+ if (!list.contains(entry))
+ list.add(entry);
+ }
+
+ private ClassWriter classWriter;
+ private Code_attribute codeAttr;
+ private Map<Integer, List<LocalVariableTypeTable_attribute.Entry>> pcMap;
+}

View File

@ -0,0 +1,508 @@
# HG changeset patch
# User jjg
# Date 1382677646 -3600
# Fri Oct 25 06:07:26 2013 +0100
# Node ID a22d1b683f15e7f67d7d3de84f7c866a65c42552
# Parent dca34170f5f80bf30228c12a647b3f1a492b3eeb
6852856: javap changes to facilitate subclassing javap for variants
Reviewed-by: mcimadamore
diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/classfile/AccessFlags.java
--- langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java Mon Aug 04 17:54:15 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java Fri Oct 25 06:07:26 2013 +0100
@@ -58,7 +58,7 @@
public static final int ACC_ENUM = 0x4000; // class, inner, field
public static final int ACC_MODULE = 0x8000; // class, inner, field, method
- private static enum Type { Class, InnerClass, Field, Method};
+ public static enum Kind { Class, InnerClass, Field, Method};
AccessFlags(ClassReader cr) throws IOException {
this(cr.readUnsignedShort());
@@ -87,11 +87,11 @@
public Set<String> getClassModifiers() {
int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
- return getModifiers(f, classModifiers, Type.Class);
+ return getModifiers(f, classModifiers, Kind.Class);
}
public Set<String> getClassFlags() {
- return getFlags(classFlags, Type.Class);
+ return getFlags(classFlags, Kind.Class);
}
private static final int[] innerClassModifiers = {
@@ -106,11 +106,11 @@
public Set<String> getInnerClassModifiers() {
int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
- return getModifiers(f, innerClassModifiers, Type.InnerClass);
+ return getModifiers(f, innerClassModifiers, Kind.InnerClass);
}
public Set<String> getInnerClassFlags() {
- return getFlags(innerClassFlags, Type.InnerClass);
+ return getFlags(innerClassFlags, Kind.InnerClass);
}
private static final int[] fieldModifiers = {
@@ -124,11 +124,11 @@
};
public Set<String> getFieldModifiers() {
- return getModifiers(fieldModifiers, Type.Field);
+ return getModifiers(fieldModifiers, Kind.Field);
}
public Set<String> getFieldFlags() {
- return getFlags(fieldFlags, Type.Field);
+ return getFlags(fieldFlags, Kind.Field);
}
private static final int[] methodModifiers = {
@@ -143,18 +143,18 @@
};
public Set<String> getMethodModifiers() {
- return getModifiers(methodModifiers, Type.Method);
+ return getModifiers(methodModifiers, Kind.Method);
}
public Set<String> getMethodFlags() {
- return getFlags(methodFlags, Type.Method);
+ return getFlags(methodFlags, Kind.Method);
}
- private Set<String> getModifiers(int[] modifierFlags, Type t) {
+ private Set<String> getModifiers(int[] modifierFlags, Kind t) {
return getModifiers(flags, modifierFlags, t);
}
- private static Set<String> getModifiers(int flags, int[] modifierFlags, Type t) {
+ private static Set<String> getModifiers(int flags, int[] modifierFlags, Kind t) {
Set<String> s = new LinkedHashSet<String>();
for (int m: modifierFlags) {
if ((flags & m) != 0)
@@ -163,7 +163,7 @@
return s;
}
- private Set<String> getFlags(int[] expectedFlags, Type t) {
+ private Set<String> getFlags(int[] expectedFlags, Kind t) {
Set<String> s = new LinkedHashSet<String>();
int f = flags;
for (int e: expectedFlags) {
@@ -180,7 +180,7 @@
return s;
}
- private static String flagToModifier(int flag, Type t) {
+ private static String flagToModifier(int flag, Kind t) {
switch (flag) {
case ACC_PUBLIC:
return "public";
@@ -195,7 +195,7 @@
case ACC_SYNCHRONIZED:
return "synchronized";
case 0x80:
- return (t == Type.Field ? "transient" : null);
+ return (t == Kind.Field ? "transient" : null);
case ACC_VOLATILE:
return "volatile";
case ACC_NATIVE:
@@ -211,7 +211,7 @@
}
}
- private static String flagToName(int flag, Type t) {
+ private static String flagToName(int flag, Kind t) {
switch (flag) {
case ACC_PUBLIC:
return "ACC_PUBLIC";
@@ -224,11 +224,11 @@
case ACC_FINAL:
return "ACC_FINAL";
case 0x20:
- return (t == Type.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
+ return (t == Kind.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
case 0x40:
- return (t == Type.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
+ return (t == Kind.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
case 0x80:
- return (t == Type.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
+ return (t == Kind.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
case ACC_NATIVE:
return "ACC_NATIVE";
case ACC_INTERFACE:
@@ -250,5 +250,5 @@
}
}
- final int flags;
+ public final int flags;
}
diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/classfile/ConstantPool.java
--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Mon Aug 04 17:54:15 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Fri Oct 25 06:07:26 2013 +0100
@@ -569,6 +569,11 @@
return visitor.visitNameAndType(this, data);
}
+ @Override
+ public String toString() {
+ return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]";
+ }
+
public final int name_index;
public final int type_index;
}
@@ -596,6 +601,11 @@
return visitor.visitString(this, data);
}
+ @Override
+ public String toString() {
+ return "CONSTANT_String_info[class_index: " + string_index + "]";
+ }
+
public final int string_index;
}
@@ -614,7 +624,19 @@
@Override
public String toString() {
- return "CONSTANT_Utf8_info[value: " + value + "]";
+ if (value.length() < 32 && isPrintableAscii(value))
+ return "CONSTANT_Utf8_info[value: \"" + value + "\"]";
+ else
+ return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]";
+ }
+
+ static boolean isPrintableAscii(String s) {
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c < 32 || c >= 127)
+ return false;
+ }
+ return true;
}
public <R, D> R accept(Visitor<R, D> visitor, D data) {
diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/AttributeWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon Aug 04 17:54:15 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Fri Oct 25 06:07:26 2013 +0100
@@ -74,7 +74,7 @@
public class AttributeWriter extends BasicWriter
implements Attribute.Visitor<Void,Void>
{
- static AttributeWriter instance(Context context) {
+ public static AttributeWriter instance(Context context) {
AttributeWriter instance = context.get(AttributeWriter.class);
if (instance == null)
instance = new AttributeWriter(context);
diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/ClassWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 17:54:15 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Fri Oct 25 06:07:26 2013 +0100
@@ -93,17 +93,25 @@
this.lastModified = lastModified;
}
- ClassFile getClassFile() {
+ protected ClassFile getClassFile() {
return classFile;
}
- Method getMethod() {
+ protected void setClassFile(ClassFile cf) {
+ classFile = cf;
+ constant_pool = classFile.constant_pool;
+ }
+
+ protected Method getMethod() {
return method;
}
+ protected void setMethod(Method m) {
+ method = m;
+ }
+
public void write(ClassFile cf) {
- classFile = cf;
- constant_pool = classFile.constant_pool;
+ setClassFile(cf);
if ((options.sysInfo || options.verbose) && !options.compat) {
if (uri != null) {
@@ -201,13 +209,13 @@
println();
}
- void writeFields() {
+ protected void writeFields() {
for (Field f: classFile.fields) {
writeField(f);
}
}
- void writeField(Field f) {
+ protected void writeField(Field f) {
if (!options.checkAccess(f.access_flags))
return;
@@ -263,12 +271,12 @@
println();
}
- void writeMethods() {
+ protected void writeMethods() {
for (Method m: classFile.methods)
writeMethod(m);
}
- void writeMethod(Method m) {
+ protected void writeMethod(Method m) {
if (!options.checkAccess(m.access_flags))
return;
diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/ConstantWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Mon Aug 04 17:54:15 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Fri Oct 25 06:07:26 2013 +0100
@@ -40,7 +40,7 @@
* deletion without notice.</b>
*/
public class ConstantWriter extends BasicWriter {
- static ConstantWriter instance(Context context) {
+ public static ConstantWriter instance(Context context) {
ConstantWriter instance = context.get(ConstantWriter.class);
if (instance == null)
instance = new ConstantWriter(context);
@@ -54,7 +54,12 @@
options = Options.instance(context);
}
- void writeConstantPool() {
+ protected void writeConstantPool() {
+ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
+ writeConstantPool(constant_pool);
+ }
+
+ protected void writeConstantPool(ConstantPool constant_pool) {
ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() {
public Integer visitClass(CONSTANT_Class_info info, Void p) {
println("#" + info.name_index + ";\t// " + stringValue(info));
@@ -114,7 +119,6 @@
};
println(" Constant pool:");
- ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
int cpx = 1;
while (cpx < constant_pool.size()) {
try {
@@ -127,7 +131,7 @@
}
}
- void write(int cpx) {
+ protected void write(int cpx) {
ClassFile classFile = classWriter.getClassFile();
if (cpx == 0) {
print("#0");
diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/JavapTask.java
--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 17:54:15 2008 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Fri Oct 25 06:07:26 2013 +0100
@@ -36,6 +36,7 @@
import java.io.Writer;
import java.security.DigestInputStream;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -242,20 +243,27 @@
};
- JavapTask() {
+ public JavapTask() {
context = new Context();
options = Options.instance(context);
+ attributeFactory = new Attribute.Factory();
}
- JavapTask(Writer out,
+ public JavapTask(Writer out,
+ JavaFileManager fileManager,
+ DiagnosticListener<? super JavaFileObject> diagnosticListener) {
+ this();
+ this.log = getPrintWriterForWriter(out);
+ this.fileManager = fileManager;
+ this.diagnosticListener = diagnosticListener;
+ }
+
+ public JavapTask(Writer out,
JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Iterable<String> options,
Iterable<String> classes) {
- this();
- this.log = getPrintWriterForWriter(out);
- this.fileManager = fileManager;
- this.diagnosticListener = diagnosticListener;
+ this(out, fileManager, diagnosticListener);
try {
handleOptions(options, false);
@@ -464,29 +472,10 @@
continue;
}
}
- Attribute.Factory attributeFactory = new Attribute.Factory();
attributeFactory.setCompat(options.compat);
attributeFactory.setJSR277(options.jsr277);
- InputStream in = fo.openInputStream();
- SizeInputStream sizeIn = null;
- MessageDigest md = null;
- if (options.sysInfo || options.verbose) {
- md = MessageDigest.getInstance("MD5");
- in = new DigestInputStream(in, md);
- in = sizeIn = new SizeInputStream(in);
- }
-
- ClassFile cf = ClassFile.read(in, attributeFactory);
-
- if (options.sysInfo || options.verbose) {
- classWriter.setFile(fo.toUri());
- classWriter.setLastModified(fo.getLastModified());
- classWriter.setDigest("MD5", md.digest());
- classWriter.setFileSize(sizeIn.size());
- }
-
- classWriter.write(cf);
+ write(read(fo));
} catch (ConstantPoolException e) {
diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
@@ -517,6 +506,103 @@
return ok;
}
+ public static class ClassFileInfo {
+ ClassFileInfo(JavaFileObject fo, ClassFile cf, byte[] digest, int size) {
+ this.fo = fo;
+ this.cf = cf;
+ this.digest = digest;
+ this.size = size;
+ }
+ public final JavaFileObject fo;
+ public final ClassFile cf;
+ public final byte[] digest;
+ public final int size;
+ }
+
+ public ClassFileInfo read(JavaFileObject fo) throws IOException, ConstantPoolException {
+ InputStream in = fo.openInputStream();
+ try {
+ SizeInputStream sizeIn = null;
+ MessageDigest md = null;
+ if (options.sysInfo || options.verbose) {
+ try {
+ md = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException ignore) {
+ }
+ in = new DigestInputStream(in, md);
+ in = sizeIn = new SizeInputStream(in);
+ }
+
+ ClassFile cf = ClassFile.read(in, attributeFactory);
+ byte[] digest = (md == null) ? null : md.digest();
+ int size = (sizeIn == null) ? -1 : sizeIn.size();
+ return new ClassFileInfo(fo, cf, digest, size);
+ } finally {
+ in.close();
+ }
+ }
+
+ public void write(ClassFileInfo info) {
+ ClassWriter classWriter = ClassWriter.instance(context);
+ if (options.sysInfo || options.verbose) {
+ classWriter.setFile(info.fo.toUri());
+ classWriter.setLastModified(info.fo.getLastModified());
+ classWriter.setDigest("MD5", info.digest);
+ classWriter.setFileSize(info.size);
+ }
+
+ classWriter.write(info.cf);
+ }
+
+ protected void setClassFile(ClassFile classFile) {
+ ClassWriter classWriter = ClassWriter.instance(context);
+ classWriter.setClassFile(classFile);
+ }
+
+ protected void setMethod(Method enclosingMethod) {
+ ClassWriter classWriter = ClassWriter.instance(context);
+ classWriter.setMethod(enclosingMethod);
+ }
+
+ protected void write(Attribute value) {
+ AttributeWriter attrWriter = AttributeWriter.instance(context);
+ ClassWriter classWriter = ClassWriter.instance(context);
+ ClassFile cf = classWriter.getClassFile();
+ attrWriter.write(cf, value, cf.constant_pool);
+ }
+
+ protected void write(Attributes attrs) {
+ AttributeWriter attrWriter = AttributeWriter.instance(context);
+ ClassWriter classWriter = ClassWriter.instance(context);
+ ClassFile cf = classWriter.getClassFile();
+ attrWriter.write(cf, attrs, cf.constant_pool);
+ }
+
+ protected void write(ConstantPool constant_pool) {
+ ConstantWriter constantWriter = ConstantWriter.instance(context);
+ constantWriter.writeConstantPool(constant_pool);
+ }
+
+ protected void write(ConstantPool constant_pool, int value) {
+ ConstantWriter constantWriter = ConstantWriter.instance(context);
+ constantWriter.write(value);
+ }
+
+ protected void write(ConstantPool.CPInfo value) {
+ ConstantWriter constantWriter = ConstantWriter.instance(context);
+ constantWriter.println(value);
+ }
+
+ protected void write(Field value) {
+ ClassWriter classWriter = ClassWriter.instance(context);
+ classWriter.writeField(value);
+ }
+
+ protected void write(Method value) {
+ ClassWriter classWriter = ClassWriter.instance(context);
+ classWriter.writeMethod(value);
+ }
+
private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
return JavapFileManager.create(dl, log, options);
}
@@ -646,7 +732,7 @@
}
}
- Context context;
+ protected Context context;
JavaFileManager fileManager;
PrintWriter log;
DiagnosticListener<? super JavaFileObject> diagnosticListener;
@@ -655,6 +741,7 @@
//ResourceBundle bundle;
Locale task_locale;
Map<Locale, ResourceBundle> bundles;
+ protected Attribute.Factory attributeFactory;
private static final String progname = "javap";

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,163 @@
# HG changeset patch
# User jjg
# Date 1249779397 25200
# Sat Aug 08 17:56:37 2009 -0700
# Node ID 4f38abed863c89ee101a3af495e7293df04a4a0e
# Parent db86275eb3f82caf87fbe6c162dc776cb5ed85dc
6868539: javap should use current names for constant pool tags
Reviewed-by: ksrini
diff -r db86275eb3f8 -r 4f38abed863c src/share/classes/com/sun/tools/javap/CodeWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Fri Oct 25 06:17:08 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Sat Aug 08 17:56:37 2009 -0700
@@ -103,7 +103,7 @@
}
public void writeInstr(Instruction instr) {
- print(String.format("%4d: %-12s ", instr.getPC(), instr.getMnemonic()));
+ print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
instr.accept(instructionPrinter, null);
println();
}
diff -r db86275eb3f8 -r 4f38abed863c src/share/classes/com/sun/tools/javap/ConstantWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Fri Oct 25 06:17:08 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Sat Aug 08 17:56:37 2009 -0700
@@ -134,10 +134,10 @@
int width = String.valueOf(constant_pool.size()).length() + 1;
int cpx = 1;
while (cpx < constant_pool.size()) {
- print(String.format("const %" + width + "s", ("#" + cpx)));
+ print(String.format("%" + width + "s", ("#" + cpx)));
try {
CPInfo cpInfo = constant_pool.get(cpx);
- print(String.format(" = %-15s ", tagName(cpInfo.getTag())));
+ print(String.format(" = %-18s ", cpTagName(cpInfo)));
cpx += cpInfo.accept(v, null);
} catch (ConstantPool.InvalidIndex ex) {
// should not happen
@@ -178,10 +178,15 @@
print(tagName(tag) + " " + stringValue(cpInfo));
}
+ String cpTagName(CPInfo cpInfo) {
+ String n = cpInfo.getClass().getSimpleName();
+ return n.replace("CONSTANT_", "").replace("_info", "");
+ }
+
String tagName(int tag) {
switch (tag) {
case CONSTANT_Utf8:
- return "Asciz";
+ return "Utf8";
case CONSTANT_Integer:
return "int";
case CONSTANT_Float:
@@ -203,7 +208,7 @@
case CONSTANT_NameAndType:
return "NameAndType";
default:
- return "unknown tag";
+ return "(unknown tag)";
}
}
diff -r db86275eb3f8 -r 4f38abed863c test/tools/javap/T6868539.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ langtools/test/tools/javap/T6868539.java Sat Aug 08 17:56:37 2009 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6868539 6868548
+ * @summary javap should use current names for constant pool entries,
+ * remove spurious ';' from constant pool entries
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T6868539
+
+{
+ public static void main(String... args) {
+ new T6868539().run();
+ }
+
+ void run() {
+ verify("T6868539", "Utf8 +java/lang/String"); // 1: Utf8
+ // 2: currently unused
+ verify("T6868539", "Integer +123456"); // 3: Integer
+ verify("T6868539", "Float +123456.0f"); // 4: Float
+ verify("T6868539", "Long +123456l"); // 5: Long
+ verify("T6868539", "Double +123456.0d"); // 6: Double
+ verify("T6868539", "Class +#[0-9]+ +// + T6868539"); // 7: Class
+ verify("T6868539", "String +#[0-9]+ +// + not found"); // 8: String
+ verify("T6868539", "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref
+ verify("T6868539", "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref
+ verify("T6868539", "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
+ // 11: InterfaceMethodref
+ verify("T6868539", "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType
+ if (errors > 0)
+ throw new Error(errors + " found.");
+ }
+
+ void verify(String className, String... expects) {
+ String output = javap(className);
+ for (String expect: expects) {
+ if (!output.matches("(?s).*" + expect + ".*"))
+ error(expect + " not found");
+ }
+ }
+
+ void error(String msg) {
+ System.err.println(msg);
+ errors++;
+ }
+
+ int errors;
+
+ String javap(String className) {
+ String testClasses = System.getProperty("test.classes", ".");
+ StringWriter sw = new StringWriter();
+ PrintWriter out = new PrintWriter(sw);
+ String[] args = { "-v", "-classpath", testClasses, className };
+ int rc = com.sun.tools.javap.Main.run(args, out);
+ if (rc != 0)
+ throw new Error("javap failed. rc=" + rc);
+ out.close();
+ String output = sw.toString();
+ System.out.println("class " + className);
+ System.out.println(output);
+ return output;
+ }
+
+ int i = 123456;
+ float f = 123456.f;
+ double d = 123456.;
+ long l = 123456L;
+
+ void m(Runnable r) { r.run(); }
+}
+

View File

@ -0,0 +1,159 @@
# HG changeset patch
# User jjg
# Date 1382713809 -3600
# Fri Oct 25 16:10:09 2013 +0100
# Node ID 9083313d5733ca9be66bc52cf64b9b5d4dd2e39a
# Parent a7567fdabf3eae2c495726e6c25e2364e175261f
6902264: fix indentation of tableswitch and lookupswitch
Reviewed-by: ksrini
diff -r a7567fdabf3e -r 9083313d5733 src/share/classes/com/sun/tools/classfile/Instruction.java
--- langtools/src/share/classes/com/sun/tools/classfile/Instruction.java Tue May 19 13:53:00 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/classfile/Instruction.java Fri Oct 25 16:10:09 2013 +0100
@@ -106,9 +106,9 @@
/** See {@link Kind#LOCAL_UBYTE}. */
R visitLocalAndValue(Instruction instr, int index, int value, P p);
/** See {@link Kind#DYNAMIC}. */
- R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets);
+ R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, P p);
/** See {@link Kind#DYNAMIC}. */
- R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets);
+ R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, P p);
/** See {@link Kind#BYTE}, {@link Kind#SHORT}. */
R visitValue(Instruction instr, int value, P p);
/** Instruction is unrecognized. */
@@ -282,7 +282,7 @@
for (int i = 0; i < values.length; i++)
values[i] = getInt(pad + 12 + 4 * i);
return visitor.visitTableSwitch(
- this, default_, low, high, values);
+ this, default_, low, high, values, p);
}
case LOOKUPSWITCH: {
int pad = align(pc + 1) - pc;
@@ -295,7 +295,7 @@
offsets[i] = getInt(pad + 12 + i * 8);
}
return visitor.visitLookupSwitch(
- this, default_, npairs, matches, offsets);
+ this, default_, npairs, matches, offsets, p);
}
default:
throw new IllegalStateException();
diff -r a7567fdabf3e -r 9083313d5733 src/share/classes/com/sun/tools/javap/CodeWriter.java
--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Tue May 19 13:53:00 2009 -0700
+++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Fri Oct 25 16:10:09 2013 +0100
@@ -117,28 +117,33 @@
public void writeInstr(Instruction instr) {
print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
- instr.accept(instructionPrinter, null);
+ // compute the number of indentations for the body of multi-line instructions
+ // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
+ // and rounded up to the next integer.
+ int indentWidth = options.indentWidth;
+ int indent = (6 + indentWidth - 1) / indentWidth;
+ instr.accept(instructionPrinter, indent);
println();
}
// where
- Instruction.KindVisitor<Void,Void> instructionPrinter =
- new Instruction.KindVisitor<Void,Void>() {
+ Instruction.KindVisitor<Void,Integer> instructionPrinter =
+ new Instruction.KindVisitor<Void,Integer>() {
- public Void visitNoOperands(Instruction instr, Void p) {
+ public Void visitNoOperands(Instruction instr, Integer indent) {
return null;
}
- public Void visitArrayType(Instruction instr, TypeKind kind, Void p) {
+ public Void visitArrayType(Instruction instr, TypeKind kind, Integer indent) {
print(" " + kind.name);
return null;
}
- public Void visitBranch(Instruction instr, int offset, Void p) {
+ public Void visitBranch(Instruction instr, int offset, Integer indent) {
print((instr.getPC() + offset));
return null;
}
- public Void visitConstantPoolRef(Instruction instr, int index, Void p) {
+ public Void visitConstantPoolRef(Instruction instr, int index, Integer indent) {
print("#" + index + ";");
tab();
print("// ");
@@ -146,7 +151,7 @@
return null;
}
- public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Void p) {
+ public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Integer indent) {
print("#" + index + ", " + value + ";");
tab();
print("// ");
@@ -154,46 +159,48 @@
return null;
}
- public Void visitLocal(Instruction instr, int index, Void p) {
+ public Void visitLocal(Instruction instr, int index, Integer indent) {
print(index);
return null;
}
- public Void visitLocalAndValue(Instruction instr, int index, int value, Void p) {
+ public Void visitLocalAndValue(Instruction instr, int index, int value, Integer indent) {
print(index + ", " + value);
return null;
}
- public Void visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets) {
+ public Void visitLookupSwitch(Instruction instr,
+ int default_, int npairs, int[] matches, int[] offsets, Integer indent) {
int pc = instr.getPC();
print("{ // " + npairs);
- indent(+1);
+ indent(indent);
for (int i = 0; i < npairs; i++) {
- print("\n" + matches[i] + ": " + (pc + offsets[i]) + ";");
+ print(String.format("%n%12d: %d", matches[i], (pc + offsets[i])));
}
- print("\ndefault: " + (pc + default_) + " }");
- indent(-1);
+ print("\n default: " + (pc + default_) + "\n}");
+ indent(-indent);
return null;
}
- public Void visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets) {
+ public Void visitTableSwitch(Instruction instr,
+ int default_, int low, int high, int[] offsets, Integer indent) {
int pc = instr.getPC();
- print("{ //" + low + " to " + high);
- indent(+1);
+ print("{ // " + low + " to " + high);
+ indent(indent);
for (int i = 0; i < offsets.length; i++) {
- print("\n" + (low + i) + ": " + (pc + offsets[i]) + ";");
+ print(String.format("%n%12d: %d", (low + i), (pc + offsets[i])));
}
- print("\ndefault: " + (pc + default_) + " }");
- indent(-1);
+ print("\n default: " + (pc + default_) + "\n}");
+ indent(-indent);
return null;
}
- public Void visitValue(Instruction instr, int value, Void p) {
+ public Void visitValue(Instruction instr, int value, Integer indent) {
print(value);
return null;
}
- public Void visitUnknown(Instruction instr, Void p) {
+ public Void visitUnknown(Instruction instr, Integer indent) {
return null;
}
};

View File

@ -0,0 +1,194 @@
# HG changeset patch
# User mullan
# Date 1287154559 14400
# Fri Oct 15 10:55:59 2010 -0400
# Node ID 5e3c766d18092d498d9019827c1058a32f1c4e2a
# Parent e5a4a4ec7b21f3d092d0b29024ff903864d05543
6954275: XML signatures with reference data larger 16KB and cacheRef on fails to validate
Reviewed-by: xuelei
diff -r e5a4a4ec7b21 -r 5e3c766d1809 src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
--- jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Mon Oct 28 21:46:43 2013 +0000
+++ jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Fri Oct 15 10:55:59 2010 -0400
@@ -3,7 +3,7 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2010 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,66 +23,70 @@
import java.io.OutputStream;
/**
- * A simple Unsynced ByteArryOutputStream
+ * A simple Unsynced ByteArrayOutputStream
* @author raul
*
*/
public class UnsyncByteArrayOutputStream extends OutputStream {
- private static ThreadLocal bufCahce = new ThreadLocal() {
+ private static final int INITIAL_SIZE = 8192;
+ private static ThreadLocal bufCache = new ThreadLocal() {
protected synchronized Object initialValue() {
- return new byte[8*1024];
+ return new byte[INITIAL_SIZE];
}
};
- byte[] buf;
- int size=8*1024;//buf.length;
- int pos=0;
- public UnsyncByteArrayOutputStream() {
- buf=(byte[])bufCahce.get();
+
+ private byte[] buf;
+ private int size = INITIAL_SIZE;
+ private int pos = 0;
+
+ public UnsyncByteArrayOutputStream() {
+ buf = (byte[])bufCache.get();
+ }
+
+ public void write(byte[] arg0) {
+ int newPos = pos + arg0.length;
+ if (newPos > size) {
+ expandSize(newPos);
}
- /** @inheritDoc */
- public void write(byte[] arg0) {
- int newPos=pos+arg0.length;
- if (newPos>size) {
- expandSize();
- }
- System.arraycopy(arg0,0,buf,pos,arg0.length);
- pos=newPos;
+ System.arraycopy(arg0, 0, buf, pos, arg0.length);
+ pos = newPos;
+ }
+
+ public void write(byte[] arg0, int arg1, int arg2) {
+ int newPos = pos + arg2;
+ if (newPos > size) {
+ expandSize(newPos);
}
- /** @inheritDoc */
- public void write(byte[] arg0, int arg1, int arg2) {
- int newPos=pos+arg2;
- if (newPos>size) {
- expandSize();
- }
- System.arraycopy(arg0,arg1,buf,pos,arg2);
- pos=newPos;
+ System.arraycopy(arg0, arg1, buf, pos, arg2);
+ pos = newPos;
+ }
+
+ public void write(int arg0) {
+ int newPos = pos + 1;
+ if (newPos > size) {
+ expandSize(newPos);
}
- /** @inheritDoc */
- public void write(int arg0) {
- if (pos>=size) {
- expandSize();
- }
- buf[pos++]=(byte)arg0;
+ buf[pos++] = (byte)arg0;
+ }
+
+ public byte[] toByteArray() {
+ byte result[] = new byte[pos];
+ System.arraycopy(buf, 0, result, 0, pos);
+ return result;
+ }
+
+ public void reset() {
+ pos = 0;
+ }
+
+ private void expandSize(int newPos) {
+ int newSize = size;
+ while (newPos > newSize) {
+ newSize = newSize<<2;
}
- /** @inheritDoc */
- public byte[] toByteArray() {
- byte result[]=new byte[pos];
- System.arraycopy(buf,0,result,0,pos);
- return result;
- }
-
- /** @inheritDoc */
- public void reset() {
- pos=0;
- }
-
- /** @inheritDoc */
- void expandSize() {
- int newSize=size<<2;
- byte newBuf[]=new byte[newSize];
- System.arraycopy(buf,0,newBuf,0,pos);
- buf=newBuf;
- size=newSize;
-
- }
+ byte newBuf[] = new byte[newSize];
+ System.arraycopy(buf, 0, newBuf, 0, pos);
+ buf = newBuf;
+ size = newSize;
+ }
}
diff -r e5a4a4ec7b21 -r 5e3c766d1809 test/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream/BufferOverflowTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream/BufferOverflowTest.java Fri Oct 15 10:55:59 2010 -0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 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 %I% %E%
+ * @bug 6954275
+ * @summary Check that UnsyncByteArrayOutputStream does not
+ * throw ArrayIndexOutOfBoundsException
+ * @compile -XDignore.symbol.file BufferOverflowTest.java
+ * @run main BufferOverflowTest
+ */
+
+import com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream;
+
+public class BufferOverflowTest {
+
+ public static void main(String[] args) throws Exception {
+ try {
+ UnsyncByteArrayOutputStream out = new UnsyncByteArrayOutputStream();
+ out.write(new byte[(8192) << 2 + 1]);
+ System.out.println("PASSED");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ System.err.println("FAILED, got ArrayIndexOutOfBoundsException");
+ throw new Exception(e);
+ }
+ }
+}

View File

@ -0,0 +1,82 @@
# HG changeset patch
# User mullan
# Date 1382735486 -3600
# Fri Oct 25 22:11:26 2013 +0100
# Node ID 5b485ecccea9064e5036e1bb040fc2af1f773c20
# Parent 011d86bdcbf8d4fe0016351b775ff1f48f3620a1
7146431: java.security files out-of-sync
Reviewed-by: vinnie, xuelei, wetmore
diff -r 011d86bdcbf8 -r 5b485ecccea9 src/share/lib/security/java.security-solaris
--- jdk/src/share/lib/security/java.security-solaris Mon Jul 15 03:40:16 2013 -0700
+++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:11:26 2013 +0100
@@ -141,6 +141,7 @@
com.sun.org.apache.xalan.internal.lib.,\
com.sun.org.apache.xalan.internal.res.,\
com.sun.org.apache.xalan.internal.templates.,\
+ com.sun.org.apache.xalan.internal.utils.\
com.sun.org.apache.xalan.internal.xslt.,\
com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
com.sun.org.apache.xalan.internal.xsltc.compiler.,\
diff -r 011d86bdcbf8 -r 5b485ecccea9 src/share/lib/security/java.security-windows
--- jdk/src/share/lib/security/java.security-windows Mon Jul 15 03:40:16 2013 -0700
+++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:11:26 2013 +0100
@@ -141,6 +141,7 @@
com.sun.org.apache.xalan.internal.lib.,\
com.sun.org.apache.xalan.internal.res.,\
com.sun.org.apache.xalan.internal.templates.,\
+ com.sun.org.apache.xalan.internal.utils.\
com.sun.org.apache.xalan.internal.xslt.,\
com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
com.sun.org.apache.xalan.internal.xsltc.compiler.,\
diff -r 011d86bdcbf8 -r 5b485ecccea9 test/java/lang/SecurityManager/CheckPackageAccess.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:11:26 2013 +0100
@@ -0,0 +1,47 @@
+/*
+ * 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 7146431
+ * @summary Test that internal JAXP packages cannot be accessed
+ */
+
+public class CheckPackageAccess {
+
+ public static void main(String[] args) throws Exception {
+
+ String[] pkgs = new String[] {
+ "com.sun.org.apache.xerces.internal.utils.",
+ "com.sun.org.apache.xalan.internal.utils." };
+ SecurityManager sm = new SecurityManager();
+ System.setSecurityManager(sm);
+ for (String pkg : pkgs) {
+ System.out.println("Checking package access for " + pkg);
+ try {
+ sm.checkPackageAccess(pkg);
+ throw new Exception("Expected SecurityException not thrown");
+ } catch (SecurityException se) { }
+ }
+ }
+}

View File

@ -0,0 +1,75 @@
# HG changeset patch
# User coffeys
# Date 1381845864 -3600
# Tue Oct 15 15:04:24 2013 +0100
# Node ID 5d81a5f8a3791316367990b35b1ad5faef42d773
# Parent 77af6e10b333347cd882027ab1bb9a3366278096
7196533: TimeZone.getDefault() slow due to synchronization bottleneck
Reviewed-by: okutsu, omajid
diff -r 77af6e10b333 -r 5d81a5f8a379 src/share/classes/java/util/TimeZone.java
--- jdk/src/share/classes/java/util/TimeZone.java Fri Oct 04 12:22:34 2013 -0400
+++ jdk/src/share/classes/java/util/TimeZone.java Tue Oct 15 15:04:24 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -646,9 +646,15 @@
* Returns the default TimeZone in an AppContext if any AppContext
* has ever used. null is returned if any AppContext hasn't been
* used or if the AppContext doesn't have the default TimeZone.
+ *
+ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ * been loaded. If so, it implies that AWTSecurityManager is not our
+ * SecurityManager and we can use a local static variable.
+ * This works around a build time issue.
*/
- private synchronized static TimeZone getDefaultInAppContext() {
- javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ private static TimeZone getDefaultInAppContext() {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
if (javaAWTAccess == null) {
return mainAppContextDefault;
} else {
@@ -670,9 +676,15 @@
* tz. null is handled special: do nothing if any AppContext
* hasn't been used, remove the default TimeZone in the
* AppContext otherwise.
+ *
+ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ * been loaded. If so, it implies that AWTSecurityManager is not our
+ * SecurityManager and we can use a local static variable.
+ * This works around a build time issue.
*/
- private synchronized static void setDefaultInAppContext(TimeZone tz) {
- javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ private static void setDefaultInAppContext(TimeZone tz) {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
if (javaAWTAccess == null) {
mainAppContextDefault = tz;
} else {
@@ -736,18 +748,8 @@
static final String GMT_ID = "GMT";
private static final int GMT_ID_LENGTH = 3;
- /*
- * Provides access implementation-private methods without using reflection
- *
- * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
- * been loaded. If so, it implies that AWTSecurityManager is not our
- * SecurityManager and we can use a local static variable.
- * This works around a build time issue.
- */
- private static JavaAWTAccess javaAWTAccess;
-
// a static TimeZone we can reference if no AppContext is in place
- private static TimeZone mainAppContextDefault;
+ private static volatile TimeZone mainAppContextDefault;
/**

View File

@ -0,0 +1,108 @@
# HG changeset patch
# User coffeys
# Date 1382735937 -3600
# Fri Oct 25 22:18:57 2013 +0100
# Node ID f7a7c7d70e4968eb99e42f812c59900f545d7fa7
# Parent 695dd7ceb9e34fd4058374de63964c205f061002
8000450: Restrict access to com/sun/corba/se/impl package
Reviewed-by: alanb, chegar, lancea
diff -r 695dd7ceb9e3 -r f7a7c7d70e49 src/share/lib/security/java.security
--- jdk/src/share/lib/security/java.security Fri Oct 25 22:17:00 2013 +0100
+++ jdk/src/share/lib/security/java.security Fri Oct 25 22:18:57 2013 +0100
@@ -128,6 +128,7 @@
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,\
+ com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
@@ -164,6 +165,7 @@
# checkPackageDefinition.
#
package.definition=sun.,\
+ com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
diff -r 695dd7ceb9e3 -r f7a7c7d70e49 src/share/lib/security/java.security-solaris
--- jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:17:00 2013 +0100
+++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:18:57 2013 +0100
@@ -129,6 +129,7 @@
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,\
+ com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
@@ -166,6 +167,7 @@
# checkPackageDefinition.
#
package.definition=sun.,\
+ com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
diff -r 695dd7ceb9e3 -r f7a7c7d70e49 src/share/lib/security/java.security-windows
--- jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:17:00 2013 +0100
+++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:18:57 2013 +0100
@@ -129,6 +129,7 @@
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,\
+ com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
@@ -167,6 +168,7 @@
# checkPackageDefinition.
#
package.definition=sun.,\
+ com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
diff -r 695dd7ceb9e3 -r f7a7c7d70e49 test/java/lang/SecurityManager/CheckPackageAccess.java
--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:17:00 2013 +0100
+++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:18:57 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,8 +23,8 @@
/*
* @test
- * @bug 7146431
- * @summary Test that internal JAXP packages cannot be accessed
+ * @bug 7146431 8000450
+ * @summary Test that internal packages cannot be accessed
*/
public class CheckPackageAccess {
@@ -32,6 +32,7 @@
public static void main(String[] args) throws Exception {
String[] pkgs = new String[] {
+ "com.sun.corba.se.impl.",
"com.sun.org.apache.xerces.internal.utils.",
"com.sun.org.apache.xalan.internal.utils." };
SecurityManager sm = new SecurityManager();
@@ -40,7 +41,11 @@
System.out.println("Checking package access for " + pkg);
try {
sm.checkPackageAccess(pkg);
- throw new Exception("Expected SecurityException not thrown");
+ throw new Exception("Expected PackageAccess SecurityException not thrown");
+ } catch (SecurityException se) { }
+ try {
+ sm.checkPackageDefinition(pkg);
+ throw new Exception("Expected PackageDefinition SecurityException not thrown");
} catch (SecurityException se) { }
}
}

View File

@ -0,0 +1,658 @@
# HG changeset patch
# User jgish
# Date 1381898393 -3600
# Wed Oct 16 05:39:53 2013 +0100
# Node ID e56220b54fe2d0f09ee151b28d6e8495cea2136f
# Parent 1ed7c9cea8c508e60d6df30c046ab48b1f1d3ab9
8002070: Remove the stack search for a resource bundle for Logger to use
Summary: The fragile, vulnerable, stack crawling has been eliminated from findResourceBundle(String)
Reviewed-by: mchung
diff -r 1ed7c9cea8c5 -r e56220b54fe2 src/share/classes/java/util/logging/Logger.java
--- jdk/src/share/classes/java/util/logging/Logger.java Wed Oct 16 05:10:54 2013 +0100
+++ jdk/src/share/classes/java/util/logging/Logger.java Wed Oct 16 05:39:53 2013 +0100
@@ -26,9 +26,17 @@
package java.util.logging;
-import java.util.*;
-import java.security.*;
import java.lang.ref.WeakReference;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.concurrent.CopyOnWriteArrayList;
+import sun.reflect.CallerSensitive;
+import sun.reflect.Reflection;
/**
* A Logger object is used to log messages for a specific
@@ -97,14 +105,8 @@
* <p>
* When mapping ResourceBundle names to ResourceBundles, the Logger
* will first try to use the Thread's ContextClassLoader. If that
- * is null it will try the SystemClassLoader instead. As a temporary
- * transition feature in the initial implementation, if the Logger is
- * unable to locate a ResourceBundle from the ContextClassLoader or
- * SystemClassLoader the Logger will also search up the class stack
- * and use successive calling ClassLoaders to try to locate a ResourceBundle.
- * (This call stack search is to allow containers to transition to
- * using ContextClassLoaders and is likely to be removed in future
- * versions.)
+ * is null it will try the
+ * {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader} instead.
* <p>
* Formatting (including localization) is the responsibility of
* the output Handler, which will typically call a Formatter.
@@ -1297,12 +1299,6 @@
return useParentHandlers;
}
- // Private utility method to map a resource bundle name to an
- // actual resource bundle, using a simple one-entry cache.
- // Returns null for a null name.
- // May also return null if we can't find the resource bundle and
- // there is no suitable previous cached value.
-
static final String SYSTEM_LOGGER_RB_NAME = "sun.util.logging.resources.logging";
private static ResourceBundle findSystemResourceBundle(final Locale locale) {
@@ -1320,6 +1316,16 @@
});
}
+ /**
+ * Private utility method to map a resource bundle name to an
+ * actual resource bundle, using a simple one-entry cache.
+ * Returns null for a null name.
+ * May also return null if we can't find the resource bundle and
+ * there is no suitable previous cached value.
+ *
+ * @param name the ResourceBundle to locate
+ * @return ResourceBundle specified by name or null if not found
+ */
private synchronized ResourceBundle findResourceBundle(String name) {
// Return a null bundle for a null name.
if (name == null) {
@@ -1329,8 +1335,8 @@
Locale currentLocale = Locale.getDefault();
// Normally we should hit on our simple one entry cache.
- if (catalog != null && currentLocale == catalogLocale
- && name == catalogName) {
+ if (catalog != null && currentLocale.equals(catalogLocale)
+ && name.equals(catalogName)) {
return catalog;
}
@@ -1341,8 +1347,8 @@
return catalog;
}
- // Use the thread's context ClassLoader. If there isn't one,
- // use the SystemClassloader.
+ // Use the thread's context ClassLoader. If there isn't one, use the
+ // {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader}.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = ClassLoader.getSystemClassLoader();
@@ -1353,45 +1359,8 @@
catalogLocale = currentLocale;
return catalog;
} catch (MissingResourceException ex) {
- // Woops. We can't find the ResourceBundle in the default
- // ClassLoader. Drop through.
+ return null;
}
-
-
- // Fall back to searching up the call stack and trying each
- // calling ClassLoader.
- for (int ix = 0; ; ix++) {
- Class clz = sun.reflect.Reflection.getCallerClass(ix);
- if (clz == null) {
- break;
- }
- ClassLoader cl2 = clz.getClassLoader();
- if (cl2 == null) {
- cl2 = ClassLoader.getSystemClassLoader();
- }
- if (cl == cl2) {
- // We've already checked this classloader.
- continue;
- }
- cl = cl2;
- try {
- catalog = ResourceBundle.getBundle(name, currentLocale, cl);
- catalogName = name;
- catalogLocale = currentLocale;
- return catalog;
- } catch (MissingResourceException ex) {
- // Ok, this one didn't work either.
- // Drop through, and try the next one.
- }
- }
-
- if (name.equals(catalogName)) {
- // Return the previous cached value for that name.
- // This may be null.
- return catalog;
- }
- // Sorry, we're out of luck.
- return null;
}
// Private utility method to initialize our one entry
@@ -1403,8 +1372,7 @@
if (name == null) {
return;
}
- ResourceBundle rb = findResourceBundle(name);
- if (rb == null) {
+ if (findResourceBundle(name) == null) {
// We've failed to find an expected ResourceBundle.
throw new MissingResourceException("Can't find " + name + " bundle", name, "");
}
diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/ClassPathTestBundle_en.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/ClassPathTestBundle_en.properties Wed Oct 16 05:39:53 2013 +0100
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+sample1=translation #2 for sample1
+sample2=translation #2 for sample2
+supports-test=ResourceBundleSearchTest
diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Wed Oct 16 05:39:53 2013 +0100
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * This class is used to ensure that a resource bundle loadable by a classloader
+ * is on the caller's stack, but not on the classpath or TCCL to ensure that
+ * Logger.getLogger() can't load the bundle via a stack search
+ *
+ * @author Jim Gish
+ */
+public class IndirectlyLoadABundle {
+
+ private final static String rbName = "StackSearchableResource";
+
+ public boolean loadAndTest() throws Throwable {
+ // Find out where we are running from so we can setup the URLClassLoader URLs
+ // test.src and test.classes will be set if running in jtreg, but probably
+ // not otherwise
+ String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
+ String testClassesDir = System.getProperty("test.classes",
+ System.getProperty("user.dir"));
+ String sep = System.getProperty("file.separator");
+ URL[] urls = new URL[2];
+
+ // Allow for both jtreg and standalone cases here
+ urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
+ urls[1] = new URL("file://" + testClassesDir + sep );
+ System.out.println("INFO: urls[0] = " + urls[0]);
+ System.out.println("INFO: urls[1] = " + urls[1]);
+
+ // Make sure we can find it via the URLClassLoader
+ URLClassLoader yetAnotherResourceCL = new URLClassLoader(urls, null);
+ if (!testForValidResourceSetup(yetAnotherResourceCL)) {
+ throw new Exception("Couldn't directly load bundle " + rbName
+ + " as expected. Test config problem");
+ }
+ // But it shouldn't be available via the system classloader
+ ClassLoader myCL = this.getClass().getClassLoader();
+ if (testForValidResourceSetup(myCL)) {
+ throw new Exception("Was able to directly load bundle " + rbName
+ + " from " + myCL + " but shouldn't have been"
+ + " able to. Test config problem");
+ }
+
+ Class<?> loadItUpClazz = Class.forName("LoadItUp", true, yetAnotherResourceCL);
+ ClassLoader actual = loadItUpClazz.getClassLoader();
+ if (actual != yetAnotherResourceCL) {
+ throw new Exception("LoadItUp was loaded by an unexpected CL: " + actual);
+ }
+ Object loadItUp = loadItUpClazz.newInstance();
+ Method testMethod = loadItUpClazz.getMethod("test", String.class);
+ try {
+ return (Boolean) testMethod.invoke(loadItUp, rbName);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+
+ private boolean testForValidResourceSetup(ClassLoader cl) {
+ // First make sure the test environment is setup properly and the bundle actually
+ // exists
+ return ResourceBundleSearchTest.isOnClassPath(rbName, cl);
+ }
+}
diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/LoadItUp.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/LoadItUp.java Wed Oct 16 05:39:53 2013 +0100
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+import java.util.MissingResourceException;
+import java.util.logging.Logger;
+
+/*
+ * This class is loaded onto the call stack when the test method is called
+ * and then its classloader can be used to find a property bundle in the same
+ * directory as the class. However, Logger is not allowed
+ * to find the bundle by looking up the stack for this classloader.
+ * We verify that this cannot happen.
+ *
+ * @author Jim Gish
+ */
+public class LoadItUp {
+
+ private final static boolean DEBUG = false;
+
+ public Boolean test(String rbName) throws Exception {
+ // we should not be able to find the resource in this directory via
+ // getLogger calls. The only way that would be possible given this setup
+ // is that if Logger.getLogger searched up the call stack
+ return lookupBundle(rbName);
+ }
+
+ private boolean lookupBundle(String rbName) {
+ // See if Logger.getLogger can find the resource in this directory
+ try {
+ Logger aLogger = Logger.getLogger("NestedLogger", rbName);
+ } catch (MissingResourceException re) {
+ if (DEBUG) {
+ System.out.println(
+ "As expected, LoadItUp.lookupBundle() did not find the bundle "
+ + rbName);
+ }
+ return false;
+ }
+ System.out.println("FAILED: LoadItUp.lookupBundle() found the bundle "
+ + rbName + " using a stack search.");
+ return true;
+ }
+}
diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Wed Oct 16 05:39:53 2013 +0100
@@ -0,0 +1,249 @@
+/*
+ * 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 8010127
+ * @summary Remove the stack search for a resource bundle Logger to use
+ * @author Jim Gish
+ * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp
+ * @run main ResourceBundleSearchTest
+ */
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+public class ResourceBundleSearchTest {
+
+ private final static boolean DEBUG = false;
+ private final static String LOGGER_PREFIX = "myLogger.";
+ private static int loggerNum = 0;
+ private final static String PROP_RB_NAME = "ClassPathTestBundle";
+ private final static String TCCL_TEST_BUNDLE = "ContextClassLoaderTestBundle";
+
+ private static int numPass = 0;
+ private static int numFail = 0;
+ private static List<String> msgs = new ArrayList<String>();
+
+ public static void main(String[] args) throws Throwable {
+ ResourceBundleSearchTest test = new ResourceBundleSearchTest();
+ test.runTests();
+ }
+
+ private void runTests() throws Throwable {
+ // ensure we are using en as the default Locale so we can find the resource
+ Locale.setDefault(Locale.ENGLISH);
+
+ String testClasses = System.getProperty("test.classes");
+ System.out.println( "test.classes = " + testClasses );
+
+ ClassLoader myClassLoader = ClassLoader.getSystemClassLoader();
+
+ // Find out where we are running from so we can setup the URLClassLoader URL
+ String userDir = System.getProperty("user.dir");
+ String testDir = System.getProperty("test.src", userDir);
+ String sep = System.getProperty("file.separator");
+
+ URL[] urls = new URL[1];
+ urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
+ URLClassLoader rbClassLoader = new URLClassLoader(urls);
+
+ // Test 1 - can we find a Logger bundle from doing a stack search?
+ // We shouldn't be able to
+ assertFalse(testGetBundleFromStackSearch(), "testGetBundleFromStackSearch");
+
+ // Test 2 - can we find a Logger bundle off of the Thread context class
+ // loader? We should be able to.
+ assertTrue(
+ testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader),
+ "testGetBundleFromTCCL");
+
+ // Test 3 - Can we find a Logger bundle from the classpath? We should be
+ // able to, but ....
+ // We check to see if the bundle is on the classpath or not so that this
+ // will work standalone. In the case of jtreg/samevm,
+ // the resource bundles are not on the classpath. Running standalone
+ // (or othervm), they are
+ if (isOnClassPath(PROP_RB_NAME, myClassLoader)) {
+ debug("We should be able to see " + PROP_RB_NAME + " on the classpath");
+ assertTrue(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
+ "testGetBundleFromSystemClassLoader");
+ } else {
+ debug("We should not be able to see " + PROP_RB_NAME + " on the classpath");
+ assertFalse(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
+ "testGetBundleFromSystemClassLoader");
+ }
+
+ report();
+ }
+
+ private void report() throws Exception {
+ System.out.println("Num passed = " + numPass + " Num failed = " + numFail);
+ if (numFail > 0) {
+ // We only care about the messages if they were errors
+ for (String msg : msgs) {
+ System.out.println(msg);
+ }
+ throw new Exception(numFail + " out of " + (numPass + numFail)
+ + " tests failed.");
+ }
+ }
+
+ public void assertTrue(boolean testResult, String testName) {
+ if (testResult) {
+ numPass++;
+ } else {
+ numFail++;
+ System.out.println("FAILED: " + testName
+ + " was supposed to return true but did NOT!");
+ }
+ }
+
+ public void assertFalse(boolean testResult, String testName) {
+ if (!testResult) {
+ numPass++;
+ } else {
+ numFail++;
+ System.out.println("FAILED: " + testName
+ + " was supposed to return false but did NOT!");
+ }
+ }
+
+ public boolean testGetBundleFromStackSearch() throws Throwable {
+ // This should fail. This was the old functionality to search up the
+ // caller's call stack
+ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
+ return indirectLoader.loadAndTest();
+ }
+
+ public boolean testGetBundleFromTCCL(String bundleName,
+ ClassLoader setOnTCCL) throws InterruptedException {
+ // This should succeed. We should be able to get the bundle from the
+ // thread context class loader
+ debug("Looking for " + bundleName + " using TCCL");
+ LoggingThread lr = new LoggingThread(bundleName, setOnTCCL);
+ lr.start();
+ synchronized (lr) {
+ try {
+ lr.wait();
+ } catch (InterruptedException ex) {
+ throw ex;
+ }
+ }
+ msgs.add(lr.msg);
+ return lr.foundBundle;
+ }
+
+ /*
+ * @param String bundleClass
+ * @param ClassLoader to use for search
+ * @return true iff bundleClass is on system classpath
+ */
+ public static boolean isOnClassPath(String baseName, ClassLoader cl) {
+ ResourceBundle rb = null;
+ try {
+ rb = ResourceBundle.getBundle(baseName, Locale.getDefault(), cl);
+ System.out.println("INFO: Found bundle " + baseName + " on " + cl);
+ } catch (MissingResourceException e) {
+ System.out.println("INFO: Could not find bundle " + baseName + " on " + cl);
+ return false;
+ }
+ return (rb != null);
+ }
+
+ private static String newLoggerName() {
+ // we need a new logger name every time we attempt to find a bundle via
+ // the Logger.getLogger call, so we'll simply tack on an integer which
+ // we increment each time this is called
+ loggerNum++;
+ return LOGGER_PREFIX + loggerNum;
+ }
+
+ public boolean testGetBundleFromSystemClassLoader(String bundleName) {
+ // this should succeed if the bundle is on the system classpath.
+ try {
+ Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(),
+ bundleName);
+ } catch (MissingResourceException re) {
+ msgs.add("INFO: testGetBundleFromSystemClassLoader() did not find bundle "
+ + bundleName);
+ return false;
+ }
+ msgs.add("INFO: testGetBundleFromSystemClassLoader() found the bundle "
+ + bundleName);
+ return true;
+ }
+
+ public static class LoggingThread extends Thread {
+
+ boolean foundBundle = false;
+ String msg = null;
+ ClassLoader clToSetOnTCCL = null;
+ String bundleName = null;
+
+ public LoggingThread(String bundleName) {
+ this.bundleName = bundleName;
+ }
+
+ public LoggingThread(String bundleName, ClassLoader setOnTCCL) {
+ this.clToSetOnTCCL = setOnTCCL;
+ this.bundleName = bundleName;
+ }
+
+ public void run() {
+ boolean setTCCL = false;
+ try {
+ if (clToSetOnTCCL != null) {
+ Thread.currentThread().setContextClassLoader(clToSetOnTCCL);
+ setTCCL = true;
+ }
+ // this should succeed if the bundle is on the system classpath.
+ try {
+ Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(),
+ bundleName);
+ msg = "INFO: LoggingRunnable() found the bundle " + bundleName
+ + (setTCCL ? " with " : " without ") + "setting the TCCL";
+ foundBundle = true;
+ } catch (MissingResourceException re) {
+ msg = "INFO: LoggingRunnable() did not find the bundle " + bundleName
+ + (setTCCL ? " with " : " without ") + "setting the TCCL";
+ foundBundle = false;
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ }
+
+ private void debug(String msg) {
+ if (DEBUG) {
+ System.out.println(msg);
+ }
+ }
+}
diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/resources/ContextClassLoaderTestBundle_en.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/resources/ContextClassLoaderTestBundle_en.properties Wed Oct 16 05:39:53 2013 +0100
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+sample1=translation #3 for sample1
+sample2=translation #3 for sample2
+supports-test=ResourceBundleSearchTest
diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/resources/StackSearchableResource_en.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/resources/StackSearchableResource_en.properties Wed Oct 16 05:39:53 2013 +0100
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+sample1=translation #4 for sample1
+sample2=translation #4 for sample2
+supports-test=ResourceBundleSearchTest

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,652 @@
# HG changeset patch
# User juh
# Date 1382736906 -3600
# Fri Oct 25 22:35:06 2013 +0100
# Node ID 2a023db33371ce5ee42134cf0d860ab9f0adff92
# Parent 3b6f55f02122398ba662fb581352c9c9b102c2e3
8004188: Rename src/share/lib/security/java.security to java.security-linux
Reviewed-by: mullan, mchung
diff -r 3b6f55f02122 -r 2a023db33371 make/java/security/Makefile
--- jdk/make/java/security/Makefile Fri Jul 12 11:36:15 2013 +0100
+++ jdk/make/java/security/Makefile Fri Oct 25 22:35:06 2013 +0100
@@ -37,7 +37,8 @@
# Directories
#
-PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security
+# The default security properties file is for linux
+PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security-linux
SUNPKCS11 =
ifeq ($(PLATFORM), solaris)
diff -r 3b6f55f02122 -r 2a023db33371 src/share/lib/security/java.security
--- jdk/src/share/lib/security/java.security Fri Jul 12 11:36:15 2013 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-#
-# This is the "master security properties file".
-#
-# In this file, various security properties are set for use by
-# java.security classes. This is where users can statically register
-# Cryptography Package Providers ("providers" for short). The term
-# "provider" refers to a package or set of packages that supply a
-# concrete implementation of a subset of the cryptography aspects of
-# the Java Security API. A provider may, for example, implement one or
-# more digital signature algorithms or message digest algorithms.
-#
-# Each provider must implement a subclass of the Provider class.
-# To register a provider in this master security properties file,
-# specify the Provider subclass name and priority in the format
-#
-# security.provider.<n>=<className>
-#
-# This declares a provider, and specifies its preference
-# order n. The preference order is the order in which providers are
-# searched for requested algorithms (when no specific provider is
-# requested). The order is 1-based; 1 is the most preferred, followed
-# by 2, and so on.
-#
-# <className> must specify the subclass of the Provider class whose
-# constructor sets the values of various properties that are required
-# for the Java Security API to look up the algorithms or other
-# facilities implemented by the provider.
-#
-# There must be at least one provider specification in java.security.
-# There is a default provider that comes standard with the JDK. It
-# is called the "SUN" provider, and its Provider subclass
-# named Sun appears in the sun.security.provider package. Thus, the
-# "SUN" provider is registered via the following:
-#
-# security.provider.1=sun.security.provider.Sun
-#
-# (The number 1 is used for the default provider.)
-#
-# Note: Providers can be dynamically registered instead by calls to
-# either the addProvider or insertProviderAt method in the Security
-# class.
-
-#
-# List of providers and their preference orders (see above):
-#
-security.provider.1=sun.security.provider.Sun
-security.provider.2=sun.security.rsa.SunRsaSign
-security.provider.3=com.sun.net.ssl.internal.ssl.Provider
-security.provider.4=com.sun.crypto.provider.SunJCE
-security.provider.5=sun.security.jgss.SunProvider
-security.provider.6=com.sun.security.sasl.Provider
-security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
-security.provider.8=sun.security.smartcardio.SunPCSC
-
-#
-# Select the source of seed data for SecureRandom. By default an
-# attempt is made to use the entropy gathering device specified by
-# the securerandom.source property. If an exception occurs when
-# accessing the URL then the traditional system/thread activity
-# algorithm is used.
-#
-# On Solaris and Linux systems, if file:/dev/urandom is specified and it
-# exists, a special SecureRandom implementation is activated by default.
-# This "NativePRNG" reads random bytes directly from /dev/urandom.
-#
-# On Windows systems, the URLs file:/dev/random and file:/dev/urandom
-# enables use of the Microsoft CryptoAPI seed functionality.
-#
-securerandom.source=file:/dev/urandom
-#
-# The entropy gathering device is described as a URL and can also
-# be specified with the system property "java.security.egd". For example,
-# -Djava.security.egd=file:/dev/urandom
-# Specifying this system property will override the securerandom.source
-# setting.
-
-#
-# Class to instantiate as the javax.security.auth.login.Configuration
-# provider.
-#
-login.configuration.provider=com.sun.security.auth.login.ConfigFile
-
-#
-# Default login configuration file
-#
-#login.config.url.1=file:${user.home}/.java.login.config
-
-#
-# Class to instantiate as the system Policy. This is the name of the class
-# that will be used as the Policy object.
-#
-policy.provider=sun.security.provider.PolicyFile
-
-# The default is to have a single system-wide policy file,
-# and a policy file in the user's home directory.
-policy.url.1=file:${java.home}/lib/security/java.policy
-policy.url.2=file:${user.home}/.java.policy
-
-# whether or not we expand properties in the policy file
-# if this is set to false, properties (${...}) will not be expanded in policy
-# files.
-policy.expandProperties=true
-
-# whether or not we allow an extra policy to be passed on the command line
-# with -Djava.security.policy=somefile. Comment out this line to disable
-# this feature.
-policy.allowSystemProperty=true
-
-# whether or not we look into the IdentityScope for trusted Identities
-# when encountering a 1.1 signed JAR file. If the identity is found
-# and is trusted, we grant it AllPermission.
-policy.ignoreIdentityScope=false
-
-#
-# Default keystore type.
-#
-keystore.type=jks
-
-#
-# Class to instantiate as the system scope:
-#
-system.scope=sun.security.provider.IdentityDatabase
-
-#
-# List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageAccess unless the
-# corresponding RuntimePermission ("accessClassInPackage."+package) has
-# been granted.
-package.access=sun.,\
- com.sun.corba.se.impl.,\
- com.sun.xml.internal.,\
- com.sun.imageio.,\
- com.sun.istack.internal.,\
- com.sun.jmx.,\
- com.sun.proxy.,\
- com.sun.org.apache.bcel.internal.,\
- com.sun.org.apache.regexp.internal.,\
- com.sun.org.apache.xerces.internal.,\
- com.sun.org.apache.xpath.internal.,\
- com.sun.org.apache.xalan.internal.extensions.,\
- com.sun.org.apache.xalan.internal.lib.,\
- com.sun.org.apache.xalan.internal.res.,\
- com.sun.org.apache.xalan.internal.templates.,\
- com.sun.org.apache.xalan.internal.xslt.,\
- com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
- com.sun.org.apache.xalan.internal.xsltc.compiler.,\
- com.sun.org.apache.xalan.internal.xsltc.trax.,\
- com.sun.org.apache.xalan.internal.xsltc.util.,\
- com.sun.org.apache.xml.internal.res.,\
- com.sun.org.apache.xml.internal.serializer.utils.,\
- com.sun.org.apache.xml.internal.utils.,\
- com.sun.org.apache.xml.internal.security.,\
- com.sun.org.glassfish.,\
- org.jcp.xml.dsig.internal.
-
-#
-# List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageDefinition unless the
-# corresponding RuntimePermission ("defineClassInPackage."+package) has
-# been granted.
-#
-# by default, none of the class loaders supplied with the JDK call
-# checkPackageDefinition.
-#
-package.definition=sun.,\
- com.sun.corba.se.impl.,\
- com.sun.xml.internal.,\
- com.sun.imageio.,\
- com.sun.istack.internal.,\
- com.sun.jmx.,\
- com.sun.proxy.,\
- com.sun.org.apache.bcel.internal.,\
- com.sun.org.apache.regexp.internal.,\
- com.sun.org.apache.xerces.internal.,\
- com.sun.org.apache.xpath.internal.,\
- com.sun.org.apache.xalan.internal.extensions.,\
- com.sun.org.apache.xalan.internal.lib.,\
- com.sun.org.apache.xalan.internal.res.,\
- com.sun.org.apache.xalan.internal.templates.,\
- com.sun.org.apache.xalan.internal.xslt.,\
- com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
- com.sun.org.apache.xalan.internal.xsltc.compiler.,\
- com.sun.org.apache.xalan.internal.xsltc.trax.,\
- com.sun.org.apache.xalan.internal.xsltc.util.,\
- com.sun.org.apache.xml.internal.res.,\
- com.sun.org.apache.xml.internal.serializer.utils.,\
- com.sun.org.apache.xml.internal.utils.,\
- com.sun.org.apache.xml.internal.security.,\
- com.sun.org.glassfish.,\
- org.jcp.xml.dsig.internal.
-
-#
-# Determines whether this properties file can be appended to
-# or overridden on the command line via -Djava.security.properties
-#
-security.overridePropertiesFile=true
-
-#
-# Determines the default key and trust manager factory algorithms for
-# the javax.net.ssl package.
-#
-ssl.KeyManagerFactory.algorithm=SunX509
-ssl.TrustManagerFactory.algorithm=PKIX
-
-#
-# The Java-level namelookup cache policy for successful lookups:
-#
-# any negative value: caching forever
-# any positive value: the number of seconds to cache an address for
-# zero: do not cache
-#
-# default value is forever (FOREVER). For security reasons, this
-# caching is made forever when a security manager is set. When a security
-# manager is not set, the default behavior in this implementation
-# is to cache for 30 seconds.
-#
-# NOTE: setting this to anything other than the default value can have
-# serious security implications. Do not set it unless
-# you are sure you are not exposed to DNS spoofing attack.
-#
-#networkaddress.cache.ttl=-1
-
-# The Java-level namelookup cache policy for failed lookups:
-#
-# any negative value: cache forever
-# any positive value: the number of seconds to cache negative lookup results
-# zero: do not cache
-#
-# In some Microsoft Windows networking environments that employ
-# the WINS name service in addition to DNS, name service lookups
-# that fail may take a noticeably long time to return (approx. 5 seconds).
-# For this reason the default caching policy is to maintain these
-# results for 10 seconds.
-#
-#
-networkaddress.cache.negative.ttl=10
-
-#
-# Properties to configure OCSP for certificate revocation checking
-#
-
-# Enable OCSP
-#
-# By default, OCSP is not used for certificate revocation checking.
-# This property enables the use of OCSP when set to the value "true".
-#
-# NOTE: SocketPermission is required to connect to an OCSP responder.
-#
-# Example,
-# ocsp.enable=true
-
-#
-# Location of the OCSP responder
-#
-# By default, the location of the OCSP responder is determined implicitly
-# from the certificate being validated. This property explicitly specifies
-# the location of the OCSP responder. The property is used when the
-# Authority Information Access extension (defined in RFC 3280) is absent
-# from the certificate or when it requires overriding.
-#
-# Example,
-# ocsp.responderURL=http://ocsp.example.net:80
-
-#
-# Subject name of the OCSP responder's certificate
-#
-# By default, the certificate of the OCSP responder is that of the issuer
-# of the certificate being validated. This property identifies the certificate
-# of the OCSP responder when the default does not apply. Its value is a string
-# distinguished name (defined in RFC 2253) which identifies a certificate in
-# the set of certificates supplied during cert path validation. In cases where
-# the subject name alone is not sufficient to uniquely identify the certificate
-# then both the "ocsp.responderCertIssuerName" and
-# "ocsp.responderCertSerialNumber" properties must be used instead. When this
-# property is set then those two properties are ignored.
-#
-# Example,
-# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp"
-
-#
-# Issuer name of the OCSP responder's certificate
-#
-# By default, the certificate of the OCSP responder is that of the issuer
-# of the certificate being validated. This property identifies the certificate
-# of the OCSP responder when the default does not apply. Its value is a string
-# distinguished name (defined in RFC 2253) which identifies a certificate in
-# the set of certificates supplied during cert path validation. When this
-# property is set then the "ocsp.responderCertSerialNumber" property must also
-# be set. When the "ocsp.responderCertSubjectName" property is set then this
-# property is ignored.
-#
-# Example,
-# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp"
-
-#
-# Serial number of the OCSP responder's certificate
-#
-# By default, the certificate of the OCSP responder is that of the issuer
-# of the certificate being validated. This property identifies the certificate
-# of the OCSP responder when the default does not apply. Its value is a string
-# of hexadecimal digits (colon or space separators may be present) which
-# identifies a certificate in the set of certificates supplied during cert path
-# validation. When this property is set then the "ocsp.responderCertIssuerName"
-# property must also be set. When the "ocsp.responderCertSubjectName" property
-# is set then this property is ignored.
-#
-# Example,
-# ocsp.responderCertSerialNumber=2A:FF:00
-
diff -r 3b6f55f02122 -r 2a023db33371 src/share/lib/security/java.security-linux
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/src/share/lib/security/java.security-linux Fri Oct 25 22:35:06 2013 +0100
@@ -0,0 +1,311 @@
+#
+# This is the "master security properties file".
+#
+# In this file, various security properties are set for use by
+# java.security classes. This is where users can statically register
+# Cryptography Package Providers ("providers" for short). The term
+# "provider" refers to a package or set of packages that supply a
+# concrete implementation of a subset of the cryptography aspects of
+# the Java Security API. A provider may, for example, implement one or
+# more digital signature algorithms or message digest algorithms.
+#
+# Each provider must implement a subclass of the Provider class.
+# To register a provider in this master security properties file,
+# specify the Provider subclass name and priority in the format
+#
+# security.provider.<n>=<className>
+#
+# This declares a provider, and specifies its preference
+# order n. The preference order is the order in which providers are
+# searched for requested algorithms (when no specific provider is
+# requested). The order is 1-based; 1 is the most preferred, followed
+# by 2, and so on.
+#
+# <className> must specify the subclass of the Provider class whose
+# constructor sets the values of various properties that are required
+# for the Java Security API to look up the algorithms or other
+# facilities implemented by the provider.
+#
+# There must be at least one provider specification in java.security.
+# There is a default provider that comes standard with the JDK. It
+# is called the "SUN" provider, and its Provider subclass
+# named Sun appears in the sun.security.provider package. Thus, the
+# "SUN" provider is registered via the following:
+#
+# security.provider.1=sun.security.provider.Sun
+#
+# (The number 1 is used for the default provider.)
+#
+# Note: Providers can be dynamically registered instead by calls to
+# either the addProvider or insertProviderAt method in the Security
+# class.
+
+#
+# List of providers and their preference orders (see above):
+#
+security.provider.1=sun.security.provider.Sun
+security.provider.2=sun.security.rsa.SunRsaSign
+security.provider.3=com.sun.net.ssl.internal.ssl.Provider
+security.provider.4=com.sun.crypto.provider.SunJCE
+security.provider.5=sun.security.jgss.SunProvider
+security.provider.6=com.sun.security.sasl.Provider
+security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
+security.provider.8=sun.security.smartcardio.SunPCSC
+
+#
+# Select the source of seed data for SecureRandom. By default an
+# attempt is made to use the entropy gathering device specified by
+# the securerandom.source property. If an exception occurs when
+# accessing the URL then the traditional system/thread activity
+# algorithm is used.
+#
+# On Solaris and Linux systems, if file:/dev/urandom is specified and it
+# exists, a special SecureRandom implementation is activated by default.
+# This "NativePRNG" reads random bytes directly from /dev/urandom.
+#
+# On Windows systems, the URLs file:/dev/random and file:/dev/urandom
+# enables use of the Microsoft CryptoAPI seed functionality.
+#
+securerandom.source=file:/dev/urandom
+#
+# The entropy gathering device is described as a URL and can also
+# be specified with the system property "java.security.egd". For example,
+# -Djava.security.egd=file:/dev/urandom
+# Specifying this system property will override the securerandom.source
+# setting.
+
+#
+# Class to instantiate as the javax.security.auth.login.Configuration
+# provider.
+#
+login.configuration.provider=com.sun.security.auth.login.ConfigFile
+
+#
+# Default login configuration file
+#
+#login.config.url.1=file:${user.home}/.java.login.config
+
+#
+# Class to instantiate as the system Policy. This is the name of the class
+# that will be used as the Policy object.
+#
+policy.provider=sun.security.provider.PolicyFile
+
+# The default is to have a single system-wide policy file,
+# and a policy file in the user's home directory.
+policy.url.1=file:${java.home}/lib/security/java.policy
+policy.url.2=file:${user.home}/.java.policy
+
+# whether or not we expand properties in the policy file
+# if this is set to false, properties (${...}) will not be expanded in policy
+# files.
+policy.expandProperties=true
+
+# whether or not we allow an extra policy to be passed on the command line
+# with -Djava.security.policy=somefile. Comment out this line to disable
+# this feature.
+policy.allowSystemProperty=true
+
+# whether or not we look into the IdentityScope for trusted Identities
+# when encountering a 1.1 signed JAR file. If the identity is found
+# and is trusted, we grant it AllPermission.
+policy.ignoreIdentityScope=false
+
+#
+# Default keystore type.
+#
+keystore.type=jks
+
+#
+# Class to instantiate as the system scope:
+#
+system.scope=sun.security.provider.IdentityDatabase
+
+#
+# List of comma-separated packages that start with or equal this string
+# will cause a security exception to be thrown when
+# passed to checkPackageAccess unless the
+# corresponding RuntimePermission ("accessClassInPackage."+package) has
+# been granted.
+package.access=sun.,\
+ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+ com.sun.org.apache.xpath.internal.,\
+ com.sun.org.apache.xalan.internal.extensions.,\
+ com.sun.org.apache.xalan.internal.lib.,\
+ com.sun.org.apache.xalan.internal.res.,\
+ com.sun.org.apache.xalan.internal.templates.,\
+ com.sun.org.apache.xalan.internal.xslt.,\
+ com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
+ com.sun.org.apache.xalan.internal.xsltc.compiler.,\
+ com.sun.org.apache.xalan.internal.xsltc.trax.,\
+ com.sun.org.apache.xalan.internal.xsltc.util.,\
+ com.sun.org.apache.xml.internal.res.,\
+ com.sun.org.apache.xml.internal.serializer.utils.,\
+ com.sun.org.apache.xml.internal.utils.,\
+ com.sun.org.apache.xml.internal.security.,\
+ com.sun.org.glassfish.,\
+ org.jcp.xml.dsig.internal.
+
+#
+# List of comma-separated packages that start with or equal this string
+# will cause a security exception to be thrown when
+# passed to checkPackageDefinition unless the
+# corresponding RuntimePermission ("defineClassInPackage."+package) has
+# been granted.
+#
+# by default, none of the class loaders supplied with the JDK call
+# checkPackageDefinition.
+#
+package.definition=sun.,\
+ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+ com.sun.org.apache.xpath.internal.,\
+ com.sun.org.apache.xalan.internal.extensions.,\
+ com.sun.org.apache.xalan.internal.lib.,\
+ com.sun.org.apache.xalan.internal.res.,\
+ com.sun.org.apache.xalan.internal.templates.,\
+ com.sun.org.apache.xalan.internal.xslt.,\
+ com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
+ com.sun.org.apache.xalan.internal.xsltc.compiler.,\
+ com.sun.org.apache.xalan.internal.xsltc.trax.,\
+ com.sun.org.apache.xalan.internal.xsltc.util.,\
+ com.sun.org.apache.xml.internal.res.,\
+ com.sun.org.apache.xml.internal.serializer.utils.,\
+ com.sun.org.apache.xml.internal.utils.,\
+ com.sun.org.apache.xml.internal.security.,\
+ com.sun.org.glassfish.,\
+ org.jcp.xml.dsig.internal.
+
+#
+# Determines whether this properties file can be appended to
+# or overridden on the command line via -Djava.security.properties
+#
+security.overridePropertiesFile=true
+
+#
+# Determines the default key and trust manager factory algorithms for
+# the javax.net.ssl package.
+#
+ssl.KeyManagerFactory.algorithm=SunX509
+ssl.TrustManagerFactory.algorithm=PKIX
+
+#
+# The Java-level namelookup cache policy for successful lookups:
+#
+# any negative value: caching forever
+# any positive value: the number of seconds to cache an address for
+# zero: do not cache
+#
+# default value is forever (FOREVER). For security reasons, this
+# caching is made forever when a security manager is set. When a security
+# manager is not set, the default behavior in this implementation
+# is to cache for 30 seconds.
+#
+# NOTE: setting this to anything other than the default value can have
+# serious security implications. Do not set it unless
+# you are sure you are not exposed to DNS spoofing attack.
+#
+#networkaddress.cache.ttl=-1
+
+# The Java-level namelookup cache policy for failed lookups:
+#
+# any negative value: cache forever
+# any positive value: the number of seconds to cache negative lookup results
+# zero: do not cache
+#
+# In some Microsoft Windows networking environments that employ
+# the WINS name service in addition to DNS, name service lookups
+# that fail may take a noticeably long time to return (approx. 5 seconds).
+# For this reason the default caching policy is to maintain these
+# results for 10 seconds.
+#
+#
+networkaddress.cache.negative.ttl=10
+
+#
+# Properties to configure OCSP for certificate revocation checking
+#
+
+# Enable OCSP
+#
+# By default, OCSP is not used for certificate revocation checking.
+# This property enables the use of OCSP when set to the value "true".
+#
+# NOTE: SocketPermission is required to connect to an OCSP responder.
+#
+# Example,
+# ocsp.enable=true
+
+#
+# Location of the OCSP responder
+#
+# By default, the location of the OCSP responder is determined implicitly
+# from the certificate being validated. This property explicitly specifies
+# the location of the OCSP responder. The property is used when the
+# Authority Information Access extension (defined in RFC 3280) is absent
+# from the certificate or when it requires overriding.
+#
+# Example,
+# ocsp.responderURL=http://ocsp.example.net:80
+
+#
+# Subject name of the OCSP responder's certificate
+#
+# By default, the certificate of the OCSP responder is that of the issuer
+# of the certificate being validated. This property identifies the certificate
+# of the OCSP responder when the default does not apply. Its value is a string
+# distinguished name (defined in RFC 2253) which identifies a certificate in
+# the set of certificates supplied during cert path validation. In cases where
+# the subject name alone is not sufficient to uniquely identify the certificate
+# then both the "ocsp.responderCertIssuerName" and
+# "ocsp.responderCertSerialNumber" properties must be used instead. When this
+# property is set then those two properties are ignored.
+#
+# Example,
+# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp"
+
+#
+# Issuer name of the OCSP responder's certificate
+#
+# By default, the certificate of the OCSP responder is that of the issuer
+# of the certificate being validated. This property identifies the certificate
+# of the OCSP responder when the default does not apply. Its value is a string
+# distinguished name (defined in RFC 2253) which identifies a certificate in
+# the set of certificates supplied during cert path validation. When this
+# property is set then the "ocsp.responderCertSerialNumber" property must also
+# be set. When the "ocsp.responderCertSubjectName" property is set then this
+# property is ignored.
+#
+# Example,
+# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp"
+
+#
+# Serial number of the OCSP responder's certificate
+#
+# By default, the certificate of the OCSP responder is that of the issuer
+# of the certificate being validated. This property identifies the certificate
+# of the OCSP responder when the default does not apply. Its value is a string
+# of hexadecimal digits (colon or space separators may be present) which
+# identifies a certificate in the set of certificates supplied during cert path
+# validation. When this property is set then the "ocsp.responderCertIssuerName"
+# property must also be set. When the "ocsp.responderCertSubjectName" property
+# is set then this property is ignored.
+#
+# Example,
+# ocsp.responderCertSerialNumber=2A:FF:00
+

View File

@ -0,0 +1,90 @@
# HG changeset patch
# User mchung
# Date 1382735820 -3600
# Fri Oct 25 22:17:00 2013 +0100
# Node ID 695dd7ceb9e34fd4058374de63964c205f061002
# Parent 5b485ecccea9064e5036e1bb040fc2af1f773c20
8006882: Proxy generated classes in sun.proxy package breaks JMockit
Reviewed-by: alanb, ahgross
diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/classes/java/lang/reflect/Proxy.java
--- jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 22:11:26 2013 +0100
+++ jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 22:17:00 2013 +0100
@@ -609,7 +609,7 @@
}
if (proxyPkg == null) {
- // if no non-public proxy interfaces, use sun.proxy package
+ // if no non-public proxy interfaces, use com.sun.proxy package
proxyPkg = ReflectUtil.PROXY_PACKAGE + ".";
}
diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/classes/sun/reflect/misc/ReflectUtil.java
--- jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 22:11:26 2013 +0100
+++ jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 22:17:00 2013 +0100
@@ -246,7 +246,7 @@
}
}
- public static final String PROXY_PACKAGE = "sun.proxy";
+ public static final String PROXY_PACKAGE = "com.sun.proxy";
/**
* Test if the given class is a proxy class that implements
diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/lib/security/java.security
--- jdk/src/share/lib/security/java.security Fri Oct 25 22:11:26 2013 +0100
+++ jdk/src/share/lib/security/java.security Fri Oct 25 22:17:00 2013 +0100
@@ -132,6 +132,7 @@
com.sun.imageio.,\
com.sun.istack.internal.,\
com.sun.jmx.,\
+ com.sun.proxy.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
@@ -167,6 +168,7 @@
com.sun.imageio.,\
com.sun.istack.internal.,\
com.sun.jmx.,\
+ com.sun.proxy.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/lib/security/java.security-solaris
--- jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:11:26 2013 +0100
+++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:17:00 2013 +0100
@@ -133,6 +133,7 @@
com.sun.imageio.,\
com.sun.istack.internal.,\
com.sun.jmx.,\
+ com.sun.proxy.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
@@ -169,6 +170,7 @@
com.sun.imageio.,\
com.sun.istack.internal.,\
com.sun.jmx.,\
+ com.sun.proxy.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/lib/security/java.security-windows
--- jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:11:26 2013 +0100
+++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:17:00 2013 +0100
@@ -133,6 +133,7 @@
com.sun.imageio.,\
com.sun.istack.internal.,\
com.sun.jmx.,\
+ com.sun.proxy.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
@@ -170,6 +171,7 @@
com.sun.imageio.,\
com.sun.istack.internal.,\
com.sun.jmx.,\
+ com.sun.proxy.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\

View File

@ -0,0 +1,115 @@
# HG changeset patch
# User okutsu
# Date 1374215521 -32400
# Fri Jul 19 15:32:01 2013 +0900
# Node ID f38a3c5421df4697851a4b4d491071c3a30e5378
# Parent 5d81a5f8a3791316367990b35b1ad5faef42d773
8006900: Add new date/time capability
Reviewed-by: mchung, hawtin
diff -r 5d81a5f8a379 -r f38a3c5421df src/share/classes/java/util/TimeZone.java
--- jdk/src/share/classes/java/util/TimeZone.java Tue Oct 15 15:04:24 2013 +0100
+++ jdk/src/share/classes/java/util/TimeZone.java Fri Jul 19 15:32:01 2013 +0900
@@ -170,6 +170,11 @@
// Proclaim serialization compatibility with JDK 1.1
static final long serialVersionUID = 3581463369166924961L;
+ // TimeZone.setDefault maintains the compatible behavior of the AppContext-based
+ // default setting for untrusted code if allowSetDefault is true.
+ private static final boolean allowSetDefault = AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction("jdk.util.TimeZone.allowSetDefault")) != null;
+
/**
* Gets the time zone offset, for current date, modified in case of
* daylight savings. This is the offset to add to UTC to get local time.
@@ -616,6 +621,9 @@
sm.checkPermission(new PropertyPermission
("user.timezone", "write"));
} catch (SecurityException e) {
+ if (!allowSetDefault) {
+ throw e;
+ }
hasPermission = false;
}
}
@@ -646,6 +654,7 @@
* Returns the default TimeZone in an AppContext if any AppContext
* has ever used. null is returned if any AppContext hasn't been
* used or if the AppContext doesn't have the default TimeZone.
+ * null is also returned if allowSetDefault is false.
*
* Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
* been loaded. If so, it implies that AWTSecurityManager is not our
@@ -653,18 +662,20 @@
* This works around a build time issue.
*/
private static TimeZone getDefaultInAppContext() {
- // JavaAWTAccess provides access implementation-private methods without using reflection.
- JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
- if (javaAWTAccess == null) {
- return mainAppContextDefault;
- } else {
- if (!javaAWTAccess.isDisposed()) {
- TimeZone tz = (TimeZone)
- javaAWTAccess.get(TimeZone.class);
- if (tz == null && javaAWTAccess.isMainAppContext()) {
- return mainAppContextDefault;
- } else {
- return tz;
+ if (allowSetDefault) {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ if (javaAWTAccess == null) {
+ return mainAppContextDefault;
+ } else {
+ if (!javaAWTAccess.isDisposed()) {
+ TimeZone tz = (TimeZone)
+ javaAWTAccess.get(TimeZone.class);
+ if (tz == null && javaAWTAccess.isMainAppContext()) {
+ return mainAppContextDefault;
+ } else {
+ return tz;
+ }
}
}
}
@@ -672,9 +683,9 @@
}
/**
- * Sets the default TimeZone in the AppContext to the given
- * tz. null is handled special: do nothing if any AppContext
- * hasn't been used, remove the default TimeZone in the
+ * Sets the default TimeZone in the AppContext to the given tz if
+ * allowSetDefault is true. null is handled special: do nothing if any
+ * AppContext hasn't been used, remove the default TimeZone in the
* AppContext otherwise.
*
* Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
@@ -683,15 +694,17 @@
* This works around a build time issue.
*/
private static void setDefaultInAppContext(TimeZone tz) {
- // JavaAWTAccess provides access implementation-private methods without using reflection.
- JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
- if (javaAWTAccess == null) {
- mainAppContextDefault = tz;
- } else {
- if (!javaAWTAccess.isDisposed()) {
- javaAWTAccess.put(TimeZone.class, tz);
- if (javaAWTAccess.isMainAppContext()) {
- mainAppContextDefault = null;
+ if (allowSetDefault) {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ if (javaAWTAccess == null) {
+ mainAppContextDefault = tz;
+ } else {
+ if (!javaAWTAccess.isDisposed()) {
+ javaAWTAccess.put(TimeZone.class, tz);
+ if (javaAWTAccess.isMainAppContext()) {
+ mainAppContextDefault = null;
+ }
}
}
}

View File

@ -0,0 +1,61 @@
# HG changeset patch
# User dsamersoff
# Date 1373279676 -14400
# Mon Jul 08 14:34:36 2013 +0400
# Node ID db4712506571ae3ae2d37b91e63641b18c3258f2
# Parent f38a3c5421df4697851a4b4d491071c3a30e5378
8008589: Better MBean permission validation
Summary: Better MBean permission validation
Reviewed-by: skoivu, dfuchs, mchung, sjiang
diff -r f38a3c5421df -r db4712506571 src/share/classes/javax/management/MBeanTrustPermission.java
--- jdk/src/share/classes/javax/management/MBeanTrustPermission.java Fri Jul 19 15:32:01 2013 +0900
+++ jdk/src/share/classes/javax/management/MBeanTrustPermission.java Mon Jul 08 14:34:36 2013 +0400
@@ -26,6 +26,9 @@
package javax.management;
import java.security.BasicPermission;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
/**
* This permission represents "trust" in a signer or codebase.
@@ -75,15 +78,31 @@
*/
public MBeanTrustPermission(String name, String actions) {
super(name, actions);
+ validate(name,actions);
+ }
+
+ private static void validate(String name, String actions) {
/* Check that actions is a null empty string */
- if (actions != null && actions.length() > 0)
- throw new IllegalArgumentException("MBeanTrustPermission " +
- "actions must be null: " +
+ if (actions != null && actions.length() > 0) {
+ throw new IllegalArgumentException("MBeanTrustPermission actions must be null: " +
actions);
+ }
- if (!name.equals("register") && !name.equals("*"))
- throw new IllegalArgumentException("MBeanTrustPermission: " +
- "Unknown target name " +
+ if (!name.equals("register") && !name.equals("*")) {
+ throw new IllegalArgumentException("MBeanTrustPermission: Unknown target name " +
"[" + name + "]");
+ }
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+
+ // Reading private fields of base class
+ in.defaultReadObject();
+ try {
+ validate(super.getName(),super.getActions());
+ } catch (IllegalArgumentException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
# HG changeset patch
# User mchung
# Date 1368544028 25200
# Tue May 14 08:07:08 2013 -0700
# Node ID e3eae7996a478cd07125110456836a42c8a504c6
# Parent d4fca2113b280a7db03b67caae22e0ceafb51b89
8010727: WLS fails to add a logger with "" in its own LogManager subclass instance
Reviewed-by: alanb, jgish
diff -r d4fca2113b28 -r e3eae7996a47 src/share/classes/java/util/logging/LogManager.java
--- jdk/src/share/classes/java/util/logging/LogManager.java Fri Oct 25 17:51:03 2013 +0100
+++ jdk/src/share/classes/java/util/logging/LogManager.java Tue May 14 08:07:08 2013 -0700
@@ -486,7 +486,7 @@
}
synchronized void ensureRootLogger(Logger logger) {
- if (logger == manager.rootLogger)
+ if (logger.getName().isEmpty())
return;
// during initialization, rootLogger is null when
diff -r d4fca2113b28 -r e3eae7996a47 test/java/util/logging/LogManagerInstanceTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/LogManagerInstanceTest.java Tue May 14 08:07:08 2013 -0700
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+import java.util.logging.*;
+
+/*
+ * @test
+ * @bug 8010727
+ * @summary LogManager.addLogger should succeed to add a logger named ""
+ * if LogManager.getLogger("") returns null.
+ *
+ * @run main LogManagerInstanceTest
+ */
+
+public class LogManagerInstanceTest {
+ public static void main(String[] argv) {
+ LogManager mgr = LogManager.getLogManager();
+ if (getRootLogger(mgr) == null) {
+ throw new RuntimeException("Root logger not exist");
+ }
+
+ SecondLogManager mgr2 = new SecondLogManager();
+ Logger root = getRootLogger(mgr2);
+ if (mgr2.base != root) {
+ throw new RuntimeException(mgr2.base + " is not the root logger");
+ }
+ }
+
+ private static Logger getRootLogger(LogManager mgr) {
+ Logger l = mgr.getLogger("");
+ if (l != null && !l.getName().isEmpty()) {
+ throw new RuntimeException(l.getName() + " is not an invalid root logger");
+ }
+ return l;
+ }
+
+ static class SecondLogManager extends LogManager {
+ final Logger base;
+ private SecondLogManager() {
+ Logger root = getLogger("");
+ if (root == null) {
+ root = new BaseLogger("", null);
+ if (!super.addLogger(root))
+ throw new RuntimeException("Fail to addLogger " + root);
+ } else {
+ System.out.println("Root logger already exists");
+ }
+ this.base = root;
+ }
+ }
+ static class BaseLogger extends Logger {
+ BaseLogger(String name, String rbname) {
+ super(name, rbname);
+ }
+ }
+}

View File

@ -0,0 +1,266 @@
# HG changeset patch
# User jgish
# Date 1366415410 25200
# Fri Apr 19 16:50:10 2013 -0700
# Node ID ed410e3d08fe7792e6c08e411580564d2562c03e
# Parent e3eae7996a478cd07125110456836a42c8a504c6
8010939: Deadlock in LogManager
Summary: re-order locks to avoid deadlock
Reviewed-by: mchung, alanb
diff -r e3eae7996a47 -r ed410e3d08fe src/share/classes/java/util/logging/LogManager.java
--- jdk/src/share/classes/java/util/logging/LogManager.java Tue May 14 08:07:08 2013 -0700
+++ jdk/src/share/classes/java/util/logging/LogManager.java Fri Apr 19 16:50:10 2013 -0700
@@ -33,10 +33,8 @@
import java.lang.ref.WeakReference;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import java.net.URL;
import sun.misc.JavaAWTAccess;
import sun.misc.SharedSecrets;
-import sun.security.action.GetPropertyAction;
/**
* There is a single global LogManager object that is used to
@@ -151,7 +149,6 @@
// The global LogManager object
private static LogManager manager;
- private final static Handler[] emptyHandlers = { };
private Properties props = new Properties();
private PropertyChangeSupport changes
= new PropertyChangeSupport(LogManager.class);
@@ -506,14 +503,11 @@
throw new NullPointerException();
}
- // cleanup some Loggers that have been GC'ed
- manager.drainLoggerRefQueueBounded();
-
LoggerWeakRef ref = namedLoggers.get(name);
if (ref != null) {
if (ref.get() == null) {
- // It's possible that the Logger was GC'ed after the
- // drainLoggerRefQueueBounded() call above so allow
+ // It's possible that the Logger was GC'ed after a
+ // drainLoggerRefQueueBounded() call so allow
// a new one to be registered.
removeLogger(name);
} else {
@@ -561,6 +555,8 @@
return true;
}
+ // note: all calls to removeLogger are synchronized on LogManager's
+ // intrinsic lock
void removeLogger(String name) {
namedLoggers.remove(name);
}
@@ -845,6 +841,7 @@
if (name == null) {
throw new NullPointerException();
}
+ drainLoggerRefQueueBounded();
LoggerContext cx = getUserContext();
if (cx.addLocalLogger(logger)) {
// Do we have a per logger handler too?
diff -r e3eae7996a47 -r ed410e3d08fe test/java/util/logging/DrainFindDeadlockTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/DrainFindDeadlockTest.java Fri Apr 19 16:50:10 2013 -0700
@@ -0,0 +1,196 @@
+/*
+ * 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.
+ */
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+import java.lang.Thread.State;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import java.util.Map;
+
+/**
+ * @test
+ * @bug 8010939
+ * @summary check for deadlock between findLogger() and drainLoggerRefQueueBounded()
+ * @author jim.gish@oracle.com
+ * @build DrainFindDeadlockTest
+ * @run main/othervm/timeout=10 DrainFindDeadlockTest
+ */
+
+/**
+ * This test is checking for a deadlock between
+ * LogManager$LoggerContext.findLogger() and
+ * LogManager.drainLoggerRefQueueBounded() (which could happen by calling
+ * Logger.getLogger() and LogManager.readConfiguration() in different threads)
+ */
+public class DrainFindDeadlockTest {
+ private LogManager mgr = LogManager.getLogManager();
+ private final static int MAX_ITERATIONS = 100;
+
+ // Get a ThreadMXBean so we can check for deadlock. N.B. this may
+ // not be supported on all platforms, which means we will have to
+ // resort to the traditional test timeout method. However, if
+ // we have the support we'll get the deadlock details if one
+ // is detected.
+ private final static ThreadMXBean threadMXBean =
+ ManagementFactory.getThreadMXBean();
+ private final boolean threadMXBeanDeadlockSupported =
+ threadMXBean.isSynchronizerUsageSupported();
+
+ public static void main(String... args) throws IOException, Exception {
+ new DrainFindDeadlockTest().testForDeadlock();
+ }
+
+ public static void randomDelay() {
+ int runs = (int) Math.random() * 1000000;
+ int c = 0;
+
+ for (int i=0; i<runs; ++i) {
+ c=c+i;
+ }
+ }
+
+ public void testForDeadlock() throws IOException, Exception {
+ System.out.println("Deadlock detection "
+ + (threadMXBeanDeadlockSupported ? "is" : "is not") +
+ " available.");
+ Thread setup = new Thread(new SetupLogger(), "SetupLogger");
+ Thread readConfig = new Thread(new ReadConfig(), "ReadConfig");
+ Thread check = new Thread(new DeadlockChecker(setup, readConfig),
+ "DeadlockChecker");
+
+ // make the threads daemon threads so they will go away when the
+ // test exits
+ setup.setDaemon(true);
+ readConfig.setDaemon(true);
+ check.setDaemon(true);
+
+ check.start(); setup.start(); readConfig.start();
+ try {
+ check.join();
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ try {
+ readConfig.join();
+ setup.join();
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ System.out.println("Test passed");
+ }
+
+ class SetupLogger implements Runnable {
+ Logger logger = null;
+
+ @Override
+ public void run() {
+ System.out.println("Running " + Thread.currentThread().getName());
+
+ for (int i=0; i < MAX_ITERATIONS; i++) {
+ logger = Logger.getLogger("DrainFindDeadlockTest"+i);
+ DrainFindDeadlockTest.randomDelay();
+ }
+ }
+ }
+
+ class ReadConfig implements Runnable {
+ @Override
+ public void run() {
+ System.out.println("Running " + Thread.currentThread().getName());
+ for (int i=0; i < MAX_ITERATIONS; i++) {
+ try {
+ mgr.readConfiguration();
+ } catch (IOException | SecurityException ex) {
+ throw new RuntimeException("FAILED: test setup problem", ex);
+ }
+ DrainFindDeadlockTest.randomDelay();
+ }
+ }
+ }
+
+ class DeadlockChecker implements Runnable {
+ Thread t1, t2;
+
+ DeadlockChecker(Thread t1, Thread t2) {
+ this.t1 = t1;
+ this.t2 = t2;
+ }
+
+ void checkState(Thread x, Thread y) {
+ // System.out.println("checkstate");
+ boolean isXblocked = x.getState().equals(State.BLOCKED);
+ boolean isYblocked = y.getState().equals(State.BLOCKED);
+ long[] deadlockedThreads = null;
+
+ if (isXblocked && isYblocked) {
+ System.out.println("threads blocked");
+ // they are both blocked, but this doesn't necessarily mean
+ // they are deadlocked
+ if (threadMXBeanDeadlockSupported) {
+ System.out.println("checking for deadlock");
+ deadlockedThreads = threadMXBean.findDeadlockedThreads();
+ } else {
+ System.out.println("Can't check for deadlock");
+ }
+ if (deadlockedThreads != null) {
+ System.out.println("We detected a deadlock! ");
+ ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(
+ deadlockedThreads, true, true);
+ for (ThreadInfo threadInfo: threadInfos) {
+ System.out.println(threadInfo);
+ }
+ throw new RuntimeException("TEST FAILED: Deadlock detected");
+ }
+ System.out.println("We may have a deadlock");
+ Map<Thread, StackTraceElement[]> threadMap =
+ Thread.getAllStackTraces();
+ dumpStack(threadMap.get(x), x);
+ dumpStack(threadMap.get(y), y);
+ }
+ }
+
+ private void dumpStack(StackTraceElement[] aStackElt, Thread aThread) {
+ if (aStackElt != null) {
+ System.out.println("Thread:" + aThread.getName() + ": " +
+ aThread.getState());
+ for (StackTraceElement element: aStackElt) {
+ System.out.println(" " + element);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ System.out.println("Running " + Thread.currentThread().getName());
+ for (int i=0; i < MAX_ITERATIONS*2; i++) {
+ checkState(t1, t2);
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException ex) {
+ };
+ }
+ }
+ }
+}

View File

@ -0,0 +1,287 @@
# HG changeset patch
# User ascarpino
# Date 1381846341 -3600
# Tue Oct 15 15:12:21 2013 +0100
# Node ID df887df12ad1543894fe79f753983754ceef5c73
# Parent db4712506571ae3ae2d37b91e63641b18c3258f2
8011071: Better crypto provider handling
Reviewed-by: hawtin, valeriep
diff -r db4712506571 -r df887df12ad1 src/share/classes/com/sun/crypto/provider/DHPrivateKey.java
--- jdk/src/share/classes/com/sun/crypto/provider/DHPrivateKey.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/com/sun/crypto/provider/DHPrivateKey.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, 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
@@ -279,22 +279,6 @@
return new DHParameterSpec(this.p, this.g);
}
- public String toString() {
- String LINE_SEP = System.getProperty("line.separator");
-
- StringBuffer strbuf
- = new StringBuffer("SunJCE Diffie-Hellman Private Key:"
- + LINE_SEP + "x:" + LINE_SEP
- + Debug.toHexString(this.x)
- + LINE_SEP + "p:" + LINE_SEP
- + Debug.toHexString(this.p)
- + LINE_SEP + "g:" + LINE_SEP
- + Debug.toHexString(this.g));
- if (this.l != 0)
- strbuf.append(LINE_SEP + "l:" + LINE_SEP + " " + this.l);
- return strbuf.toString();
- }
-
private void parseKeyBits() throws InvalidKeyException {
try {
DerInputStream in = new DerInputStream(this.key);
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/ec/ECPrivateKeyImpl.java
--- jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -153,12 +153,4 @@
throw new InvalidKeyException("Invalid EC private key", e);
}
}
-
- // return a string representation of this key for debugging
- public String toString() {
- return "Sun EC private key, " + params.getCurve().getField().getFieldSize()
- + " bits\n private value: "
- + s + "\n parameters: " + params;
- }
-
}
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/jgss/GSSCredentialImpl.java
--- jdk/src/share/classes/sun/security/jgss/GSSCredentialImpl.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/jgss/GSSCredentialImpl.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -630,7 +630,7 @@
buffer.append(element.isAcceptorCredential() ?
" Accept" : "");
buffer.append(" [");
- buffer.append(element.toString());
+ buffer.append(element.getClass());
buffer.append(']');
} catch (GSSException e) {
// skip to next element
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/pkcs/PKCS8Key.java
--- jdk/src/share/classes/sun/security/pkcs/PKCS8Key.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/pkcs/PKCS8Key.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -304,17 +304,6 @@
return encodedKey.clone();
}
- /*
- * Returns a printable representation of the key
- */
- public String toString ()
- {
- HexDumpEncoder encoder = new HexDumpEncoder ();
-
- return "algorithm = " + algid.toString ()
- + ", unparsed keybits = \n" + encoder.encodeBuffer (key);
- }
-
/**
* Initialize an PKCS8Key object from an input stream. The data
* on that input stream must be encoded using DER, obeying the
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/pkcs11/P11Key.java
--- jdk/src/share/classes/sun/security/pkcs11/P11Key.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/pkcs11/P11Key.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -542,27 +542,6 @@
fetchValues();
return coeff;
}
- public String toString() {
- fetchValues();
- StringBuilder sb = new StringBuilder(super.toString());
- sb.append("\n modulus: ");
- sb.append(n);
- sb.append("\n public exponent: ");
- sb.append(e);
- sb.append("\n private exponent: ");
- sb.append(d);
- sb.append("\n prime p: ");
- sb.append(p);
- sb.append("\n prime q: ");
- sb.append(q);
- sb.append("\n prime exponent p: ");
- sb.append(pe);
- sb.append("\n prime exponent q: ");
- sb.append(qe);
- sb.append("\n crt coefficient: ");
- sb.append(coeff);
- return sb.toString();
- }
}
// RSA non-CRT private key
@@ -616,15 +595,6 @@
fetchValues();
return d;
}
- public String toString() {
- fetchValues();
- StringBuilder sb = new StringBuilder(super.toString());
- sb.append("\n modulus: ");
- sb.append(n);
- sb.append("\n private exponent: ");
- sb.append(d);
- return sb.toString();
- }
}
private static final class P11RSAPublicKey extends P11Key
@@ -794,11 +764,6 @@
fetchValues();
return params;
}
- public String toString() {
- fetchValues();
- return super.toString() + "\n x: " + x + "\n p: " + params.getP()
- + "\n q: " + params.getQ() + "\n g: " + params.getG();
- }
}
private static final class P11DHPrivateKey extends P11Key
@@ -856,11 +821,6 @@
fetchValues();
return params;
}
- public String toString() {
- fetchValues();
- return super.toString() + "\n x: " + x + "\n p: " + params.getP()
- + "\n g: " + params.getG();
- }
}
private static final class P11DHPublicKey extends P11Key
@@ -977,12 +937,6 @@
fetchValues();
return params;
}
- public String toString() {
- fetchValues();
- return super.toString()
- + "\n private value: " + s
- + "\n parameters: " + params;
- }
}
private static final class P11ECPublicKey extends P11Key
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/provider/DSAPrivateKey.java
--- jdk/src/share/classes/sun/security/provider/DSAPrivateKey.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/provider/DSAPrivateKey.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -142,11 +142,6 @@
}
}
- public String toString() {
- return "Sun DSA Private Key \nparameters:" + algid + "\nx: " +
- Debug.toHexString(x) + "\n";
- }
-
protected void parseKeyBits() throws InvalidKeyException {
try {
DerInputStream in = new DerInputStream(key);
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
--- jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -225,29 +225,4 @@
}
return b;
}
-
- // return a string representation of this key for debugging
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("Sun RSA private CRT key, ");
- sb.append(n.bitLength());
- sb.append(" bits\n modulus: ");
- sb.append(n);
- sb.append("\n public exponent: ");
- sb.append(e);
- sb.append("\n private exponent: ");
- sb.append(d);
- sb.append("\n prime p: ");
- sb.append(p);
- sb.append("\n prime q: ");
- sb.append(q);
- sb.append("\n prime exponent p: ");
- sb.append(pe);
- sb.append("\n prime exponent q: ");
- sb.append(qe);
- sb.append("\n crt coefficient: ");
- sb.append(coeff);
- return sb.toString();
- }
-
}
diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java
--- jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java Mon Jul 08 14:34:36 2013 +0400
+++ jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java Tue Oct 15 15:12:21 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -98,11 +98,4 @@
public BigInteger getPrivateExponent() {
return d;
}
-
- // return a string representation of this key for debugging
- public String toString() {
- return "Sun RSA private key, " + n.bitLength() + " bits\n modulus: "
- + n + "\n private exponent: " + d;
- }
-
}

View File

@ -0,0 +1,267 @@
# HG changeset patch
# User jbachorik
# Date 1366702651 -7200
# Tue Apr 23 09:37:31 2013 +0200
# Node ID de77043ae6b9c9693ae149d0ab9bae4d5007ce19
# Parent df887df12ad1543894fe79f753983754ceef5c73
8011081: Improve jhat
Summary: Properly escape HTML output
Reviewed-by: alanb, mschoene, sundar
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java Tue Apr 23 09:37:31 2013 +0200
@@ -84,7 +84,7 @@
lastPackage = pkg;
printClass(clazz);
if (clazz.getId() != -1) {
- out.print(" [" + clazz.getIdString() + "]");
+ print(" [" + clazz.getIdString() + "]");
}
out.println("<br>");
}
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java Tue Apr 23 09:37:31 2013 +0200
@@ -112,12 +112,12 @@
out.println("<h2>Instances</h2>");
printAnchorStart();
- out.print("instances/" + encodeForURL(clazz));
+ print("instances/" + encodeForURL(clazz));
out.print("\">");
out.println("Exclude subclasses</a><br>");
printAnchorStart();
- out.print("allInstances/" + encodeForURL(clazz));
+ print("allInstances/" + encodeForURL(clazz));
out.print("\">");
out.println("Include subclasses</a><br>");
@@ -126,19 +126,19 @@
out.println("<h2>New Instances</h2>");
printAnchorStart();
- out.print("newInstances/" + encodeForURL(clazz));
+ print("newInstances/" + encodeForURL(clazz));
out.print("\">");
out.println("Exclude subclasses</a><br>");
printAnchorStart();
- out.print("allNewInstances/" + encodeForURL(clazz));
+ print("allNewInstances/" + encodeForURL(clazz));
out.print("\">");
out.println("Include subclasses</a><br>");
}
out.println("<h2>References summary by Type</h2>");
printAnchorStart();
- out.print("refsByType/" + encodeForURL(clazz));
+ print("refsByType/" + encodeForURL(clazz));
out.print("\">");
out.println("References summary by type</a>");
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java Tue Apr 23 09:37:31 2013 +0200
@@ -41,21 +41,17 @@
import java.net.Socket;
-import java.net.ServerSocket;
-import java.net.InetAddress;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
-import java.io.Writer;
import java.io.BufferedWriter;
import java.io.PrintWriter;
-import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.BufferedOutputStream;
import com.sun.tools.hat.internal.model.Snapshot;
import com.sun.tools.hat.internal.oql.OQLEngine;
+import com.sun.tools.hat.internal.util.Misc;
public class HttpReader implements Runnable {
@@ -87,7 +83,7 @@
outputError("Protocol error");
}
int data;
- StringBuffer queryBuf = new StringBuffer();
+ StringBuilder queryBuf = new StringBuilder();
while ((data = in.read()) != -1 && data != ' ') {
char ch = (char) data;
queryBuf.append(ch);
@@ -217,7 +213,7 @@
private void outputError(String msg) {
out.println();
out.println("<html><body bgcolor=\"#ffffff\">");
- out.println(msg);
+ out.println(Misc.encodeHtml(msg));
out.println("</body></html>");
}
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java Tue Apr 23 09:37:31 2013 +0200
@@ -102,7 +102,7 @@
int count = clazz.getInstancesCount(false);
print("" + count);
printAnchorStart();
- out.print("instances/" + encodeForURL(classes[i]));
+ print("instances/" + encodeForURL(classes[i]));
out.print("\"> ");
if (count == 1) {
print("instance");
@@ -121,7 +121,7 @@
}
print("(");
printAnchorStart();
- out.print("newInstances/" + encodeForURL(classes[i]));
+ print("newInstances/" + encodeForURL(classes[i]));
out.print("\">");
print("" + newInst + " new");
out.print("</a>) ");
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java Tue Apr 23 09:37:31 2013 +0200
@@ -54,10 +54,7 @@
out.print((char)ch);
}
} catch (Exception exp) {
- out.println(exp.getMessage());
- out.println("<pre>");
- exp.printStackTrace(out);
- out.println("</pre>");
+ printException(exp);
}
}
}
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java Tue Apr 23 09:37:31 2013 +0200
@@ -32,10 +32,7 @@
package com.sun.tools.hat.internal.server;
-import com.sun.tools.hat.internal.model.*;
import com.sun.tools.hat.internal.oql.*;
-import com.sun.tools.hat.internal.util.ArraySorter;
-import com.sun.tools.hat.internal.util.Comparer;
/**
* This handles Object Query Language (OQL) queries.
@@ -68,7 +65,7 @@
out.println("<p align='center'>");
out.println("<textarea name='query' cols=80 rows=10>");
if (oql != null) {
- out.println(oql);
+ println(oql);
}
out.println("</textarea>");
out.println("</p>");
@@ -91,10 +88,7 @@
try {
out.println(engine.toHtml(o));
} catch (Exception e) {
- out.println(e.getMessage());
- out.println("<pre>");
- e.printStackTrace(out);
- out.println("</pre>");
+ printException(e);
}
out.println("</td></tr>");
return false;
@@ -102,10 +96,7 @@
});
out.println("</table>");
} catch (OQLException exp) {
- out.println(exp.getMessage());
- out.println("<pre>");
- exp.printStackTrace(out);
- out.println("</pre>");
+ printException(exp);
}
}
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java Tue Apr 23 09:37:31 2013 +0200
@@ -36,6 +36,7 @@
import com.sun.tools.hat.internal.model.*;
import com.sun.tools.hat.internal.util.Misc;
+import java.io.StringWriter;
import java.net.URLEncoder;
import java.io.UnsupportedEncodingException;
@@ -96,7 +97,7 @@
}
protected void error(String msg) {
- out.println(msg);
+ println(msg);
}
protected void printAnchorStart() {
@@ -160,7 +161,6 @@
out.println("null");
return;
}
- String name = clazz.getName();
printAnchorStart();
out.print("class/");
print(encodeForURL(clazz));
@@ -208,6 +208,15 @@
}
}
+ protected void printException(Throwable t) {
+ println(t.getMessage());
+ out.println("<pre>");
+ StringWriter sw = new StringWriter();
+ t.printStackTrace(new PrintWriter(sw));
+ print(sw.toString());
+ out.println("</pre>");
+ }
+
protected void printHex(long addr) {
if (snapshot.getIdentifierSize() == 4) {
out.print(Misc.toHex((int)addr));
@@ -223,4 +232,8 @@
protected void print(String str) {
out.print(Misc.encodeHtml(str));
}
+
+ protected void println(String str) {
+ out.println(Misc.encodeHtml(str));
+ }
}
diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java
--- jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java Tue Oct 15 15:12:21 2013 +0100
+++ jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java Tue Apr 23 09:37:31 2013 +0200
@@ -89,7 +89,7 @@
out.println("<p align='center'>");
printClass(clazz);
if (clazz.getId() != -1) {
- out.println("[" + clazz.getIdString() + "]");
+ println("[" + clazz.getIdString() + "]");
}
out.println("</p>");
@@ -125,9 +125,9 @@
JavaClass clazz = classes[i];
out.println("<tr><td>");
out.print("<a href='/refsByType/");
- out.print(clazz.getIdString());
+ print(clazz.getIdString());
out.print("'>");
- out.print(clazz.getName());
+ print(clazz.getName());
out.println("</a>");
out.println("</td><td>");
out.println(map.get(clazz));

View File

@ -0,0 +1,58 @@
# HG changeset patch
# User jfranck
# Date 1382726704 -3600
# Fri Oct 25 19:45:04 2013 +0100
# Node ID a2b63addc0633a5ef8d196d1019d78b920cb4b1a
# Parent e7ed5dad88eefc49130ae02bcbf329d72f18f12e
8011139: (reflect) Revise checking in getEnclosingClass
Reviewed-by: darcy, mchung, ahgross
diff -r e7ed5dad88ee -r a2b63addc063 src/share/classes/java/lang/Class.java
--- jdk/src/share/classes/java/lang/Class.java Fri Oct 25 19:37:20 2013 +0100
+++ jdk/src/share/classes/java/lang/Class.java Fri Oct 25 19:45:04 2013 +0100
@@ -1131,13 +1131,9 @@
enclosingCandidate = enclosingClass;
}
- // be very careful not to change the stack depth of this
- // checkMemberAccess call for security reasons
- // see java.lang.SecurityManager.checkMemberAccess
- if (enclosingCandidate != null) {
- enclosingCandidate.checkMemberAccess(Member.DECLARED,
- Reflection.getCallerClass(), true);
- }
+ if (enclosingCandidate != null)
+ enclosingCandidate.checkPackageAccess(
+ ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
return enclosingCandidate;
}
@@ -2214,6 +2210,8 @@
* Check if client is allowed to access members. If access is denied,
* throw a SecurityException.
*
+ * This method also enforces package access.
+ *
* <p> Default policy: allow all clients access with normal Java access
* control.
*/
@@ -2234,7 +2232,19 @@
// checkMemberAccess of subclasses of SecurityManager as specified.
s.checkMemberAccess(this, which);
}
+ this.checkPackageAccess(ccl, checkProxyInterfaces);
+ }
+ }
+ /*
+ * Checks if a client loaded in ClassLoader ccl is allowed to access this
+ * class under the current package access policy. If access is denied,
+ * throw a SecurityException.
+ */
+ private void checkPackageAccess(final ClassLoader ccl, boolean checkProxyInterfaces) {
+ final SecurityManager s = System.getSecurityManager();
+ if (s != null) {
+ final ClassLoader cl = getClassLoader0();
if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
String name = this.getName();

View File

@ -0,0 +1,125 @@
# HG changeset patch
# User msheppar
# Date 1381849187 -3600
# Tue Oct 15 15:59:47 2013 +0100
# Node ID 468ec57a684409e4c7ed97be8ffa36322fb8a36b
# Parent de77043ae6b9c9693ae149d0ab9bae4d5007ce19
8011157: Improve CORBA portablility
Summary: fix also reviewed by Alexander Fomin
Reviewed-by: alanb, coffeys, skoivu
diff -r de77043ae6b9 -r 468ec57a6844 make/com/sun/jmx/Makefile
--- jdk/make/com/sun/jmx/Makefile Tue Apr 23 09:37:31 2013 +0200
+++ jdk/make/com/sun/jmx/Makefile Tue Oct 15 15:59:47 2013 +0100
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -126,11 +126,13 @@
$(RMIC) -classpath "$(CLASSDESTDIR)" \
-d $(CLASSDESTDIR) \
-iiop -v1.2 \
+ -emitPermissionCheck \
$(subst /,.,$(<:$(CLASSDESTDIR)/%.class=%))
$(RMIC) $(HOTSPOT_INTERPRETER_FLAG) -classpath "$(CLASSDESTDIR)" \
-d $(CLASSDESTDIR) \
-iiop -v1.2 \
-standardPackage \
+ -emitPermissionCheck \
$(subst /,.,$(<:$(CLASSDESTDIR)/%.class=%))
@$(java-vm-cleanup)
diff -r de77043ae6b9 -r 468ec57a6844 src/share/classes/javax/management/modelmbean/RequiredModelMBean.java
--- jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Apr 23 09:37:31 2013 +0200
+++ jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Oct 15 15:59:47 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -299,11 +299,15 @@
RequiredModelMBean.class.getName(),
"setModelMBeanInfo(ModelMBeanInfo)",
"Setting ModelMBeanInfo to " + printModelMBeanInfo(mbi));
+ int noOfNotifications = 0;
+ if (mbi.getNotifications() != null) {
+ noOfNotifications = mbi.getNotifications().length;
+ }
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setModelMBeanInfo(ModelMBeanInfo)",
"ModelMBeanInfo notifications has " +
- (mbi.getNotifications()).length + " elements");
+ noOfNotifications + " elements");
}
modelMBeanInfo = (ModelMBeanInfo)mbi.clone();
@@ -3001,4 +3005,5 @@
Void.class.getName()
};
}
+
}
diff -r de77043ae6b9 -r 468ec57a6844 src/share/classes/javax/management/remote/rmi/RMIConnector.java
--- jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java Tue Apr 23 09:37:31 2013 +0200
+++ jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java Tue Oct 15 15:59:47 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -60,6 +60,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
import java.security.ProtectionDomain;
import java.util.Arrays;
import java.util.Collections;
@@ -241,10 +242,21 @@
//--------------------------------------------------------------------
// implements JMXConnector interface
//--------------------------------------------------------------------
+
+ /**
+ * @throws IOException if the connection could not be made because of a
+ * communication problem, or in the case of the {@code iiop} protocol,
+ * that RMI/IIOP is not supported
+ */
public void connect() throws IOException {
connect(null);
}
+ /**
+ * @throws IOException if the connection could not be made because of a
+ * communication problem, or in the case of the {@code iiop} protocol,
+ * that RMI/IIOP is not supported
+ */
public synchronized void connect(Map<String,?> environment)
throws IOException {
final boolean tracing = logger.traceOn();
@@ -2334,7 +2346,16 @@
private static RMIConnection shadowIiopStub(Stub stub)
throws InstantiationException, IllegalAccessException {
- Stub proxyStub = (Stub) proxyStubClass.newInstance();
+ Stub proxyStub = null;
+ try {
+ proxyStub = AccessController.doPrivileged(new PrivilegedExceptionAction<Stub>() {
+ public Stub run() throws Exception {
+ return (Stub) proxyStubClass.newInstance();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new InternalError();
+ }
proxyStub._set_delegate(stub._get_delegate());
return (RMIConnection) proxyStub;
}

View File

@ -0,0 +1,183 @@
# HG changeset patch
# User msheppar
# Date 1381847065 -3600
# Tue Oct 15 15:24:25 2013 +0100
# Node ID 9e7e1b6ab5cdf0096c9c16d991e6a982771a15f1
# Parent 14308db8214e69d7cad09a8f4d49d421b5b13ba0
8011157: Improve CORBA portablility
Summary: fix also reviewed by Alexander Fomin
Reviewed-by: alanb, coffeys, skoivu
diff -r 14308db8214e -r 9e7e1b6ab5cd src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java
--- corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Mon Jun 17 19:01:08 2013 +0200
+++ corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Tue Oct 15 15:24:25 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -54,7 +54,7 @@
/**
* @author Harold Carr
*/
-public class SelectorImpl
+class SelectorImpl
extends
Thread
implements
diff -r 14308db8214e -r 9e7e1b6ab5cd src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java
--- corba/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Mon Jun 17 19:01:08 2013 +0200
+++ corba/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Tue Oct 15 15:24:25 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -34,6 +34,9 @@
import java.io.File;
import java.io.IOException;
+import java.io.SerializablePermission;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
@@ -49,6 +52,7 @@
import com.sun.corba.se.impl.util.PackagePrefixChecker;
import sun.rmi.rmic.Main;
+
/**
* An IIOP stub/tie generator for rmic.
*
@@ -78,6 +82,7 @@
protected boolean castArray = false;
protected Hashtable transactionalObjects = new Hashtable() ;
protected boolean POATie = false ;
+ protected boolean emitPermissionCheck = false;
/**
* Default constructor for Main to use.
@@ -193,6 +198,9 @@
} else if (argv[i].equals("-standardPackage")) {
standardPackage = true;
argv[i] = null;
+ } else if (argv[i].equals("-emitPermissionCheck")) {
+ emitPermissionCheck = true;
+ argv[i] = null;
} else if (arg.equals("-xstubbase")) {
argv[i] = null;
if (++i < argv.length && argv[i] != null && !argv[i].startsWith("-")) {
@@ -390,9 +398,22 @@
writePackageAndImports(p);
+// generate
+// import java.security.AccessController;
+// import java.security.PrivilegedAction;
+// import java.io.SerializablePermission;
+ if (emitPermissionCheck) {
+ p.pln("import java.security.AccessController;");
+ p.pln("import java.security.PrivilegedAction;");
+ p.pln("import java.io.SerializablePermission;");
+ p.pln();
+ p.pln();
+ }
+
// Declare the stub class; implement all remote interfaces.
p.p("public class " + currentClass);
+
p.p(" extends " + getName(stubBaseClass));
p.p(" implements ");
if (remoteInterfaces.length > 0) {
@@ -422,6 +443,56 @@
writeIds( p, theType, false );
p.pln();
+ if (emitPermissionCheck) {
+
+ // produce the following generated code
+ // private static Void checkPermission() {
+ // SecurityManager sm = System.getSecurityManager();
+ // if (sm != null) {
+ // sm.checkPermission(new SerializablePermission(
+ // "enableSubclassImplementation")); // testing
+ // }
+ // return null;
+ // }
+ //
+ // private _XXXXXX_Stub(Void ignore) {
+ // }
+ //
+ // public _XXXXXX_Stub() {
+ // this(checkPermission());
+ // }
+ // where XXXXXX is the name of the remote interface
+
+ p.pln();
+ p.plnI("private static Void checkPermission() {");
+ p.plnI("SecurityManager sm = System.getSecurityManager();");
+ p.pln("if (sm != null) {");
+ p.pI();
+ p.plnI("sm.checkPermission(new SerializablePermission(");
+ p.plnI("\"enableSubclassImplementation\"));");
+ p.pO();
+ p.pO();
+ p.pOln("}");
+ p.pln("return null;");
+ p.pO();
+ p.pOln("}");
+ p.pln();
+ p.pO();
+
+ p.pI();
+ p.pln("private " + currentClass + "(Void ignore) { }");
+ p.pln();
+
+ p.plnI("public " + currentClass + "() { ");
+ p.pln("this(checkPermission());");
+ p.pOln("}");
+ p.pln();
+ }
+
+ if (!emitPermissionCheck) {
+ p.pI();
+ }
+
// Write the _ids() method...
p.plnI("public String[] _ids() { ");
@@ -815,7 +886,6 @@
CompoundType theType) throws IOException {
// Wtite the method declaration and opening brace...
-
String methodName = method.getName();
String methodIDLName = method.getIDLName();
@@ -1631,7 +1701,7 @@
// Write data members...
p.pln();
- p.pln("private " + getName(theType) + " target = null;");
+ p.pln("volatile private " + getName(theType) + " target = null;");
p.pln();
// Write the ids...
@@ -1695,6 +1765,10 @@
if (remoteMethods.length > 0) {
p.plnI("try {");
+ p.pln(getName(theType) + " target = this.target;");
+ p.plnI("if (target == null) {");
+ p.pln("throw new java.io.IOException();");
+ p.pOln("}");
p.plnI(idExtInputStream + " "+in+" = ");
p.pln("(" + idExtInputStream + ") "+_in+";");
p.pO();

View File

@ -0,0 +1,58 @@
# HG changeset patch
# User jgish
# Date 1366144454 14400
# Tue Apr 16 16:34:14 2013 -0400
# Node ID a7048970934a1425d5486e6acd0b07558be038c4
# Parent ed410e3d08fe7792e6c08e411580564d2562c03e
8011990: TEST_BUG: java/util/logging/bundlesearch/ResourceBundleSearchTest.java fails on Windows
Summary: Fix URL to reliably work on all platforms
Reviewed-by: duke
diff -r ed410e3d08fe -r a7048970934a test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java
--- jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Fri Apr 19 16:50:10 2013 -0700
+++ jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Tue Apr 16 16:34:14 2013 -0400
@@ -21,6 +21,7 @@
* questions.
*/
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
@@ -45,11 +46,13 @@
String testClassesDir = System.getProperty("test.classes",
System.getProperty("user.dir"));
String sep = System.getProperty("file.separator");
+
URL[] urls = new URL[2];
// Allow for both jtreg and standalone cases here
- urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
- urls[1] = new URL("file://" + testClassesDir + sep );
+ urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
+ urls[1] = new File( testClassesDir + sep ).toURI().toURL();
+
System.out.println("INFO: urls[0] = " + urls[0]);
System.out.println("INFO: urls[1] = " + urls[1]);
diff -r ed410e3d08fe -r a7048970934a test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
--- jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Fri Apr 19 16:50:10 2013 -0700
+++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Tue Apr 16 16:34:14 2013 -0400
@@ -29,6 +29,7 @@
* @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp
* @run main ResourceBundleSearchTest
*/
+import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -70,7 +71,8 @@
String sep = System.getProperty("file.separator");
URL[] urls = new URL[1];
- urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
+
+ urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
URLClassLoader rbClassLoader = new URLClassLoader(urls);
// Test 1 - can we find a Logger bundle from doing a stack search?

View File

@ -0,0 +1,87 @@
# HG changeset patch
# User malenkov
# Date 1381850636 -3600
# Tue Oct 15 16:23:56 2013 +0100
# Node ID 7a6de63e89636f3bfb5b32e2a8d1ea3df1fe2d79
# Parent 468ec57a684409e4c7ed97be8ffa36322fb8a36b
8012071: Better Building of Beans
Reviewed-by: art, skoivu
diff -r 468ec57a6844 -r 7a6de63e8963 src/share/classes/java/beans/Beans.java
--- jdk/src/share/classes/java/beans/Beans.java Tue Oct 15 15:59:47 2013 +0100
+++ jdk/src/share/classes/java/beans/Beans.java Tue Oct 15 16:23:56 2013 +0100
@@ -42,6 +42,8 @@
import java.io.ObjectStreamClass;
import java.io.StreamCorruptedException;
+import java.lang.reflect.Modifier;
+
import java.net.URL;
import java.security.AccessController;
@@ -222,6 +224,10 @@
throw ex;
}
+ if (!Modifier.isPublic(cl.getModifiers())) {
+ throw new ClassNotFoundException("" + cl + " : no public access");
+ }
+
/*
* Try to instantiate the class.
*/
diff -r 468ec57a6844 -r 7a6de63e8963 src/share/classes/java/beans/DefaultPersistenceDelegate.java
--- jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Oct 15 15:59:47 2013 +0100
+++ jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Oct 15 16:23:56 2013 +0100
@@ -235,6 +235,9 @@
for(int i = 0; i < a.length; i = i + 3) {
try {
Field f = type.getField((String)a[i]);
+ if (!ReflectUtil.isPackageAccessible(f.getDeclaringClass())) {
+ continue;
+ }
if (f.get(null).equals(oldValue)) {
out.remove(oldValue);
out.writeExpression(new Expression(oldValue, f, "get", new Object[]{null}));
diff -r 468ec57a6844 -r 7a6de63e8963 src/share/classes/java/beans/MetaData.java
--- jdk/src/share/classes/java/beans/MetaData.java Tue Oct 15 15:59:47 2013 +0100
+++ jdk/src/share/classes/java/beans/MetaData.java Tue Oct 15 16:23:56 2013 +0100
@@ -40,6 +40,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -47,6 +48,7 @@
import java.sql.Timestamp;
import java.util.*;
+import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
import javax.swing.Box;
import javax.swing.JLayeredPane;
@@ -907,13 +909,15 @@
class StaticFieldsPersistenceDelegate extends PersistenceDelegate {
protected void installFields(Encoder out, Class<?> cls) {
- Field fields[] = cls.getFields();
- for(int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- // Don't install primitives, their identity will not be preserved
- // by wrapping.
- if (Object.class.isAssignableFrom(field.getType())) {
- out.writeExpression(new Expression(field, "get", new Object[]{null}));
+ if (Modifier.isPublic(cls.getModifiers()) && isPackageAccessible(cls)) {
+ Field fields[] = cls.getFields();
+ for(int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ // Don't install primitives, their identity will not be preserved
+ // by wrapping.
+ if (Object.class.isAssignableFrom(field.getType())) {
+ out.writeExpression(new Expression(field, "get", new Object[]{null}));
+ }
}
}
}

View File

@ -0,0 +1,55 @@
# HG changeset patch
# User erikj
# Date 1381850834 -3600
# Tue Oct 15 16:27:14 2013 +0100
# Node ID 8521d2f3d9640e6516d8b71aa2f553bc4028362f
# Parent 7a6de63e89636f3bfb5b32e2a8d1ea3df1fe2d79
8012147: Improve tool support
Summary: Adding libjli to jdk lib dir and removing now redundant rpath entries from executables
Reviewed-by: alanb, dholmes, ksrini, ahgross
diff -r 7a6de63e8963 -r 8521d2f3d964 make/common/Program.gmk
--- jdk/make/common/Program.gmk Tue Oct 15 16:23:56 2013 +0100
+++ jdk/make/common/Program.gmk Tue Oct 15 16:27:14 2013 +0100
@@ -78,17 +78,14 @@
ifeq ($(PLATFORM), solaris)
ifeq ($(ARCH_DATA_MODEL), 32)
LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli
- LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli
else
LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli
- LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli
endif
endif
ifeq ($(PLATFORM), linux)
LDFLAGS += -Wl,-z -Wl,origin
LDFLAGS += -Wl,--allow-shlib-undefined
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
- LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
endif
endif
ifeq ($(PLATFORM), windows)
diff -r 7a6de63e8963 -r 8521d2f3d964 make/common/Release.gmk
--- jdk/make/common/Release.gmk Tue Oct 15 16:23:56 2013 +0100
+++ jdk/make/common/Release.gmk Tue Oct 15 16:27:14 2013 +0100
@@ -855,6 +855,11 @@
| $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre )
$(RM) -rf $(JDK_IMAGE_DIR)/jre/man
$(CHMOD) a+rx `$(FIND) $(JDK_IMAGE_DIR) -type d`
+ ifneq (,$(findstring $(PLATFORM), linux solaris)) # If linux or solaris
+ ($(CD) $(LIBDIR)/.. && $(TAR) cf - \
+ `$(FIND) lib -name $(LIB_PREFIX)jli.$(LIB_SUFFIX) -print `) | \
+ ($(CD) $(JDK_IMAGE_DIR) && $(TAR) xf -)
+ endif # PLATFORM
initial-image-jdk64-bindemos:
for dir in bin demo ; do \
@@ -891,7 +896,7 @@
initial-image-jdk:: initial-image-jdk-setup \
initial-image-jdk-db \
$(JDK_LICENSES) $(JDK_DOCFILES)
- $(MKDIR) $(JDK_IMAGE_DIR)/lib
+ $(MKDIR) -p $(JDK_IMAGE_DIR)/lib
@#
@# Copy in the jars in lib that only belong in the JDK
@#

View File

@ -0,0 +1,45 @@
# HG changeset patch
# User dfuchs
# Date 1367362161 -7200
# Wed May 01 00:49:21 2013 +0200
# Node ID 47c881c5439a4542b19ab85f376e94fc2c0a5a57
# Parent 0bf55b4c8a7bbea02a9d848b2a5451adbd6a6ac4
8012243: about 30% regression on specjvm2008.serial on 7u25 comparing 7u21
Reviewed-by: alanb, skoivu, smarks, mchung
diff -r 0bf55b4c8a7b -r 47c881c5439a src/share/classes/java/io/ObjectStreamClass.java
--- jdk/src/share/classes/java/io/ObjectStreamClass.java Fri May 17 14:29:51 2013 -0700
+++ jdk/src/share/classes/java/io/ObjectStreamClass.java Wed May 01 00:49:21 2013 +0200
@@ -241,9 +241,11 @@
if (cl == null) {
return null;
}
- Class<?> caller = Reflection.getCallerClass();
- if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
- ReflectUtil.checkPackageAccess(cl);
+ if (System.getSecurityManager() != null) {
+ Class<?> caller = Reflection.getCallerClass();
+ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
+ ReflectUtil.checkPackageAccess(cl);
+ }
}
return cl;
}
diff -r 0bf55b4c8a7b -r 47c881c5439a src/share/classes/java/io/ObjectStreamField.java
--- jdk/src/share/classes/java/io/ObjectStreamField.java Fri May 17 14:29:51 2013 -0700
+++ jdk/src/share/classes/java/io/ObjectStreamField.java Wed May 01 00:49:21 2013 +0200
@@ -162,9 +162,11 @@
*/
@CallerSensitive
public Class<?> getType() {
- Class<?> caller = Reflection.getCallerClass();
- if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
- ReflectUtil.checkPackageAccess(type);
+ if (System.getSecurityManager() != null) {
+ Class<?> caller = Reflection.getCallerClass();
+ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
+ ReflectUtil.checkPackageAccess(type);
+ }
}
return type;
}

View File

@ -0,0 +1,83 @@
# HG changeset patch
# User malenkov
# Date 1370018612 -14400
# Fri May 31 20:43:32 2013 +0400
# Node ID 337232ddaec36c6d9843ff35906e6160446844eb
# Parent 8521d2f3d9640e6516d8b71aa2f553bc4028362f
8012277: Improve AWT DataFlavor
Reviewed-by: art, skoivu
diff -r 8521d2f3d964 -r 337232ddaec3 src/share/classes/java/awt/datatransfer/DataFlavor.java
--- jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Tue Oct 15 16:27:14 2013 +0100
+++ jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Fri May 31 20:43:32 2013 +0400
@@ -25,12 +25,14 @@
package java.awt.datatransfer;
-import java.awt.Toolkit;
import java.io.*;
import java.nio.*;
import java.util.*;
import sun.awt.datatransfer.DataTransferer;
+import sun.reflect.misc.ReflectUtil;
+
+import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
/**
* A {@code DataFlavor} provides meta information about data. {@code DataFlavor}
@@ -117,26 +119,36 @@
ClassLoader fallback)
throws ClassNotFoundException
{
- ClassLoader systemClassLoader = (ClassLoader)
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- ClassLoader cl = Thread.currentThread().
- getContextClassLoader();
- return (cl != null)
- ? cl
- : ClassLoader.getSystemClassLoader();
+ ReflectUtil.checkPackageAccess(className);
+ try {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(GET_CLASSLOADER_PERMISSION);
+ }
+ ClassLoader loader = ClassLoader.getSystemClassLoader();
+ try {
+ // bootstrap class loader and system class loader if present
+ return Class.forName(className, true, loader);
+ }
+ catch (ClassNotFoundException exception) {
+ // thread context class loader if and only if present
+ loader = Thread.currentThread().getContextClassLoader();
+ if (loader != null) {
+ try {
+ return Class.forName(className, true, loader);
}
- });
-
- try {
- return Class.forName(className, true, systemClassLoader);
- } catch (ClassNotFoundException e2) {
- if (fallback != null) {
- return Class.forName(className, true, fallback);
- } else {
- throw new ClassNotFoundException(className);
+ catch (ClassNotFoundException e) {
+ // fallback to user's class loader
+ }
+ }
}
+ } catch (SecurityException exception) {
+ // ignore secured class loaders
+ }
+ if (fallback != null) {
+ return Class.forName(className, true, fallback);
+ } else {
+ throw new ClassNotFoundException(className);
}
}

View File

@ -0,0 +1,380 @@
# HG changeset patch
# User joehw
# Date 1383025844 0
# Tue Oct 29 05:50:44 2013 +0000
# Node ID 7799c3bd00f5a4fda6448cb8bcd7768c66ec166d
# Parent b5b1d1fa4bb4fcd8bc0602fd4f3523fe24d9f00b
8012425: Transform TransformerFactory
Reviewed-by: alanb, dfuchs, mullan
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Tue Oct 29 05:50:44 2013 +0000
@@ -40,6 +40,7 @@
import java.util.Vector;
import java.lang.reflect.Constructor;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -251,6 +252,7 @@
_propertiesClone = (Properties) _properties.clone();
_indentNumber = indentNumber;
_tfactory = tfactory;
+ _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
//_isIncremental = tfactory._incremental;
}
@@ -266,6 +268,7 @@
*/
public void setSecureProcessing(boolean flag) {
_isSecureProcessing = flag;
+ _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
}
/**
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java Tue Oct 29 05:50:44 2013 +0000
@@ -104,6 +104,13 @@
if (reader == null) {
try {
reader= XMLReaderFactory.createXMLReader();
+ try {
+ reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
+ xsltc.isSecureProcessing());
+ } catch (SAXNotRecognizedException e) {
+ System.err.println("Warning: " + reader.getClass().getName() + ": "
+ + e.getMessage());
+ }
} catch (Exception e ) {
try {
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 05:50:44 2013 +0000
@@ -20,9 +20,18 @@
package com.sun.org.apache.xerces.internal.jaxp.validation;
+import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
+import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
+import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import java.lang.ref.SoftReference;
import java.io.IOException;
-
+import javax.xml.XMLConstants;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXTransformerFactory;
@@ -32,15 +41,6 @@
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
-
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
-import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
-import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
-import com.sun.org.apache.xerces.internal.xni.XNIException;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
-import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import org.xml.sax.SAXException;
/**
@@ -84,6 +84,11 @@
private static final String VALIDATION_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+
+ /** Property id: security manager. */
+ private static final String SECURITY_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
+
//
// Data
//
@@ -161,6 +166,9 @@
private XMLParserConfiguration initialize() {
XML11Configuration config = new XML11Configuration();
+ if (fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ config.setProperty(SECURITY_MANAGER, new SecurityManager());
+ }
config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER);
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Oct 29 05:50:44 2013 +0000
@@ -672,6 +672,8 @@
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
try {
+ spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
+ fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
reader = spf.newSAXParser().getXMLReader();
// If this is a Xerces SAX parser, set the security manager if there is one
if (reader instanceof com.sun.org.apache.xerces.internal.parsers.SAXParser) {
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Tue Oct 29 05:50:44 2013 +0000
@@ -20,15 +20,12 @@
package com.sun.org.apache.xerces.internal.parsers;
-import java.io.IOException;
-import java.util.Locale;
-
import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
+import com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper;
import com.sun.org.apache.xerces.internal.util.EntityResolverWrapper;
-import com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper;
import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
@@ -47,15 +44,17 @@
import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
+import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
+import java.io.IOException;
+import java.util.Locale;
+import javax.xml.XMLConstants;
import org.xml.sax.AttributeList;
-import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.DocumentHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -129,6 +128,10 @@
protected static final String DOM_NODE =
Constants.SAX_PROPERTY_PREFIX + Constants.DOM_NODE_PROPERTY;
+ /** Property id: security manager. */
+ private static final String SECURITY_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
+
/** Recognized properties. */
private static final String[] RECOGNIZED_PROPERTIES = {
LEXICAL_HANDLER,
@@ -1643,19 +1646,13 @@
// Drop through and perform default processing
//
}
-
- //
- // Xerces Features
- //
-
- /*
- else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
- String feature = featureId.substring(XERCES_FEATURES_PREFIX.length());
- //
- // Drop through and perform default processing
- //
+ else if (featureId.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ if (state) {
+ if (fConfiguration.getProperty(SECURITY_MANAGER )==null) {
+ fConfiguration.setProperty(SECURITY_MANAGER, new SecurityManager());
+ }
+ }
}
- */
//
// Default handling
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Oct 29 05:50:44 2013 +0000
@@ -20,11 +20,6 @@
package com.sun.org.apache.xerces.internal.parsers;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Locale;
-
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XML11DTDScannerImpl;
import com.sun.org.apache.xerces.internal.impl.XML11DocumentScannerImpl;
@@ -65,6 +60,11 @@
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+import javax.xml.XMLConstants;
/**
* This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
@@ -428,30 +428,30 @@
XMLGrammarPool grammarPool,
XMLComponentManager parentSettings) {
- super(parentSettings);
+ super(parentSettings);
- // create a vector to hold all the components in use
- // XML 1.0 specialized components
- fComponents = new ArrayList();
- // XML 1.1 specialized components
- fXML11Components = new ArrayList();
- // Common components for XML 1.1. and XML 1.0
- fCommonComponents = new ArrayList();
+ // create a vector to hold all the components in use
+ // XML 1.0 specialized components
+ fComponents = new ArrayList();
+ // XML 1.1 specialized components
+ fXML11Components = new ArrayList();
+ // Common components for XML 1.1. and XML 1.0
+ fCommonComponents = new ArrayList();
- // create storage for recognized features and properties
- fRecognizedFeatures = new ArrayList();
- fRecognizedProperties = new ArrayList();
-
- // create table for features and properties
- fFeatures = new HashMap();
- fProperties = new HashMap();
+ // create storage for recognized features and properties
+ fRecognizedFeatures = new ArrayList();
+ fRecognizedProperties = new ArrayList();
+
+ // create table for features and properties
+ fFeatures = new HashMap();
+ fProperties = new HashMap();
// add default recognized features
final String[] recognizedFeatures =
{
CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
- VALIDATION,
- NAMESPACES,
+ VALIDATION,
+ NAMESPACES,
NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
HONOUR_ALL_SCHEMALOCATIONS, USE_GRAMMAR_POOL_ONLY,
@@ -460,26 +460,29 @@
// features might not have been set and it would cause a
// not-recognized exception to be thrown. -Ac
XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING,
- EXTERNAL_GENERAL_ENTITIES,
- EXTERNAL_PARAMETER_ENTITIES,
- PARSER_SETTINGS
+ EXTERNAL_GENERAL_ENTITIES,
+ EXTERNAL_PARAMETER_ENTITIES,
+ PARSER_SETTINGS,
+ XMLConstants.FEATURE_SECURE_PROCESSING
};
+
addRecognizedFeatures(recognizedFeatures);
// set state for default features
- fFeatures.put(VALIDATION, Boolean.FALSE);
- fFeatures.put(NAMESPACES, Boolean.TRUE);
- fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
- fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
- fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
- fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
- fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
- fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
- fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
+ fFeatures.put(VALIDATION, Boolean.FALSE);
+ fFeatures.put(NAMESPACES, Boolean.TRUE);
+ fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
+ fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
+ fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
+ fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
+ fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
+ fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
+ fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE);
- fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
+ fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
+ fFeatures.put(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
// add default recognized properties
final String[] recognizedProperties =
diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java Thu Oct 10 16:18:30 2013 +0100
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java Tue Oct 29 05:50:44 2013 +0000
@@ -24,6 +24,7 @@
import java.util.HashMap;
+import javax.xml.XMLConstants;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
@@ -31,6 +32,7 @@
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
/**
* Creates XMLReader objects and caches them for re-use.
@@ -60,6 +62,8 @@
*/
private HashMap m_inUse;
+
+ private boolean _secureProcessing;
/**
* Hidden constructor
*/
@@ -109,7 +113,12 @@
// TransformerFactory creates a reader via the
// XMLReaderFactory if setXMLReader is not used
reader = XMLReaderFactory.createXMLReader();
-
+ try {
+ reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _secureProcessing);
+ } catch (SAXNotRecognizedException e) {
+ System.err.println("Warning: " + reader.getClass().getName() + ": "
+ + e.getMessage());
+ }
} catch (Exception e) {
try {
// If unable to create an instance, let's try to use
@@ -150,6 +159,15 @@
return reader;
}
+ /**
+ * Set feature
+ */
+ public void setFeature(String name, boolean value) {
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ _secureProcessing = value;
+ }
+ }
+
/**
* Mark the cached XMLReader as available. If the reader was not
* actually in the cache, do nothing.

View File

@ -0,0 +1,383 @@
# HG changeset patch
# User uta
# Date 1383008821 0
# Tue Oct 29 01:07:01 2013 +0000
# Node ID 20c88fd14959c6a4df2e0f36bd759b56efa6f2cb
# Parent 3e758b40337ef9da5ad030d0ac60ab4407357277
8012453: (process) Runtime.exec(String) fails if command contains spaces [win]
Reviewed-by: alanb
diff -r 3e758b40337e -r 20c88fd14959 src/share/classes/java/lang/ProcessBuilder.java
--- jdk/src/share/classes/java/lang/ProcessBuilder.java Tue Jul 30 17:20:22 2013 -0400
+++ jdk/src/share/classes/java/lang/ProcessBuilder.java Tue Oct 29 01:07:01 2013 +0000
@@ -490,6 +490,15 @@
+ (dir == null ? "" : " (in directory \"" + dir + "\")")
+ exceptionInfo,
cause);
+ } catch (IllegalArgumentException e) {
+ String exceptionInfo = ": " + e.getMessage();
+ // It's much easier for us to create a high-quality error
+ // message than the low-level C code which found the problem.
+ throw new IOException(
+ "Cannot run program \"" + prog + "\""
+ + (dir == null ? "" : " (in directory \"" + dir + "\")")
+ + exceptionInfo,
+ e);
}
}
}
diff -r 3e758b40337e -r 20c88fd14959 src/windows/classes/java/lang/ProcessImpl.java
--- jdk/src/windows/classes/java/lang/ProcessImpl.java Tue Jul 30 17:20:22 2013 -0400
+++ jdk/src/windows/classes/java/lang/ProcessImpl.java Tue Oct 29 01:07:01 2013 +0000
@@ -26,6 +26,9 @@
package java.lang;
import java.io.*;
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/* This class is for the exclusive use of ProcessBuilder.start() to
* create new processes.
@@ -47,6 +50,66 @@
return new ProcessImpl(cmdarray, envblock, dir, redirectErrorStream);
}
+ private static class LazyPattern {
+ // Escape-support version:
+ // "(\")((?:\\\\\\1|.)+?)\\1|([^\\s\"]+)";
+ private static final Pattern PATTERN =
+ Pattern.compile("[^\\s\"]+|\"[^\"]*\"");
+ };
+
+ /* Parses the command string parameter into the executable name and
+ * program arguments.
+ *
+ * The command string is broken into tokens. The token separator is a space
+ * or quota character. The space inside quotation is not a token separator.
+ * There are no escape sequences.
+ */
+ private static String[] getTokensFromCommand(String command) {
+ ArrayList<String> matchList = new ArrayList<String>(8);
+ Matcher regexMatcher = LazyPattern.PATTERN.matcher(command);
+ while (regexMatcher.find())
+ matchList.add(regexMatcher.group());
+ return matchList.toArray(new String[matchList.size()]);
+ }
+
+ private static String createCommandLine(boolean isCmdFile,
+ final String executablePath,
+ final String cmd[])
+ {
+ StringBuilder cmdbuf = new StringBuilder(80);
+
+ cmdbuf.append(executablePath);
+
+ for (int i = 1; i < cmd.length; ++i) {
+ cmdbuf.append(' ');
+ String s = cmd[i];
+ if (needsEscaping(isCmdFile, s)) {
+ cmdbuf.append('"');
+ cmdbuf.append(s);
+
+ // The code protects the [java.exe] and console command line
+ // parser, that interprets the [\"] combination as an escape
+ // sequence for the ["] char.
+ // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
+ //
+ // If the argument is an FS path, doubling of the tail [\]
+ // char is not a problem for non-console applications.
+ //
+ // The [\"] sequence is not an escape sequence for the [cmd.exe]
+ // command line parser. The case of the [""] tail escape
+ // sequence could not be realized due to the argument validation
+ // procedure.
+ if (!isCmdFile && s.endsWith("\\")) {
+ cmdbuf.append('\\');
+ }
+ cmdbuf.append('"');
+ } else {
+ cmdbuf.append(s);
+ }
+ }
+ return cmdbuf.toString();
+ }
+
// We guarantee the only command file execution for implicit [cmd.exe] run.
// http://technet.microsoft.com/en-us/library/bb490954.aspx
private static final char CMD_BAT_ESCAPE[] = {' ', '\t', '<', '>', '&', '|', '^'};
@@ -128,6 +191,16 @@
return fileToRun.getPath();
}
+ private boolean isShellFile(String executablePath) {
+ String upPath = executablePath.toUpperCase();
+ return (upPath.endsWith(".CMD") || upPath.endsWith(".BAT"));
+ }
+
+ private String quoteString(String arg) {
+ StringBuilder argbuf = new StringBuilder(arg.length() + 2);
+ return argbuf.append('"').append(arg).append('"').toString();
+ }
+
private long handle = 0;
private FileDescriptor stdin_fd;
@@ -143,36 +216,66 @@
boolean redirectErrorStream)
throws IOException
{
- // The [executablePath] is not quoted for any case.
- String executablePath = getExecutablePath(cmd[0]);
+ String cmdstr;
+ SecurityManager security = System.getSecurityManager();
+ boolean allowAmbigousCommands = false;
+ if (security == null) {
+ String value = System.getProperty("jdk.lang.Process.allowAmbigousCommands");
+ if (value != null)
+ allowAmbigousCommands = !"false".equalsIgnoreCase(value);
+ }
+ if (allowAmbigousCommands) {
+ // Legacy mode.
- // We need to extend the argument verification procedure
- // to guarantee the only command file execution for implicit [cmd.exe]
- // run.
- String upPath = executablePath.toUpperCase();
- boolean isCmdFile = (upPath.endsWith(".CMD") || upPath.endsWith(".BAT"));
+ // Normalize path if possible.
+ String executablePath = new File(cmd[0]).getPath();
- StringBuilder cmdbuf = new StringBuilder(80);
+ // No worry about internal and unpaired ["] .
+ if (needsEscaping(false, executablePath) )
+ executablePath = quoteString(executablePath);
- // Quotation protects from interpretation of the [path] argument as
- // start of longer path with spaces. Quotation has no influence to
- // [.exe] extension heuristic.
- cmdbuf.append('"');
- cmdbuf.append(executablePath);
- cmdbuf.append('"');
+ cmdstr = createCommandLine(
+ false, //legacy mode doesn't worry about extended verification
+ executablePath,
+ cmd);
+ } else {
+ String executablePath;
+ try {
+ executablePath = getExecutablePath(cmd[0]);
+ } catch (IllegalArgumentException e) {
+ // Workaround for the calls like
+ // Runtime.getRuntime().exec("\"C:\\Program Files\\foo\" bar")
- for (int i = 1; i < cmd.length; i++) {
- cmdbuf.append(' ');
- String s = cmd[i];
- if (needsEscaping(isCmdFile, s)) {
- cmdbuf.append('"');
- cmdbuf.append(s);
- cmdbuf.append('"');
- } else {
- cmdbuf.append(s);
+ // No chance to avoid CMD/BAT injection, except to do the work
+ // right from the beginning. Otherwise we have too many corner
+ // cases from
+ // Runtime.getRuntime().exec(String[] cmd [, ...])
+ // calls with internal ["] and escape sequences.
+
+ // Restore original command line.
+ StringBuilder join = new StringBuilder();
+ // terminal space in command line is ok
+ for (String s : cmd)
+ join.append(s).append(' ');
+
+ // Parse the command line again.
+ cmd = getTokensFromCommand(join.toString());
+ executablePath = getExecutablePath(cmd[0]);
+
+ // Check new executable name once more
+ if (security != null)
+ security.checkExec(executablePath);
}
+
+ // Quotation protects from interpretation of the [path] argument as
+ // start of longer path with spaces. Quotation has no influence to
+ // [.exe] extension heuristic.
+ cmdstr = createCommandLine(
+ // We need the extended verification procedure for CMD files.
+ isShellFile(executablePath),
+ quoteString(executablePath),
+ cmd);
}
- String cmdstr = cmdbuf.toString();
stdin_fd = new FileDescriptor();
stdout_fd = new FileDescriptor();
diff -r 3e758b40337e -r 20c88fd14959 test/java/lang/Runtime/exec/ExecCommand.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/lang/Runtime/exec/ExecCommand.java Tue Oct 29 01:07:01 2013 +0000
@@ -0,0 +1,163 @@
+/*
+ * 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 8012453
+ * @run main/othervm ExecCommand
+ * @summary workaround for legacy applications with Runtime.getRuntime().exec(String command)
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.security.AccessControlException;
+
+public class ExecCommand {
+ static class SecurityMan extends SecurityManager {
+ public static String unquote(String str)
+ {
+ int length = (str == null)
+ ? 0
+ : str.length();
+
+ if (length > 1
+ && str.charAt(0) == '\"'
+ && str.charAt(length - 1) == '\"')
+ {
+ return str.substring(1, length - 1);
+ }
+ return str;
+ }
+
+ @Override public void checkExec(String cmd) {
+ String ncmd = (new File(unquote(cmd))).getPath();
+ if ( ncmd.equals(".\\Program")
+ || ncmd.equals("\".\\Program")
+ || ncmd.equals(".\\Program Files\\do.cmd")
+ || ncmd.equals(".\\Program.cmd"))
+ {
+ return;
+ }
+ super.checkExec(cmd);
+ }
+ }
+
+ // Parameters for the Runtime.exec calls
+ private static final String TEST_RTE_ARG[] = {
+ ".\\Program Files\\do.cmd",
+ "\".\\Program Files\\doNot.cmd\" arg",
+ "\".\\Program Files\\do.cmd\" arg",
+ // compatibility
+ "\".\\Program.cmd\" arg",
+ ".\\Program.cmd arg",
+ };
+
+ private static final String doCmdCopy[] = {
+ ".\\Program.cmd",
+ ".\\Program Files\\doNot.cmd",
+ ".\\Program Files\\do.cmd",
+ };
+
+ // Golden image for results
+ private static final String TEST_RTE_GI[][] = {
+ //Pure system | Legacy mode | Legacy mode & SM
+ // [.\Program File\do.cmd]
+ new String[]{"IOException", // [.\Program] not found
+ "Success",
+ "IOException"}, //SM - no legacy mode [.\Program] - OK
+
+ // [".\Program File\doNot.cmd" arg]
+ new String[]{"Success",
+ "Success",
+ "AccessControlException"}, //SM - [".\Program] - OK,
+ // [.\\Program Files\\doNot.cmd] - Fail
+
+ // [".\Program File\do.cmd" arg]
+ // AccessControlException
+ new String[]{"Success",
+ "Success",
+ "Success"}, //SM - [".\Program] - OK,
+ // [.\\Program Files\\do.cmd] - OK
+
+ // compatibility
+ new String[]{"Success", "Success", "Success"}, //[".\Program.cmd"]
+ new String[]{"Success", "Success", "Success"} //[.\Program.cmd]
+ };
+
+ public static void main(String[] _args) throws Exception {
+ if (!System.getProperty("os.name").startsWith("Windows")) {
+ return;
+ }
+
+ // tear up
+ try {
+ new File(".\\Program Files").mkdirs();
+ for (int i = 0; i < doCmdCopy.length; ++i) {
+ try (BufferedWriter outCmd = new BufferedWriter(
+ new FileWriter(doCmdCopy[i]))) {
+ outCmd.write("@echo %1");
+ }
+ }
+ } catch (IOException e) {
+ throw new Error(e.getMessage());
+ }
+
+ // action
+ for (int k = 0; k < 3; ++k) {
+ switch (k) {
+ case 1:
+ System.setProperty("jdk.lang.Process.allowAmbigousCommands", "");
+ break;
+ case 2:
+ System.setSecurityManager( new SecurityMan() );
+ break;
+ }
+ for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
+ String outRes;
+ try {
+ Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
+ exec.waitFor();
+ outRes = "Success";
+ } catch (IOException ioe) {
+ outRes = "IOException: " + ioe.getMessage();
+ } catch (IllegalArgumentException iae) {
+ outRes = "IllegalArgumentException: " + iae.getMessage();
+ } catch (AccessControlException se) {
+ outRes = "AccessControlException: " + se.getMessage();
+ }
+
+ if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
+ throw new Error("Unexpected output! Step" + k + "" + i
+ + " \nArgument: " + TEST_RTE_ARG[i]
+ + "\nExpected: " + TEST_RTE_GI[i][k]
+ + "\n Output: " + outRes);
+ } else {
+ System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
+ }
+ }
+ }
+ }
+}

View File

@ -0,0 +1,515 @@
# HG changeset patch
# User prr
# Date 1382993769 0
# Mon Oct 28 20:56:09 2013 +0000
# Node ID 150e0c3e95ce6869f8e7b42c6d8683817433e124
# Parent 9cfb9105241489a5fbc3fcfdea15a6aee15b2cfc
8012617: ArrayIndexOutOfBoundsException with some fonts using LineBreakMeasurer
Reviewed-by: bae, srl, omajid
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/classes/sun/font/ExtendedTextSourceLabel.java
--- jdk/src/share/classes/sun/font/ExtendedTextSourceLabel.java Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/classes/sun/font/ExtendedTextSourceLabel.java Mon Oct 28 20:56:09 2013 +0000
@@ -246,6 +246,10 @@
float aw = 0f;
float ah = cm.ascent + cm.descent;
+ if (charinfo == null || charinfo.length == 0) {
+ return new Rectangle2D.Float(al, at, aw, ah);
+ }
+
boolean lineIsLTR = (source.getLayoutFlags() & 0x8) == 0;
int rn = info.length - numvals;
if (lineIsLTR) {
@@ -349,24 +353,42 @@
public float getCharX(int index) {
validate(index);
- return getCharinfo()[l2v(index) * numvals + posx];
+ float[] charinfo = getCharinfo();
+ int idx = l2v(index) * numvals + posx;
+ if (charinfo == null || idx >= charinfo.length) {
+ return 0f;
+ } else {
+ return charinfo[idx];
+ }
}
public float getCharY(int index) {
validate(index);
- return getCharinfo()[l2v(index) * numvals + posy];
+ float[] charinfo = getCharinfo();
+ int idx = l2v(index) * numvals + posy;
+ if (charinfo == null || idx >= charinfo.length) {
+ return 0f;
+ } else {
+ return charinfo[idx];
+ }
}
public float getCharAdvance(int index) {
validate(index);
- return getCharinfo()[l2v(index) * numvals + advx];
+ float[] charinfo = getCharinfo();
+ int idx = l2v(index) * numvals + advx;
+ if (charinfo == null || idx >= charinfo.length) {
+ return 0f;
+ } else {
+ return charinfo[idx];
+ }
}
public Rectangle2D handleGetCharVisualBounds(int index) {
validate(index);
float[] charinfo = getCharinfo();
index = l2v(index) * numvals;
- if ((index+vish) >= charinfo.length) {
+ if (charinfo == null || (index+vish) >= charinfo.length) {
return new Rectangle2D.Float();
}
return new Rectangle2D.Float(
@@ -462,7 +484,7 @@
if (cidx >= charinfo.length) {
break; // layout bailed for some reason
}
- float adv = charinfo[l2v(start) * numvals + advx];
+ float adv = charinfo[cidx];
width -= adv;
}
@@ -511,7 +533,13 @@
// }
//}
- return getCharinfo()[v * numvals + advx] != 0;
+ int idx = v * numvals + advx;
+ float[] charinfo = getCharinfo();
+ if (charinfo == null || idx >= charinfo.length) {
+ return false;
+ } else {
+ return charinfo[idx] != 0;
+ }
}
private final float[] getCharinfo() {
@@ -603,6 +631,9 @@
*/
int numGlyphs = gv.getNumGlyphs();
+ if (numGlyphs == 0) {
+ return glyphinfo;
+ }
int[] indices = gv.getGlyphCharIndices(0, numGlyphs, null);
boolean DEBUG = false;
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/classes/sun/font/GlyphLayout.java
--- jdk/src/share/classes/sun/font/GlyphLayout.java Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/classes/sun/font/GlyphLayout.java Mon Oct 28 20:56:09 2013 +0000
@@ -76,9 +76,12 @@
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
import static java.lang.Character.*;
+import sun.java2d.SunGraphicsEnvironment;
+
public final class GlyphLayout {
// data for glyph vector
private GVData _gvdata;
@@ -461,7 +464,12 @@
break;
}
catch (IndexOutOfBoundsException e) {
- _gvdata.grow();
+ if (_gvdata._count >=0) {
+ _gvdata.grow();
+ }
+ }
+ if (_gvdata._count < 0) {
+ break;
}
}
}
@@ -470,7 +478,19 @@
// _gvdata.adjustPositions(txinfo.invdtx);
// }
- StandardGlyphVector gv = _gvdata.createGlyphVector(font, frc, result);
+ // If layout fails (negative glyph count) create an un-laid out GV instead.
+ // ie default positions. This will be a lot better than the alternative of
+ // a complete blank layout.
+ StandardGlyphVector gv;
+ if (_gvdata._count < 0) {
+ gv = new StandardGlyphVector(font, text, offset, count, frc);
+ if (SunGraphicsEnvironment.debugFonts) {
+ Logger.getLogger("sun.java2d").warning("OpenType layout failed on font: " +
+ font);
+ }
+ } else {
+ gv = _gvdata.createGlyphVector(font, frc, result);
+ }
// System.err.println("Layout returns: " + gv);
return gv;
}
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/ContextualSubstSubtables.cpp
--- jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -218,6 +218,9 @@
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
le_uint16 srSetCount = SWAPW(subRuleSetCount);
@@ -267,6 +270,9 @@
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
const ClassDefinitionTable *classDefinitionTable =
@@ -395,6 +401,9 @@
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
le_uint16 srSetCount = SWAPW(chainSubRuleSetCount);
@@ -466,6 +475,9 @@
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
const ClassDefinitionTable *backtrackClassDefinitionTable =
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp
--- jdk/src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -45,7 +45,7 @@
le_int32 coverageIndex = getGlyphCoverage(base, glyphID, success);
le_uint16 eeCount = SWAPW(entryExitCount);
- if (coverageIndex < 0 || coverageIndex >= eeCount) {
+ if (coverageIndex < 0 || coverageIndex >= eeCount || LE_FAILURE(success)) {
glyphIterator->setCursiveGlyph();
return 0;
}
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/ExtensionSubtables.cpp
--- jdk/src/share/native/sun/font/layout/ExtensionSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/ExtensionSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -44,10 +44,10 @@
#define READ_LONG(code) (le_uint32)((SWAPW(*(le_uint16*)&code) << 16) + SWAPW(*(((le_uint16*)&code) + 1)))
// FIXME: should look at the format too... maybe have a sub-class for it?
-le_uint32 ExtensionSubtable::process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
+le_uint32 ExtensionSubtable::process(const LEReferenceTo<ExtensionSubtable> &thisRef,
+ const LookupProcessor *lookupProcessor, le_uint16 lookupType,
GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
{
- const LEReferenceTo<ExtensionSubtable> thisRef(lookupProcessor->getReference(), success); // create a reference to this
if (LE_FAILURE(success)) {
return 0;
@@ -57,7 +57,7 @@
if (elt != lookupType) {
le_uint32 extOffset = READ_LONG(extensionOffset);
- LEReferenceTo<LookupSubtable> subtable(thisRef, success, extOffset);
+ LEReferenceTo<LookupSubtable> subtable(thisRef, success, extOffset);
if(LE_SUCCESS(success)) {
return lookupProcessor->applySubtable(subtable, elt, glyphIterator, fontInstance, success);
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/ExtensionSubtables.h
--- jdk/src/share/native/sun/font/layout/ExtensionSubtables.h Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/ExtensionSubtables.h Mon Oct 28 20:56:09 2013 +0000
@@ -52,7 +52,8 @@
le_uint16 extensionLookupType;
le_uint32 extensionOffset;
- le_uint32 process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
+ le_uint32 process(const LEReferenceTo<ExtensionSubtable> &extRef,
+ const LookupProcessor *lookupProcessor, le_uint16 lookupType,
GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const;
};
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp
--- jdk/src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -168,7 +168,7 @@
{
LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
- delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
+ delta = subtable->process(subtable, this, lookupType, glyphIterator, fontInstance, success);
break;
}
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/GlyphSubstLookupProc.cpp
--- jdk/src/share/native/sun/font/layout/GlyphSubstLookupProc.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/GlyphSubstLookupProc.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -139,7 +139,7 @@
{
const LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
- delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
+ delta = subtable->process(subtable, this, lookupType, glyphIterator, fontInstance, success);
break;
}
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/LigatureSubstSubtables.cpp
--- jdk/src/share/native/sun/font/layout/LigatureSubstSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/LigatureSubstSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -45,6 +45,10 @@
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
+
if (coverageIndex >= 0) {
Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset);
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp
--- jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -56,6 +56,10 @@
LEGlyphID markGlyph = glyphIterator->getCurrGlyphID();
le_int32 markCoverage = getGlyphCoverage(base, (LEGlyphID) markGlyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
+
if (markCoverage < 0) {
// markGlyph isn't a covered mark glyph
return 0;
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp
--- jdk/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -55,6 +55,10 @@
LEGlyphID markGlyph = glyphIterator->getCurrGlyphID();
le_int32 markCoverage = getGlyphCoverage(base, (LEGlyphID) markGlyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
+
if (markCoverage < 0) {
// markGlyph isn't a covered mark glyph
return 0;
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp
--- jdk/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -56,6 +56,10 @@
LEGlyphID markGlyph = glyphIterator->getCurrGlyphID();
le_int32 markCoverage = getGlyphCoverage(base, (LEGlyphID) markGlyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
+
if (markCoverage < 0) {
// markGlyph isn't a covered mark glyph
return 0;
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MultipleSubstSubtables.cpp
--- jdk/src/share/native/sun/font/layout/MultipleSubstSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/MultipleSubstSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -61,6 +61,10 @@
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
le_uint16 seqCount = SWAPW(sequenceCount);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
+
if (coverageIndex >= 0 && coverageIndex < seqCount) {
Offset sequenceTableOffset = SWAPW(sequenceTableOffsetArray[coverageIndex]);
const SequenceTable *sequenceTable = (const SequenceTable *) ((char *) this + sequenceTableOffset);
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/PairPositioningSubtables.cpp
--- jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -126,6 +126,11 @@
{
LEGlyphID firstGlyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(base, firstGlyph, success);
+
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
+
GlyphIterator tempIterator(*glyphIterator);
if (coverageIndex >= 0 && glyphIterator->next()) {
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/SinglePositioningSubtables.cpp
--- jdk/src/share/native/sun/font/layout/SinglePositioningSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/SinglePositioningSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -70,6 +70,9 @@
{
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
valueRecord.adjustPosition(SWAPW(valueFormat), (const char *) this, *glyphIterator, fontInstance);
@@ -84,6 +87,9 @@
{
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int16 coverageIndex = (le_int16) getGlyphCoverage(base, glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
valueRecordArray[0].adjustPosition(coverageIndex, SWAPW(valueFormat), (const char *) this, *glyphIterator, fontInstance);
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/SingleSubstitutionSubtables.cpp
--- jdk/src/share/native/sun/font/layout/SingleSubstitutionSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/SingleSubstitutionSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -69,6 +69,9 @@
{
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID);
@@ -87,6 +90,9 @@
{
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
+ if (LE_FAILURE(success)) {
+ return 0;
+ }
if (coverageIndex >= 0) {
TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]);
diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/SunLayoutEngine.cpp
--- jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Tue Jul 16 21:00:34 2013 +0400
+++ jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Mon Oct 28 20:56:09 2013 +0000
@@ -203,16 +203,19 @@
getFloat(env, pt, x, y);
jboolean rtl = (typo_flags & TYPO_RTL) != 0;
int glyphCount = engine->layoutChars(chars, start - min, limit - start, len, rtl, x, y, success);
- // fprintf(stderr, "sle nl len %d -> gc: %d\n", len, glyphCount); fflush(stderr);
+ // fprintf(stderr, "sle nl len %d -> gc: %d\n", len, glyphCount); fflush(stderr);
engine->getGlyphPosition(glyphCount, x, y, success);
- // fprintf(stderr, "layout glyphs: %d x: %g y: %g\n", glyphCount, x, y); fflush(stderr);
-
- if (putGV(env, gmask, baseIndex, gvdata, engine, glyphCount)) {
- // !!! hmmm, could use current value in positions array of GVData...
- putFloat(env, pt, x, y);
- }
+ // fprintf(stderr, "layout glyphs: %d x: %g y: %g\n", glyphCount, x, y); fflush(stderr);
+ if (LE_FAILURE(success)) {
+ env->SetIntField(gvdata, gvdCountFID, -1); // flag failure
+ } else {
+ if (putGV(env, gmask, baseIndex, gvdata, engine, glyphCount)) {
+ // !!! hmmm, could use current value in positions array of GVData...
+ putFloat(env, pt, x, y);
+ }
+ }
if (chars != buffer) {
free(chars);
diff -r 9cfb91052414 -r 150e0c3e95ce test/java/awt/font/LineBreakMeasurer/AllFontsLBM.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/awt/font/LineBreakMeasurer/AllFontsLBM.java Mon Oct 28 20:56:09 2013 +0000
@@ -0,0 +1,78 @@
+/*
+ * 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 8012617
+ * @summary ArrayIndexOutOfBoundsException in LineBreakMeasurer
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+import java.awt.font.*;
+import java.awt.geom.*;
+import java.text.*;
+import java.util.Hashtable;
+
+public class AllFontsLBM {
+
+ public static void main(String[] args) {
+ Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
+ for (int i=0;i<allFonts.length; i++) {
+ try {
+ Font f = allFonts[i].deriveFont(Font.PLAIN, 20);
+
+ if ( f.getFontName().startsWith("HiraKaku") ) {
+ continue;
+ }
+
+ System.out.println("Try : " + f.getFontName());
+ System.out.flush();
+ breakLines(f);
+ } catch (Exception e) {
+ System.out.println(allFonts[i]);
+ }
+ }
+ }
+
+ static void breakLines(Font font) {
+ AttributedString vanGogh = new AttributedString(
+ "Many people believe that Vincent van Gogh painted his best works " +
+ "during the two-year period he spent in Provence. Here is where he " +
+ "painted The Starry Night--which some consider to be his greatest " +
+ "work of all. However, as his artistic brilliance reached new " +
+ "heights in Provence, his physical and mental health plummeted. ",
+ new Hashtable());
+ vanGogh.addAttribute(TextAttribute.FONT, font);
+ BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2d = bi.createGraphics();
+ AttributedCharacterIterator aci = vanGogh.getIterator();
+ FontRenderContext frc = new FontRenderContext(null, false, false);
+ LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
+ lbm.setPosition(aci.getBeginIndex());
+ while (lbm.getPosition() < aci.getEndIndex()) {
+ lbm.nextLayout(100f);
+ }
+
+ }
+}

View File

@ -0,0 +1,941 @@
# HG changeset patch
# User andrew
# Date 1372305047 18000
# Wed Jun 26 22:50:47 2013 -0500
# Node ID 8733761ca20bb4e46405e274c514bda0e0616a21
# Parent a7048970934a1425d5486e6acd0b07558be038c4
8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
Summary: Use caller's classloader to load resource as an alternative to thread context classloader and system classloader
Reviewed-by: mchung, alanb
diff -r a7048970934a -r 8733761ca20b src/share/classes/java/util/logging/LogManager.java
--- jdk/src/share/classes/java/util/logging/LogManager.java Tue Apr 16 16:34:14 2013 -0400
+++ jdk/src/share/classes/java/util/logging/LogManager.java Wed Jun 26 22:50:47 2013 -0500
@@ -377,11 +377,11 @@
// add a new Logger or return the one that has been added previously
// as a LogManager subclass may override the addLogger, getLogger,
// readConfiguration, and other methods.
- Logger demandLogger(String name, String resourceBundleName) {
+ Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
Logger result = getLogger(name);
if (result == null) {
// only allocate the new logger once
- Logger newLogger = new Logger(name, resourceBundleName);
+ Logger newLogger = new Logger(name, resourceBundleName, caller);
do {
if (addLogger(newLogger)) {
// We successfully added the new Logger that we
@@ -465,7 +465,7 @@
Logger demandLogger(String name, String resourceBundleName) {
// a LogManager subclass may have its own implementation to add and
// get a Logger. So delegate to the LogManager to do the work.
- return manager.demandLogger(name, resourceBundleName);
+ return manager.demandLogger(name, resourceBundleName, null);
}
synchronized Logger findLogger(String name) {
diff -r a7048970934a -r 8733761ca20b src/share/classes/java/util/logging/Logger.java
--- jdk/src/share/classes/java/util/logging/Logger.java Tue Apr 16 16:34:14 2013 -0400
+++ jdk/src/share/classes/java/util/logging/Logger.java Wed Jun 26 22:50:47 2013 -0500
@@ -189,6 +189,7 @@
private ArrayList<LogManager.LoggerWeakRef> kids; // WeakReferences to loggers that have us as parent
private Level levelObject;
private volatile int levelValue; // current effective level value
+ private WeakReference<ClassLoader> callersClassLoaderRef;
/**
* GLOBAL_LOGGER_NAME is a name for the global logger.
@@ -244,15 +245,31 @@
* no corresponding resource can be found.
*/
protected Logger(String name, String resourceBundleName) {
+ this(name, resourceBundleName, null);
+ }
+
+ Logger(String name, String resourceBundleName, Class<?> caller) {
this.manager = LogManager.getLogManager();
- if (resourceBundleName != null) {
- // Note: we may get a MissingResourceException here.
- setupResourceInfo(resourceBundleName);
- }
+ setupResourceInfo(resourceBundleName, caller);
this.name = name;
levelValue = Level.INFO.intValue();
}
+ private void setCallersClassLoaderRef(Class<?> caller) {
+ ClassLoader callersClassLoader = ((caller != null)
+ ? caller.getClassLoader()
+ : null);
+ if (callersClassLoader != null) {
+ this.callersClassLoaderRef = new WeakReference(callersClassLoader);
+ }
+ }
+
+ private ClassLoader getCallersClassLoader() {
+ return (callersClassLoaderRef != null)
+ ? callersClassLoaderRef.get()
+ : null;
+ }
+
// This constructor is used only to create the global Logger.
// It is needed to break a cyclic dependence between the LogManager
// and Logger static initializers causing deadlocks.
@@ -306,7 +323,9 @@
return manager.demandSystemLogger(name, resourceBundleName);
}
}
- return manager.demandLogger(name, resourceBundleName);
+ return manager.demandLogger(name, resourceBundleName, caller);
+ // ends up calling new Logger(name, resourceBundleName, caller)
+ // iff the logger doesn't exist already
}
/**
@@ -382,11 +401,24 @@
*/
@CallerSensitive
public static synchronized Logger getLogger(String name, String resourceBundleName) {
- Logger result = demandLogger(name, resourceBundleName, Reflection.getCallerClass());
+ Class<?> callerClass = Reflection.getCallerClass();
+ Logger result = demandLogger(name, resourceBundleName, callerClass);
+
if (result.resourceBundleName == null) {
+ // We haven't set a bundle name yet on the Logger, so it's ok to proceed.
+
+ // We have to set the callers ClassLoader here in case demandLogger
+ // above found a previously created Logger. This can happen, for
+ // example, if Logger.getLogger(name) is called and subsequently
+ // Logger.getLogger(name, resourceBundleName) is called. In this case
+ // we won't necessarily have the correct classloader saved away, so
+ // we need to set it here, too.
+
// Note: we may get a MissingResourceException here.
- result.setupResourceInfo(resourceBundleName);
+ result.setupResourceInfo(resourceBundleName, callerClass);
} else if (!result.resourceBundleName.equals(resourceBundleName)) {
+ // We already had a bundle name on the Logger and we're trying
+ // to change it here which is not allowed.
throw new IllegalArgumentException(result.resourceBundleName +
" != " + resourceBundleName);
}
@@ -441,11 +473,13 @@
* @return a newly created private Logger
* @throws MissingResourceException if the named ResourceBundle cannot be found.
*/
+ @CallerSensitive
public static synchronized Logger getAnonymousLogger(String resourceBundleName) {
LogManager manager = LogManager.getLogManager();
// cleanup some Loggers that have been GC'ed
manager.drainLoggerRefQueueBounded();
- Logger result = new Logger(null, resourceBundleName);
+ Logger result = new Logger(null, resourceBundleName,
+ Reflection.getCallerClass());
result.anonymous = true;
Logger root = manager.getLogger("");
result.doSetParent(root);
@@ -461,7 +495,7 @@
* @return localization bundle (may be null)
*/
public ResourceBundle getResourceBundle() {
- return findResourceBundle(getResourceBundleName());
+ return findResourceBundle(getResourceBundleName(), true);
}
/**
@@ -548,7 +582,7 @@
String ebname = getEffectiveResourceBundleName();
if (ebname != null && !ebname.equals(SYSTEM_LOGGER_RB_NAME)) {
lr.setResourceBundleName(ebname);
- lr.setResourceBundle(findResourceBundle(ebname));
+ lr.setResourceBundle(findResourceBundle(ebname, true));
}
log(lr);
}
@@ -765,7 +799,7 @@
lr.setLoggerName(name);
if (rbname != null) {
lr.setResourceBundleName(rbname);
- lr.setResourceBundle(findResourceBundle(rbname));
+ lr.setResourceBundle(findResourceBundle(rbname, false));
}
log(lr);
}
@@ -789,7 +823,6 @@
* can be null
* @param msg The string message (or a key in the message catalog)
*/
-
public void logrb(Level level, String sourceClass, String sourceMethod,
String bundleName, String msg) {
if (level.intValue() < levelValue || levelValue == offValue) {
@@ -1323,9 +1356,18 @@
* there is no suitable previous cached value.
*
* @param name the ResourceBundle to locate
+ * @param userCallersClassLoader if true search using the caller's ClassLoader
* @return ResourceBundle specified by name or null if not found
*/
- private synchronized ResourceBundle findResourceBundle(String name) {
+ private synchronized ResourceBundle findResourceBundle(String name,
+ boolean useCallersClassLoader) {
+ // For all lookups, we first check the thread context class loader
+ // if it is set. If not, we use the system classloader. If we
+ // still haven't found it we use the callersClassLoaderRef if it
+ // is set and useCallersClassLoader is true. We set
+ // callersClassLoaderRef initially upon creating the logger with a
+ // non-null resource bundle name.
+
// Return a null bundle for a null name.
if (name == null) {
return null;
@@ -1358,22 +1400,52 @@
catalogLocale = currentLocale;
return catalog;
} catch (MissingResourceException ex) {
+ // We can't find the ResourceBundle in the default
+ // ClassLoader. Drop through.
+ }
+
+ if (useCallersClassLoader) {
+ // Try with the caller's ClassLoader
+ ClassLoader callersClassLoader = getCallersClassLoader();
+
+ if (callersClassLoader == null || callersClassLoader == cl) {
+ return null;
+ }
+
+ try {
+ catalog = ResourceBundle.getBundle(name, currentLocale,
+ callersClassLoader);
+ catalogName = name;
+ catalogLocale = currentLocale;
+ return catalog;
+ } catch (MissingResourceException ex) {
+ return null; // no luck
+ }
+ } else {
return null;
}
}
// Private utility method to initialize our one entry
- // resource bundle cache.
+ // resource bundle name cache and the callers ClassLoader
// Note: for consistency reasons, we are careful to check
// that a suitable ResourceBundle exists before setting the
- // ResourceBundleName.
- private synchronized void setupResourceInfo(String name) {
+ // resourceBundleName field.
+ // Synchronized to prevent races in setting the fields.
+ private synchronized void setupResourceInfo(String name,
+ Class<?> callersClass) {
if (name == null) {
return;
}
- if (findResourceBundle(name) == null) {
+
+ setCallersClassLoaderRef(callersClass);
+ if (findResourceBundle(name, true) == null) {
// We've failed to find an expected ResourceBundle.
- throw new MissingResourceException("Can't find " + name + " bundle", name, "");
+ // unset the caller's ClassLoader since we were unable to find the
+ // the bundle using it
+ this.callersClassLoaderRef = null;
+ throw new MissingResourceException("Can't find " + name + " bundle",
+ name, "");
}
resourceBundleName = name;
}
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java
--- jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Tue Apr 16 16:34:14 2013 -0400
+++ jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Wed Jun 26 22:50:47 2013 -0500
@@ -21,43 +21,28 @@
* questions.
*/
-import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.file.Paths;
+import java.util.logging.Logger;
/**
* This class is used to ensure that a resource bundle loadable by a classloader
- * is on the caller's stack, but not on the classpath or TCCL to ensure that
- * Logger.getLogger() can't load the bundle via a stack search
+ * is on the caller's stack, but not on the classpath or TCCL. It tests that
+ * Logger.getLogger() can load the bundle via the immediate caller's classloader
*
* @author Jim Gish
*/
public class IndirectlyLoadABundle {
- private final static String rbName = "StackSearchableResource";
+ private final static String rbName = "CallerSearchableResource";
public boolean loadAndTest() throws Throwable {
- // Find out where we are running from so we can setup the URLClassLoader URLs
- // test.src and test.classes will be set if running in jtreg, but probably
- // not otherwise
- String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
- String testClassesDir = System.getProperty("test.classes",
- System.getProperty("user.dir"));
- String sep = System.getProperty("file.separator");
-
- URL[] urls = new URL[2];
-
- // Allow for both jtreg and standalone cases here
- urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
- urls[1] = new File( testClassesDir + sep ).toURI().toURL();
-
- System.out.println("INFO: urls[0] = " + urls[0]);
- System.out.println("INFO: urls[1] = " + urls[1]);
-
// Make sure we can find it via the URLClassLoader
- URLClassLoader yetAnotherResourceCL = new URLClassLoader(urls, null);
+ URLClassLoader yetAnotherResourceCL = new URLClassLoader(getURLs(), null);
if (!testForValidResourceSetup(yetAnotherResourceCL)) {
throw new Exception("Couldn't directly load bundle " + rbName
+ " as expected. Test config problem");
@@ -70,23 +55,109 @@
+ " able to. Test config problem");
}
- Class<?> loadItUpClazz = Class.forName("LoadItUp", true, yetAnotherResourceCL);
+ Class<?> loadItUpClazz = Class.forName("LoadItUp1", true,
+ yetAnotherResourceCL);
ClassLoader actual = loadItUpClazz.getClassLoader();
if (actual != yetAnotherResourceCL) {
- throw new Exception("LoadItUp was loaded by an unexpected CL: " + actual);
+ throw new Exception("LoadItUp1 was loaded by an unexpected CL: " + actual);
}
Object loadItUp = loadItUpClazz.newInstance();
- Method testMethod = loadItUpClazz.getMethod("test", String.class);
+ Method testMethod = loadItUpClazz.getMethod("getLogger", String.class, String.class);
try {
- return (Boolean) testMethod.invoke(loadItUp, rbName);
+ return (Logger)testMethod.invoke(loadItUp, "NestedLogger1", rbName) != null;
} catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
}
+ public boolean testGetAnonymousLogger() throws Throwable {
+ // Test getAnonymousLogger()
+ URLClassLoader loadItUpCL = new URLClassLoader(getURLs(), null);
+ Class<?> loadItUpClazz = Class.forName("LoadItUp1", true, loadItUpCL);
+ ClassLoader actual = loadItUpClazz.getClassLoader();
+ if (actual != loadItUpCL) {
+ throw new Exception("LoadItUp1 was loaded by an unexpected CL: "
+ + actual);
+ }
+ Object loadItUpAnon = loadItUpClazz.newInstance();
+ Method testAnonMethod = loadItUpClazz.getMethod("getAnonymousLogger",
+ String.class);
+ try {
+ return (Logger)testAnonMethod.invoke(loadItUpAnon, rbName) != null;
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+
+
+ public boolean testGetLoggerGetLoggerWithBundle() throws Throwable {
+ // test getLogger("NestedLogger2"); followed by
+ // getLogger("NestedLogger2", rbName) to see if the bundle is found
+ //
+ URL[] urls = getURLs();
+ if (getLoggerWithNewCL(urls, "NestedLogger2", null)) {
+ return getLoggerWithNewCL(urls, "NestedLogger2", rbName);
+
+ } else {
+ throw new Exception("TEST FAILED: first call to getLogger() failed "
+ + " in IndirectlyLoadABundle."
+ + "testGetLoggerGetLoggerWithBundle");
+ }
+ }
+
+ private URL[] getURLs() throws MalformedURLException {
+ // Find out where we are running from so we can setup the URLClassLoader URLs
+ // test.src and test.classes will be set if running in jtreg, but probably
+ // not otherwise
+ String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
+ String testClassesDir = System.getProperty("test.classes",
+ System.getProperty("user.dir"));
+ URL[] urls = new URL[2];
+ // Allow for both jtreg and standalone cases here
+ urls[0] = Paths.get(testDir, "resources").toUri().toURL();
+ urls[1] = Paths.get(testClassesDir).toUri().toURL();
+
+ return urls;
+ }
+
+ private boolean getLoggerWithNewCL(URL[] urls, String loggerName,
+ String bundleName) throws Throwable {
+ Logger result = null;;
+ // Test getLogger("foo"); getLogger("foo", "rbName");
+ // First do the getLogger() call with no bundle name
+ URLClassLoader getLoggerCL = new URLClassLoader(urls, null);
+ Class<?> loadItUpClazz1 = Class.forName("LoadItUp1", true, getLoggerCL);
+ ClassLoader actual = loadItUpClazz1.getClassLoader();
+ if (actual != getLoggerCL) {
+ throw new Exception("LoadItUp1 was loaded by an unexpected CL: "
+ + actual);
+ }
+ Object loadItUp1 = loadItUpClazz1.newInstance();
+ if (bundleName != null) {
+ Method getLoggerMethod = loadItUpClazz1.getMethod("getLogger",
+ String.class,
+ String.class);
+ try {
+ result = (Logger) getLoggerMethod.invoke(loadItUp1, loggerName,
+ bundleName);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ } else {
+ Method getLoggerMethod = loadItUpClazz1.getMethod("getLogger",
+ String.class);
+ try {
+ result = (Logger) getLoggerMethod.invoke(loadItUp1, loggerName);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+ return result != null;
+ }
+
private boolean testForValidResourceSetup(ClassLoader cl) {
- // First make sure the test environment is setup properly and the bundle actually
- // exists
+ // First make sure the test environment is setup properly and the bundle
+ // actually exists
return ResourceBundleSearchTest.isOnClassPath(rbName, cl);
}
}
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/LoadItUp.java
--- jdk/test/java/util/logging/bundlesearch/LoadItUp.java Tue Apr 16 16:34:14 2013 -0400
+++ jdk/test/java/util/logging/bundlesearch/LoadItUp.java Wed Jun 26 22:50:47 2013 -0500
@@ -20,43 +20,30 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-import java.util.MissingResourceException;
import java.util.logging.Logger;
/*
- * This class is loaded onto the call stack when the test method is called
- * and then its classloader can be used to find a property bundle in the same
- * directory as the class. However, Logger is not allowed
+ * This class is loaded onto the call stack when the getLogger methods are
+ * called and then the classes classloader can be used to find a bundle in
+ * the same directory as the class. However, Logger is not allowed
* to find the bundle by looking up the stack for this classloader.
* We verify that this cannot happen.
*
* @author Jim Gish
*/
-public class LoadItUp {
-
- private final static boolean DEBUG = false;
-
- public Boolean test(String rbName) throws Exception {
+public class LoadItUp1 {
+ public Logger getAnonymousLogger(String rbName) throws Exception {
// we should not be able to find the resource in this directory via
// getLogger calls. The only way that would be possible given this setup
// is that if Logger.getLogger searched up the call stack
- return lookupBundle(rbName);
+ return Logger.getAnonymousLogger(rbName);
}
- private boolean lookupBundle(String rbName) {
- // See if Logger.getLogger can find the resource in this directory
- try {
- Logger aLogger = Logger.getLogger("NestedLogger", rbName);
- } catch (MissingResourceException re) {
- if (DEBUG) {
- System.out.println(
- "As expected, LoadItUp.lookupBundle() did not find the bundle "
- + rbName);
- }
- return false;
- }
- System.out.println("FAILED: LoadItUp.lookupBundle() found the bundle "
- + rbName + " using a stack search.");
- return true;
+ public Logger getLogger(String loggerName) {
+ return Logger.getLogger(loggerName);
+ }
+
+ public Logger getLogger(String loggerName,String bundleName) {
+ return Logger.getLogger(loggerName, bundleName);
}
}
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/LoadItUp2.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/LoadItUp2.java Wed Jun 26 22:50:47 2013 -0500
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+import java.util.MissingResourceException;
+import java.util.logging.Logger;
+
+/*
+ * This class is loaded onto the call stack by LoadItUp2Invoker from a separate
+ * classloader. LoadItUp2Invoker was loaded by a class loader that does have
+ * access to the bundle, but the class loader used to load this class does not.
+ * Thus the logging code should not be able to see the resource bundle unless
+ * it has more than a single level stack crawl, which is not allowed.
+ *
+ * @author Jim Gish
+ */
+public class LoadItUp2 {
+
+ private final static boolean DEBUG = false;
+
+ public Boolean test(String rbName) throws Exception {
+ // we should not be able to find the resource in this directory via
+ // getLogger calls. The only way that would be possible given this setup
+ // is that if Logger.getLogger searched up the call stack
+ return lookupBundle(rbName);
+ }
+
+ private boolean lookupBundle(String rbName) {
+ // See if Logger.getLogger can find the resource in this directory
+ try {
+ Logger aLogger = Logger.getLogger("NestedLogger2", rbName);
+ } catch (MissingResourceException re) {
+ if (DEBUG) {
+ System.out.println(
+ "As expected, LoadItUp2.lookupBundle() did not find the bundle "
+ + rbName);
+ }
+ return false;
+ }
+ System.out.println("FAILED: LoadItUp2.lookupBundle() found the bundle "
+ + rbName + " using a stack search.");
+ return true;
+ }
+}
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/LoadItUp2Invoker.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/LoadItUp2Invoker.java Wed Jun 26 22:50:47 2013 -0500
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * This class is loaded by a class loader that can see the resource. It creates
+ * a new classloader for LoadItUp2 which cannot see the resource. So, 2 levels
+ * up the call chain we have a class/classloader that can see the resource, but
+ * 1 level up the class/classloader cannot.
+ *
+ * @author Jim Gish
+ */
+public class LoadItUp2Invoker {
+ private URLClassLoader cl;
+ private String rbName;
+ private Object loadItUp2;
+ private Method testMethod;
+
+ public void setup(URL[] urls, String rbName) throws
+ ReflectiveOperationException {
+ this.cl = new URLClassLoader(urls, null);
+ this.rbName = rbName;
+ // Using this new classloader, load the actual test class
+ // which is now two levels removed from the original caller
+ Class<?> loadItUp2Clazz = Class.forName("LoadItUp2", true , cl);
+ this.loadItUp2 = loadItUp2Clazz.newInstance();
+ this.testMethod = loadItUp2Clazz.getMethod("test", String.class);
+ }
+
+ public Boolean test() throws Throwable {
+ try {
+ return (Boolean) testMethod.invoke(loadItUp2, rbName);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+}
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
--- jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Tue Apr 16 16:34:14 2013 -0400
+++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Wed Jun 26 22:50:47 2013 -0500
@@ -23,15 +23,15 @@
/*
* @test
- * @bug 8010127
+ * @bug 8010127 8013380
* @summary Remove the stack search for a resource bundle Logger to use
* @author Jim Gish
- * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp
- * @run main ResourceBundleSearchTest
+ * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker
+ * @run main/othervm ResourceBundleSearchTest
*/
-import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -39,6 +39,12 @@
import java.util.ResourceBundle;
import java.util.logging.Logger;
+/**
+ * This class tests various scenarios of loading resource bundles from
+ * java.util.logging. Since jtreg uses the logging system, it is necessary to
+ * run these tests using othervm mode to ensure no interference from logging
+ * initialization by jtreg
+ */
public class ResourceBundleSearchTest {
private final static boolean DEBUG = false;
@@ -49,7 +55,7 @@
private static int numPass = 0;
private static int numFail = 0;
- private static List<String> msgs = new ArrayList<String>();
+ private static List<String> msgs = new ArrayList<>();
public static void main(String[] args) throws Throwable {
ResourceBundleSearchTest test = new ResourceBundleSearchTest();
@@ -60,47 +66,54 @@
// ensure we are using en as the default Locale so we can find the resource
Locale.setDefault(Locale.ENGLISH);
- String testClasses = System.getProperty("test.classes");
- System.out.println( "test.classes = " + testClasses );
-
ClassLoader myClassLoader = ClassLoader.getSystemClassLoader();
// Find out where we are running from so we can setup the URLClassLoader URL
String userDir = System.getProperty("user.dir");
String testDir = System.getProperty("test.src", userDir);
- String sep = System.getProperty("file.separator");
URL[] urls = new URL[1];
- urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
+ urls[0] = Paths.get(testDir, "resources").toUri().toURL();
URLClassLoader rbClassLoader = new URLClassLoader(urls);
// Test 1 - can we find a Logger bundle from doing a stack search?
// We shouldn't be able to
- assertFalse(testGetBundleFromStackSearch(), "testGetBundleFromStackSearch");
+ assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
// Test 2 - can we find a Logger bundle off of the Thread context class
// loader? We should be able to.
- assertTrue(
- testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader),
- "testGetBundleFromTCCL");
+ assertTrue(testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader),
+ "2-testGetBundleFromTCCL");
// Test 3 - Can we find a Logger bundle from the classpath? We should be
- // able to, but ....
- // We check to see if the bundle is on the classpath or not so that this
- // will work standalone. In the case of jtreg/samevm,
- // the resource bundles are not on the classpath. Running standalone
- // (or othervm), they are
+ // able to. We'll first check to make sure the setup is correct and
+ // it actually is on the classpath before checking whether logging
+ // can see it there.
if (isOnClassPath(PROP_RB_NAME, myClassLoader)) {
debug("We should be able to see " + PROP_RB_NAME + " on the classpath");
assertTrue(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
- "testGetBundleFromSystemClassLoader");
+ "3-testGetBundleFromSystemClassLoader");
} else {
- debug("We should not be able to see " + PROP_RB_NAME + " on the classpath");
- assertFalse(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
- "testGetBundleFromSystemClassLoader");
+ throw new Exception("TEST SETUP FAILURE: Cannot see " + PROP_RB_NAME
+ + " on the classpath");
}
+ // Test 4 - we should be able to find a bundle from the caller's
+ // classloader, but only one level up.
+ assertTrue(testGetBundleFromCallersClassLoader(),
+ "4-testGetBundleFromCallersClassLoader");
+
+ // Test 5 - this ensures that getAnonymousLogger(String rbName)
+ // can find the bundle from the caller's classloader
+ assertTrue(testGetAnonymousLogger(), "5-testGetAnonymousLogger");
+
+ // Test 6 - first call getLogger("myLogger").
+ // Then call getLogger("myLogger","bundleName") from a different ClassLoader
+ // Make sure we find the bundle
+ assertTrue(testGetBundleFromSecondCallersClassLoader(),
+ "6-testGetBundleFromSecondCallersClassLoader");
+
report();
}
@@ -112,7 +125,7 @@
System.out.println(msg);
}
throw new Exception(numFail + " out of " + (numPass + numFail)
- + " tests failed.");
+ + " tests failed.");
}
}
@@ -122,7 +135,7 @@
} else {
numFail++;
System.out.println("FAILED: " + testName
- + " was supposed to return true but did NOT!");
+ + " was supposed to return true but did NOT!");
}
}
@@ -132,13 +145,20 @@
} else {
numFail++;
System.out.println("FAILED: " + testName
- + " was supposed to return false but did NOT!");
+ + " was supposed to return false but did NOT!");
}
}
public boolean testGetBundleFromStackSearch() throws Throwable {
// This should fail. This was the old functionality to search up the
// caller's call stack
+ TwiceIndirectlyLoadABundle indirectLoader = new TwiceIndirectlyLoadABundle();
+ return indirectLoader.loadAndTest();
+ }
+
+ public boolean testGetBundleFromCallersClassLoader() throws Throwable {
+ // This should pass. This exercises getting the bundle using the
+ // class loader of the caller (one level up)
IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
return indirectLoader.loadAndTest();
}
@@ -193,14 +213,29 @@
bundleName);
} catch (MissingResourceException re) {
msgs.add("INFO: testGetBundleFromSystemClassLoader() did not find bundle "
- + bundleName);
+ + bundleName);
return false;
}
msgs.add("INFO: testGetBundleFromSystemClassLoader() found the bundle "
- + bundleName);
+ + bundleName);
return true;
}
+ private boolean testGetAnonymousLogger() throws Throwable {
+ // This should pass. This exercises getting the bundle using the
+ // class loader of the caller (one level up) when calling
+ // Logger.getAnonymousLogger(String rbName)
+ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
+ return indirectLoader.testGetAnonymousLogger();
+ }
+
+ private boolean testGetBundleFromSecondCallersClassLoader() throws Throwable {
+ // This should pass. This exercises getting the bundle using the
+ // class loader of the caller (one level up)
+ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
+ return indirectLoader.testGetLoggerGetLoggerWithBundle();
+ }
+
public static class LoggingThread extends Thread {
boolean foundBundle = false;
@@ -227,13 +262,13 @@
// this should succeed if the bundle is on the system classpath.
try {
Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(),
- bundleName);
- msg = "INFO: LoggingRunnable() found the bundle " + bundleName
- + (setTCCL ? " with " : " without ") + "setting the TCCL";
+ bundleName);
+ msg = "INFO: LoggingThread.run() found the bundle " + bundleName
+ + (setTCCL ? " with " : " without ") + "setting the TCCL";
foundBundle = true;
} catch (MissingResourceException re) {
- msg = "INFO: LoggingRunnable() did not find the bundle " + bundleName
- + (setTCCL ? " with " : " without ") + "setting the TCCL";
+ msg = "INFO: LoggingThread.run() did not find the bundle " + bundleName
+ + (setTCCL ? " with " : " without ") + "setting the TCCL";
foundBundle = false;
}
} catch (Throwable e) {
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/TwiceIndirectlyLoadABundle.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/TwiceIndirectlyLoadABundle.java Wed Jun 26 22:50:47 2013 -0500
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Paths;
+
+/**
+ * This class constructs a scenario where a bundle is accessible on the call
+ * stack two levels up from the call to getLogger(), but not on the immediate
+ * caller. This tests that getLogger() isn't doing a stack crawl more than one
+ * level up to find a bundle.
+ *
+ * @author Jim Gish
+ */
+public class TwiceIndirectlyLoadABundle {
+
+ private final static String rbName = "StackSearchableResource";
+
+ public boolean loadAndTest() throws Throwable {
+ // Find out where we are running from so we can setup the URLClassLoader URLs
+ // test.src and test.classes will be set if running in jtreg, but probably
+ // not otherwise
+ String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
+ String testClassesDir = System.getProperty("test.classes",
+ System.getProperty("user.dir"));
+ URL[] urls = new URL[2];
+
+ // Allow for both jtreg and standalone cases here
+ // Unlike the 1-level test where we can get the bundle from the caller's
+ // class loader, for this one we don't want to expose the resource directory
+ // to the next class. That way we're invoking the LoadItUp2Invoker class
+ // from this class that does have access to the resources (two levels
+ // up the call stack), but the Invoker itself won't have access to resource
+ urls[0] = Paths.get(testDir,"resources").toUri().toURL();
+ urls[1] = Paths.get(testClassesDir).toUri().toURL();
+
+ // Make sure we can find it via the URLClassLoader
+ URLClassLoader yetAnotherResourceCL = new URLClassLoader(urls, null);
+ Class<?> loadItUp2InvokerClazz = Class.forName("LoadItUp2Invoker", true,
+ yetAnotherResourceCL);
+ ClassLoader actual = loadItUp2InvokerClazz.getClassLoader();
+ if (actual != yetAnotherResourceCL) {
+ throw new Exception("LoadItUp2Invoker was loaded by an unexpected CL: "
+ + actual);
+ }
+ Object loadItUp2Invoker = loadItUp2InvokerClazz.newInstance();
+
+ Method setupMethod = loadItUp2InvokerClazz.getMethod("setup",
+ urls.getClass(), String.class);
+ try {
+ // For the next class loader we create, we want to leave off
+ // the resources. That way loadItUp2Invoker will have access to
+ // them, but the next class won't.
+ URL[] noResourceUrl = new URL[1];
+ noResourceUrl[0] = urls[1]; // from above -- just the test classes
+ setupMethod.invoke(loadItUp2Invoker, noResourceUrl, rbName);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+
+ Method testMethod = loadItUp2InvokerClazz.getMethod("test");
+ try {
+ return (Boolean) testMethod.invoke(loadItUp2Invoker);
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+}
diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/resources/CallerSearchableResource_en.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/util/logging/bundlesearch/resources/CallerSearchableResource_en.properties Wed Jun 26 22:50:47 2013 -0500
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+sample1=translation #4 for sample1
+sample2=translation #4 for sample2
+supports-test=ResourceBundleSearchTest

View File

@ -0,0 +1,224 @@
# HG changeset patch
# User joehw
# Date 1381418310 -3600
# Thu Oct 10 16:18:30 2013 +0100
# Node ID b5b1d1fa4bb4fcd8bc0602fd4f3523fe24d9f00b
# Parent 7e2686f3328994b546b7a5d2f7ed5d994a9a724f
8013503: Improve stream factories
Reviewed-by: alanb, dfuchs, mullan
diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/FactoryFinder.java
--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/FactoryFinder.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/FactoryFinder.java Thu Oct 10 16:18:30 2013 +0100
@@ -204,13 +204,15 @@
* a property name
* @param fallbackClassName Implementation class name, if nothing else
* is found. Use null to mean no fallback.
+ * @param standardId Indicate whether the factoryId is standard
+ * or user specified.
*
* Package private so this code can be shared.
*/
- static Object find(String factoryId, String fallbackClassName)
+ static Object find(String factoryId, String fallbackClassName, boolean standardId)
throws ConfigurationError
{
- return find(factoryId, null, fallbackClassName);
+ return find(factoryId, null, fallbackClassName, standardId);
}
/**
@@ -227,23 +229,34 @@
* @param fallbackClassName Implementation class name, if nothing else
* is found. Use null to mean no fallback.
*
+ * @param standardId Indicate whether the factoryId is standard
+ * or user specified.
+ *
* Package private so this code can be shared.
*/
- static Object find(String factoryId, ClassLoader cl, String fallbackClassName)
+ static Object find(String factoryId, ClassLoader cl, String fallbackClassName,
+ boolean standardId)
throws ConfigurationError
{
dPrint("find factoryId =" + factoryId);
// Use the system property first
try {
- String systemProp = ss.getSystemProperty(factoryId);
+ String systemProp;
+ if (standardId) {
+ systemProp = ss.getSystemProperty(factoryId);
+ } else {
+ systemProp = System.getProperty(factoryId);
+ }
+
if (systemProp != null) {
dPrint("found system property, value=" + systemProp);
return newInstance(systemProp, null, true);
}
}
catch (SecurityException se) {
- if (debug) se.printStackTrace();
+ throw new ConfigurationError(
+ "Failed to read factoryId '" + factoryId + "'", se);
}
// Try read $java.home/lib/stax.properties followed by
diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/XMLEventFactory.java
--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLEventFactory.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLEventFactory.java Thu Oct 10 16:18:30 2013 +0100
@@ -47,6 +47,9 @@
* @since 1.6
*/
public abstract class XMLEventFactory {
+
+ static final String JAXPFACTORYID = "javax.xml.stream.XMLEventFactory";
+
protected XMLEventFactory(){}
/**
@@ -57,8 +60,7 @@
throws FactoryConfigurationError
{
return (XMLEventFactory) FactoryFinder.find(
- "javax.xml.stream.XMLEventFactory",
- "com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
+ JAXPFACTORYID, "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", true);
}
/**
@@ -91,7 +93,7 @@
{
return (XMLEventFactory) FactoryFinder.find(
"javax.xml.stream.XMLEventFactory",
- "com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
+ "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", true);
}
/**
@@ -114,7 +116,8 @@
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
- return (XMLEventFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
+ return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader,
+ null, factoryId.equals(JAXPFACTORYID) ? true : false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
@@ -141,7 +144,8 @@
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
- return (XMLEventFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
+ return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader,
+ null, factoryId.equals(JAXPFACTORYID) ? true : false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/XMLInputFactory.java
--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLInputFactory.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLInputFactory.java Thu Oct 10 16:18:30 2013 +0100
@@ -139,6 +139,7 @@
public static final String ALLOCATOR=
"javax.xml.stream.allocator";
+ static final String JAXPFACTORYID = "javax.xml.stream.XMLInputFactory";
static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
protected XMLInputFactory(){}
@@ -150,9 +151,7 @@
public static XMLInputFactory newInstance()
throws FactoryConfigurationError
{
- return (XMLInputFactory) FactoryFinder.find(
- "javax.xml.stream.XMLInputFactory",
- DEFAULIMPL);
+ return (XMLInputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
}
/**
@@ -183,9 +182,7 @@
public static XMLInputFactory newFactory()
throws FactoryConfigurationError
{
- return (XMLInputFactory) FactoryFinder.find(
- "javax.xml.stream.XMLInputFactory",
- DEFAULIMPL);
+ return (XMLInputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
}
/**
@@ -208,7 +205,8 @@
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
- return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
+ return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader,
+ null, factoryId.equals(JAXPFACTORYID) ? true : false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
@@ -235,7 +233,8 @@
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
- return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
+ return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader,
+ null, factoryId.equals(JAXPFACTORYID) ? true : false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/XMLOutputFactory.java
--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLOutputFactory.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLOutputFactory.java Thu Oct 10 16:18:30 2013 +0100
@@ -115,6 +115,7 @@
public static final String IS_REPAIRING_NAMESPACES=
"javax.xml.stream.isRepairingNamespaces";
+ static final String JAXPFACTORYID = "javax.xml.stream.XMLOutputFactory";
static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLOutputFactoryImpl";
protected XMLOutputFactory(){}
@@ -126,8 +127,7 @@
public static XMLOutputFactory newInstance()
throws FactoryConfigurationError
{
- return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory",
- DEFAULIMPL);
+ return (XMLOutputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
}
/**
@@ -158,8 +158,7 @@
public static XMLOutputFactory newFactory()
throws FactoryConfigurationError
{
- return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory",
- DEFAULIMPL);
+ return (XMLOutputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
}
/**
@@ -181,7 +180,8 @@
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
- return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
+ return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader,
+ null, factoryId.equals(JAXPFACTORYID) ? true : false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());
@@ -210,7 +210,8 @@
throws FactoryConfigurationError {
try {
//do not fallback if given classloader can't find the class, throw exception
- return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader, null);
+ return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader,
+ null, factoryId.equals(JAXPFACTORYID) ? true : false);
} catch (FactoryFinder.ConfigurationError e) {
throw new FactoryConfigurationError(e.getException(),
e.getMessage());

View File

@ -0,0 +1,39 @@
# HG changeset patch
# User ksrini
# Date 1381851019 -3600
# Tue Oct 15 16:30:19 2013 +0100
# Node ID 8fb384d684f5b9bc76970bdc7e5603b9cd9944b8
# Parent 337232ddaec36c6d9843ff35906e6160446844eb
8013506: Better Pack200 data handling
Reviewed-by: jrose, kizune, mschoene
diff -r 337232ddaec3 -r 8fb384d684f5 src/share/native/com/sun/java/util/jar/pack/zip.cpp
--- jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp Fri May 31 20:43:32 2013 +0400
+++ jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp Tue Oct 15 16:30:19 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -339,6 +339,10 @@
time_t t = modtime;
struct tm sbuf;
struct tm* s = gmtime_r(&t, &sbuf);
+ if (s == NULL) {
+ fprintf(u->errstrm, "Error: gmtime failure, invalid input archive\n");
+ exit(2);
+ }
modtime_cache = modtime;
dostime_cache = dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
s->tm_hour, s->tm_min, s->tm_sec);
@@ -383,7 +387,7 @@
}
deflated.empty();
- zs.next_out = (uchar*) deflated.grow(len + (len/2));
+ zs.next_out = (uchar*) deflated.grow(add_size(len, (len/2)));
zs.avail_out = deflated.size();
zs.next_in = (uchar*)head.ptr;

View File

@ -0,0 +1,57 @@
# HG changeset patch
# User jchen
# Date 1368123798 25200
# Thu May 09 11:23:18 2013 -0700
# Node ID c428e65fa8fd127058ea33ef728391887ea108e6
# Parent 8fb384d684f5b9bc76970bdc7e5603b9cd9944b8
8013510: Augment image writing code
Reviewed-by: bae, prr
diff -r 8fb384d684f5 -r c428e65fa8fd src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
--- jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Tue Oct 15 16:30:19 2013 +0100
+++ jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Thu May 09 11:23:18 2013 -0700
@@ -1178,6 +1178,11 @@
target = imRas;
}
int [] bandSizes = target.getSampleModel().getSampleSize();
+ for (int i = 0; i < bandSizes.length; i++) {
+ if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
+ throw new IIOException("Illegal band size: should be 0 < size <= 8");
+ }
+ }
/*
* If the process is sequential, and we have restart markers,
diff -r 8fb384d684f5 -r c428e65fa8fd src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
--- jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java Tue Oct 15 16:30:19 2013 +0100
+++ jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java Thu May 09 11:23:18 2013 -0700
@@ -490,8 +490,8 @@
// handle <= 8-bit samples. We now check the band sizes and throw
// an exception for images, such as USHORT_GRAY, with > 8 bits
// per sample.
- if (bandSizes[i] > 8) {
- throw new IIOException("Sample size must be <= 8");
+ if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
+ throw new IIOException("Illegal band size: should be 0 < size <= 8");
}
// 4450894 part 2: We expand IndexColorModel images to full 24-
// or 32-bit in grabPixels() for each scanline. For indexed
diff -r 8fb384d684f5 -r c428e65fa8fd src/share/native/sun/awt/image/jpeg/imageioJPEG.c
--- jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Tue Oct 15 16:30:19 2013 +0100
+++ jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Thu May 09 11:23:18 2013 -0700
@@ -2684,6 +2684,15 @@
bandSize = (*env)->GetIntArrayElements(env, bandSizes, NULL);
for (i = 0; i < numBands; i++) {
+ if (bandSize[i] <= 0 || bandSize[i] > JPEG_BAND_SIZE) {
+ (*env)->ReleaseIntArrayElements(env, bandSizes,
+ bandSize, JNI_ABORT);
+ JNU_ThrowByName(env, "javax/imageio/IIOException", "Invalid Image");
+ return JNI_FALSE;;
+ }
+ }
+
+ for (i = 0; i < numBands; i++) {
if (bandSize[i] != JPEG_BAND_SIZE) {
mustScale = TRUE;
break;

View File

@ -0,0 +1,51 @@
# HG changeset patch
# User vadim
# Date 1381851333 -3600
# Tue Oct 15 16:35:33 2013 +0100
# Node ID a28b8ce4d90e7d7bc1fab599298831e0d62e171e
# Parent c428e65fa8fd127058ea33ef728391887ea108e6
8013514: Improve stability of cmap class
Reviewed-by: mschoene, prr, bae
diff -r c428e65fa8fd -r a28b8ce4d90e src/share/classes/sun/font/FileFont.java
--- jdk/src/share/classes/sun/font/FileFont.java Thu May 09 11:23:18 2013 -0700
+++ jdk/src/share/classes/sun/font/FileFont.java Tue Oct 15 16:35:33 2013 +0100
@@ -174,7 +174,9 @@
}
}
}
- scaler.dispose();
+ if (scaler != null) {
+ scaler.dispose();
+ }
scaler = FontManager.getNullScaler();
}
diff -r c428e65fa8fd -r a28b8ce4d90e src/share/classes/sun/font/StandardGlyphVector.java
--- jdk/src/share/classes/sun/font/StandardGlyphVector.java Thu May 09 11:23:18 2013 -0700
+++ jdk/src/share/classes/sun/font/StandardGlyphVector.java Tue Oct 15 16:35:33 2013 +0100
@@ -1733,8 +1733,9 @@
tx,
sgv.font.getStyle(),
aa, fm);
-
- FontStrike strike = sgv.font2D.getStrike(desc); // !!! getStrike(desc, false)
+ // Get the strike via the handle. Shouldn't matter
+ // if we've invalidated the font but its an extra precaution.
+ FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc); // !!! getStrike(desc, false)
return new GlyphStrike(sgv, strike, dx, dy);
}
diff -r c428e65fa8fd -r a28b8ce4d90e src/share/classes/sun/font/TrueTypeFont.java
--- jdk/src/share/classes/sun/font/TrueTypeFont.java Thu May 09 11:23:18 2013 -0700
+++ jdk/src/share/classes/sun/font/TrueTypeFont.java Tue Oct 15 16:35:33 2013 +0100
@@ -559,6 +559,9 @@
if (head_Table != null && head_Table.capacity() >= 18) {
ShortBuffer sb = head_Table.asShortBuffer();
upem = sb.get(9) & 0xffff;
+ if (upem < 16 || upem > 16384) {
+ upem = 2048;
+ }
}
setStrikethroughMetrics(os2_Table, upem);

View File

@ -0,0 +1,148 @@
# HG changeset patch
# User weijun
# Date 1382990980 0
# Mon Oct 28 20:09:40 2013 +0000
# Node ID 42fd9f22ae5e9aea017af28a2b5ff7a498753e15
# Parent 2adb9f71f6c0723acf40877f059d276557b71034
8013739: Better LDAP resource management
Reviewed-by: ahgross, mchung, xuelei
diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/com/sun/jndi/ldap/VersionHelper12.java
--- jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java Mon Jul 22 14:06:39 2013 -0700
+++ jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java Mon Oct 28 20:09:40 2013 +0000
@@ -25,11 +25,12 @@
package com.sun.jndi.ldap;
-import java.net.URL;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
+import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import sun.misc.SharedSecrets;
final class VersionHelper12 extends VersionHelper {
@@ -82,12 +83,16 @@
}
Thread createThread(final Runnable r) {
- return (Thread) AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new Thread(r);
+ final AccessControlContext acc = AccessController.getContext();
+ // 4290486: doPrivileged is needed to create a thread in
+ // an environment that restricts "modifyThreadGroup".
+ return AccessController.doPrivileged(
+ new PrivilegedAction<Thread>() {
+ public Thread run() {
+ return SharedSecrets.getJavaLangAccess()
+ .newThreadWithAcc(r, acc);
+ }
}
- }
);
}
}
diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/java/lang/System.java
--- jdk/src/share/classes/java/lang/System.java Mon Jul 22 14:06:39 2013 -0700
+++ jdk/src/share/classes/java/lang/System.java Mon Oct 28 20:09:40 2013 +0000
@@ -25,6 +25,7 @@
package java.lang;
import java.io.*;
+import java.security.AccessControlContext;
import java.util.Properties;
import java.util.PropertyPermission;
import java.util.StringTokenizer;
@@ -1158,6 +1159,9 @@
public void blockedOn(Thread t, Interruptible b) {
t.blockedOn(b);
}
+ public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
+ return new Thread(target, acc);
+ }
});
}
}
diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/java/lang/Thread.java
--- jdk/src/share/classes/java/lang/Thread.java Mon Jul 22 14:06:39 2013 -0700
+++ jdk/src/share/classes/java/lang/Thread.java Mon Oct 28 20:09:40 2013 +0000
@@ -322,6 +322,15 @@
}
/**
+ * Initializes a Thread with the current AccessControlContext.
+ * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext)
+ */
+ private void init(ThreadGroup g, Runnable target, String name,
+ long stackSize) {
+ init(g, target, name, stackSize, null);
+ }
+
+ /**
* Initializes a Thread.
*
* @param g the Thread group
@@ -329,9 +338,11 @@
* @param name the name of the new Thread
* @param stackSize the desired stack size for the new thread, or
* zero to indicate that this parameter is to be ignored.
+ * @param acc the AccessControlContext to inherit, or
+ * AccessController.getContext() if null
*/
private void init(ThreadGroup g, Runnable target, String name,
- long stackSize) {
+ long stackSize, AccessControlContext acc) {
Thread parent = currentThread();
SecurityManager security = System.getSecurityManager();
if (g == null) {
@@ -374,7 +385,8 @@
this.contextClassLoader = parent.getContextClassLoader();
else
this.contextClassLoader = parent.contextClassLoader;
- this.inheritedAccessControlContext = AccessController.getContext();
+ this.inheritedAccessControlContext =
+ acc != null ? acc : AccessController.getContext();
this.target = target;
setPriority(priority);
if (parent.inheritableThreadLocals != null)
@@ -427,6 +439,14 @@
}
/**
+ * Creates a new Thread that inherits the given AccessControlContext.
+ * This is not a public constructor.
+ */
+ Thread(Runnable target, AccessControlContext acc) {
+ init(null, target, "Thread-" + nextThreadNum(), 0, acc);
+ }
+
+ /**
* Allocates a new <code>Thread</code> object. This constructor has
* the same effect as <code>Thread(null, null,</code>
* <i>gname</i><code>)</code>, where <b><i>gname</i></b> is
diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/sun/misc/JavaLangAccess.java
--- jdk/src/share/classes/sun/misc/JavaLangAccess.java Mon Jul 22 14:06:39 2013 -0700
+++ jdk/src/share/classes/sun/misc/JavaLangAccess.java Mon Oct 28 20:09:40 2013 +0000
@@ -25,6 +25,7 @@
package sun.misc;
+import java.security.AccessControlContext;
import sun.reflect.ConstantPool;
import sun.reflect.annotation.AnnotationType;
import sun.nio.ch.Interruptible;
@@ -54,4 +55,10 @@
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
+
+ /**
+ * Returns a new Thread with the given Runnable and an
+ * inherited AccessControlContext.
+ */
+ Thread newThreadWithAcc(Runnable target, AccessControlContext acc);
}

View File

@ -0,0 +1,196 @@
# HG changeset patch
# User alexsch
# Date 1381852031 -3600
# Tue Oct 15 16:47:11 2013 +0100
# Node ID d10e47deb098d4af5d58a8bfe92dc8033e5ef6f7
# Parent a28b8ce4d90e7d7bc1fab599298831e0d62e171e
8013744: Better tabling for AWT
Reviewed-by: art, malenkov, skoivu
diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/JTable.java
--- jdk/src/share/classes/javax/swing/JTable.java Tue Oct 15 16:35:33 2013 +0100
+++ jdk/src/share/classes/javax/swing/JTable.java Tue Oct 15 16:47:11 2013 +0100
@@ -52,6 +52,7 @@
import javax.print.attribute.*;
import javax.print.PrintService;
+import sun.reflect.misc.ReflectUtil;
import sun.swing.SwingUtilities2;
import sun.swing.SwingUtilities2.Section;
@@ -5461,14 +5462,15 @@
// they have the option to replace the value with
// null or use escape to restore the original.
// For Strings, return "" for backward compatibility.
- if ("".equals(s)) {
- if (constructor.getDeclaringClass() == String.class) {
- value = s;
- }
- super.stopCellEditing();
- }
-
try {
+ if ("".equals(s)) {
+ if (constructor.getDeclaringClass() == String.class) {
+ value = s;
+ }
+ super.stopCellEditing();
+ }
+
+ SwingUtilities2.checkAccess(constructor.getModifiers());
value = constructor.newInstance(new Object[]{s});
}
catch (Exception e) {
@@ -5492,6 +5494,8 @@
if (type == Object.class) {
type = String.class;
}
+ ReflectUtil.checkPackageAccess(type);
+ SwingUtilities2.checkAccess(type.getModifiers());
constructor = type.getConstructor(argTypes);
}
catch (Exception e) {
diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/UIDefaults.java
--- jdk/src/share/classes/javax/swing/UIDefaults.java Tue Oct 15 16:35:33 2013 +0100
+++ jdk/src/share/classes/javax/swing/UIDefaults.java Tue Oct 15 16:47:11 2013 +0100
@@ -53,6 +53,7 @@
import sun.reflect.misc.MethodUtil;
import sun.reflect.misc.ReflectUtil;
+import sun.swing.SwingUtilities2;
import sun.util.CoreResourceBundleControl;
/**
@@ -1102,7 +1103,7 @@
}
ReflectUtil.checkPackageAccess(className);
c = Class.forName(className, true, (ClassLoader)cl);
- checkAccess(c.getModifiers());
+ SwingUtilities2.checkAccess(c.getModifiers());
if (methodName != null) {
Class[] types = getClassArray(args);
Method m = c.getMethod(methodName, types);
@@ -1110,7 +1111,7 @@
} else {
Class[] types = getClassArray(args);
Constructor constructor = c.getConstructor(types);
- checkAccess(constructor.getModifiers());
+ SwingUtilities2.checkAccess(constructor.getModifiers());
return constructor.newInstance(args);
}
} catch(Exception e) {
@@ -1125,13 +1126,6 @@
}, acc);
}
- private void checkAccess(int modifiers) {
- if(System.getSecurityManager() != null &&
- !Modifier.isPublic(modifiers)) {
- throw new SecurityException("Resource is not accessible");
- }
- }
-
/*
* Coerce the array of class types provided into one which
* looks the way the Reflection APIs expect. This is done
diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/text/DefaultFormatter.java
--- jdk/src/share/classes/javax/swing/text/DefaultFormatter.java Tue Oct 15 16:35:33 2013 +0100
+++ jdk/src/share/classes/javax/swing/text/DefaultFormatter.java Tue Oct 15 16:47:11 2013 +0100
@@ -24,7 +24,8 @@
*/
package javax.swing.text;
-import sun.reflect.misc.ConstructorUtil;
+import sun.reflect.misc.ReflectUtil;
+import sun.swing.SwingUtilities2;
import java.io.Serializable;
import java.lang.reflect.*;
@@ -247,7 +248,9 @@
Constructor cons;
try {
- cons = ConstructorUtil.getConstructor(vc, new Class[]{String.class});
+ ReflectUtil.checkPackageAccess(vc);
+ SwingUtilities2.checkAccess(vc.getModifiers());
+ cons = vc.getConstructor(new Class[]{String.class});
} catch (NoSuchMethodException nsme) {
cons = null;
@@ -255,6 +258,7 @@
if (cons != null) {
try {
+ SwingUtilities2.checkAccess(cons.getModifiers());
return cons.newInstance(new Object[] { string });
} catch (Throwable ex) {
throw new ParseException("Error creating instance", 0);
diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/text/NumberFormatter.java
--- jdk/src/share/classes/javax/swing/text/NumberFormatter.java Tue Oct 15 16:35:33 2013 +0100
+++ jdk/src/share/classes/javax/swing/text/NumberFormatter.java Tue Oct 15 16:47:11 2013 +0100
@@ -28,6 +28,8 @@
import java.text.*;
import java.util.*;
import javax.swing.text.*;
+import sun.reflect.misc.ReflectUtil;
+import sun.swing.SwingUtilities2;
/**
* <code>NumberFormatter</code> subclasses <code>InternationalFormatter</code>
@@ -466,10 +468,12 @@
valueClass = value.getClass();
}
try {
+ ReflectUtil.checkPackageAccess(valueClass);
+ SwingUtilities2.checkAccess(valueClass.getModifiers());
Constructor cons = valueClass.getConstructor(
new Class[] { String.class });
-
if (cons != null) {
+ SwingUtilities2.checkAccess(cons.getModifiers());
return cons.newInstance(new Object[]{string});
}
} catch (Throwable ex) { }
diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/sun/swing/SwingLazyValue.java
--- jdk/src/share/classes/sun/swing/SwingLazyValue.java Tue Oct 15 16:35:33 2013 +0100
+++ jdk/src/share/classes/sun/swing/SwingLazyValue.java Tue Oct 15 16:47:11 2013 +0100
@@ -30,6 +30,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.swing.UIDefaults;
+import sun.reflect.misc.ReflectUtil;
/**
* SwingLazyValue is a copy of ProxyLazyValue that does not snapshot the
@@ -64,7 +65,7 @@
public Object createValue(final UIDefaults table) {
try {
Class c;
- Object cl;
+ ReflectUtil.checkPackageAccess(className);
c = Class.forName(className, true, null);
if (methodName != null) {
Class[] types = getClassArray(args);
diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/sun/swing/SwingUtilities2.java
--- jdk/src/share/classes/sun/swing/SwingUtilities2.java Tue Oct 15 16:35:33 2013 +0100
+++ jdk/src/share/classes/sun/swing/SwingUtilities2.java Tue Oct 15 16:47:11 2013 +0100
@@ -1319,6 +1319,19 @@
}
/**
+ * Utility method that throws SecurityException if SecurityManager is set
+ * and modifiers are not public
+ *
+ * @param modifiers a set of modifiers
+ */
+ public static void checkAccess(int modifiers) {
+ if (System.getSecurityManager() != null
+ && !Modifier.isPublic(modifiers)) {
+ throw new SecurityException("Resource is not accessible");
+ }
+ }
+
+ /**
* Returns true if EventQueue.getCurrentEvent() has the permissions to
* access the system clipboard and if it is allowed gesture (if
* checkGesture true)

View File

@ -0,0 +1,176 @@
# HG changeset patch
# User dxu
# Date 1383018580 0
# Tue Oct 29 03:49:40 2013 +0000
# Node ID 8459b68eb028734b2153266176538e1eddbb87be
# Parent 8ad2eb12bf42f2564fdf80a7236e4046046a4f4e
8013827: File.createTempFile hangs with temp file starting with 'com1.4'
8011950: java.io.File.createTempFile enters infinite loop when passed invalid data
Reviewed-by: alanb
diff -r 8ad2eb12bf42 -r 8459b68eb028 src/share/classes/java/io/File.java
--- jdk/src/share/classes/java/io/File.java Tue Oct 29 03:05:18 2013 +0000
+++ jdk/src/share/classes/java/io/File.java Tue Oct 29 03:49:40 2013 +0000
@@ -1801,7 +1801,11 @@
} else {
n = Math.abs(n);
}
- return new File(dir, prefix + Long.toString(n) + suffix);
+ String name = prefix + Long.toString(n) + suffix;
+ File f = new File(dir, name);
+ if (!name.equals(f.getName()))
+ throw new IOException("Unable to create temporary file");
+ return f;
}
private static boolean checkAndCreate(String filename, SecurityManager sm,
diff -r 8ad2eb12bf42 -r 8459b68eb028 src/windows/native/java/io/WinNTFileSystem_md.c
--- jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Oct 29 03:05:18 2013 +0000
+++ jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Oct 29 03:49:40 2013 +0000
@@ -356,6 +356,10 @@
WCHAR *pathbuf = pathToNTPath(env, path, JNI_FALSE);
if (pathbuf == NULL)
return JNI_FALSE;
+ if (isReservedDeviceNameW(pathbuf)) {
+ free(pathbuf);
+ return JNI_FALSE;
+ }
h = CreateFileW(
pathbuf, /* Wide char path name */
GENERIC_READ | GENERIC_WRITE, /* Read and write permission */
diff -r 8ad2eb12bf42 -r 8459b68eb028 test/java/io/File/CreateNewFile.java
--- jdk/test/java/io/File/CreateNewFile.java Tue Oct 29 03:05:18 2013 +0000
+++ jdk/test/java/io/File/CreateNewFile.java Tue Oct 29 03:49:40 2013 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -22,7 +22,7 @@
*/
/* @test
- @bug 4130498 4391178
+ @bug 4130498 4391178 6198547
@summary Basic test for createNewFile method
*/
@@ -51,5 +51,20 @@
} catch (IOException e) {
// Exception expected
}
+
+ testCreateExistingDir();
+ }
+
+ // Test JDK-6198547
+ private static void testCreateExistingDir() throws IOException {
+ File tmpFile = new File("hugo");
+ if (tmpFile.exists() && !tmpFile.delete())
+ throw new RuntimeException("Cannot delete " + tmpFile);
+ if (!tmpFile.mkdir())
+ throw new RuntimeException("Cannot create dir " + tmpFile);
+ if (!tmpFile.exists())
+ throw new RuntimeException("Cannot see created dir " + tmpFile);
+ if (tmpFile.createNewFile())
+ throw new RuntimeException("Should fail to create file " + tmpFile);
}
}
diff -r 8ad2eb12bf42 -r 8459b68eb028 test/java/io/File/NulFile.java
--- jdk/test/java/io/File/NulFile.java Tue Oct 29 03:05:18 2013 +0000
+++ jdk/test/java/io/File/NulFile.java Tue Oct 29 03:49:40 2013 +0000
@@ -612,7 +612,7 @@
try {
File.createTempFile(prefix, suffix, directory);
} catch (IOException ex) {
- if ("Unable to create temporary file".equals(ex.getMessage()))
+ if (ExceptionMsg.equals(ex.getMessage()))
exceptionThrown = true;
}
}
diff -r 8ad2eb12bf42 -r 8459b68eb028 test/java/io/File/createTempFile/SpecialTempFile.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jdk/test/java/io/File/createTempFile/SpecialTempFile.java Tue Oct 29 03:49:40 2013 +0000
@@ -0,0 +1,80 @@
+/*
+ * 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 8013827 8011950
+ * @summary Check whether File.createTempFile can handle special parameters
+ * on Windows platforms
+ * @author Dan Xu
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+public class SpecialTempFile {
+
+ private static void test(String name, String[] prefix, String[] suffix) {
+ if (prefix == null || suffix == null
+ || prefix.length != suffix.length)
+ {
+ return;
+ }
+
+ final String exceptionMsg = "Unable to create temporary file";
+ final String errMsg = "IOException is expected";
+
+ for (int i = 0; i < prefix.length; i++) {
+ boolean exceptionThrown = false;
+ File f = null;
+ System.out.println("In test " + name
+ + ", creating temp file with prefix, "
+ + prefix[i] + ", suffix, " + suffix[i]);
+ try {
+ f = File.createTempFile(prefix[i], suffix[i]);
+ } catch (IOException e) {
+ if (exceptionMsg.equals(e.getMessage()))
+ exceptionThrown = true;
+ else
+ System.out.println("Wrong error message:" + e.getMessage());
+ }
+ if (!exceptionThrown || f != null)
+ throw new RuntimeException(errMsg);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (!System.getProperty("os.name").startsWith("Windows"))
+ return;
+
+ // Test JDK-8013827
+ String[] resvPre = { "LPT1.package.zip", "com7.4.package.zip" };
+ String[] resvSuf = { ".temp", ".temp" };
+ test("ReservedName", resvPre, resvSuf);
+
+ // Test JDK-8011950
+ String[] slashPre = { "///..///", "temp", "///..///" };
+ String[] slashSuf = { ".temp", "///..///..", "///..///.." };
+ test("SlashedName", slashPre, slashSuf);
+ }
+}

View File

@ -0,0 +1,412 @@
# HG changeset patch
# User jbachorik
# Date 1371711107 -7200
# Thu Jun 20 08:51:47 2013 +0200
# Node ID a9be60a78488c7b261b92d927d1272afe2484e6b
# Parent d10e47deb098d4af5d58a8bfe92dc8033e5ef6f7
8014085: Better serialization support in JMX classes
Reviewed-by: alanb, dfuchs, skoivu
diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/MBeanNotificationInfo.java
--- jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Tue Oct 15 16:47:11 2013 +0100
+++ jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Thu Jun 20 08:51:47 2013 +0200
@@ -25,6 +25,9 @@
package javax.management;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
import java.util.Arrays;
/**
@@ -67,7 +70,7 @@
/**
* @serial The different types of the notification.
*/
- private final String[] types;
+ private String[] types;
/** @see MBeanInfo#arrayGettersSafe */
private final transient boolean arrayGettersSafe;
@@ -114,9 +117,8 @@
notifType, though it doesn't explicitly allow it
either. */
- if (notifTypes == null)
- notifTypes = NO_TYPES;
- this.types = notifTypes;
+ this.types = (notifTypes != null && notifTypes.length > 0) ?
+ notifTypes.clone() : NO_TYPES;
this.arrayGettersSafe =
MBeanInfo.arrayGettersSafe(this.getClass(),
MBeanNotificationInfo.class);
@@ -203,4 +205,16 @@
hash ^= types[i].hashCode();
return hash;
}
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = ois.readFields();
+ String[] t = (String[])gf.get("types", null);
+
+ if (t == null) {
+ throw new InvalidObjectException("Trying to deserialize an invalid " +
+ "instance of " + MBeanNotificationInfo.class +
+ "[types=null]");
+ }
+ types = t.length == 0 ? t : t.clone();
+ }
}
diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/JMXPrincipal.java
--- jdk/src/share/classes/javax/management/remote/JMXPrincipal.java Tue Oct 15 16:47:11 2013 +0100
+++ jdk/src/share/classes/javax/management/remote/JMXPrincipal.java Thu Jun 20 08:51:47 2013 +0200
@@ -26,6 +26,9 @@
package javax.management.remote;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.security.Principal;
@@ -64,9 +67,7 @@
* <code>null</code>.
*/
public JMXPrincipal(String name) {
- if (name == null)
- throw new NullPointerException("illegal null input");
-
+ validate(name);
this.name = name;
}
@@ -130,4 +131,20 @@
public int hashCode() {
return name.hashCode();
}
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = ois.readFields();
+ String principalName = (String)gf.get("name", null);
+ try {
+ validate(principalName);
+ this.name = principalName;
+ } catch (NullPointerException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
+ }
+
+ private static void validate(String name) throws NullPointerException {
+ if (name == null)
+ throw new NullPointerException("illegal null input");
+ }
}
diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/JMXServiceURL.java
--- jdk/src/share/classes/javax/management/remote/JMXServiceURL.java Tue Oct 15 16:47:11 2013 +0100
+++ jdk/src/share/classes/javax/management/remote/JMXServiceURL.java Thu Jun 20 08:51:47 2013 +0200
@@ -29,6 +29,9 @@
import com.sun.jmx.remote.util.ClassLogger;
import com.sun.jmx.remote.util.EnvHelp;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.net.InetAddress;
@@ -299,7 +302,7 @@
If we're given an explicit host name that is illegal we
have to reject it. (Bug 5057532.) */
try {
- validateHost(host);
+ validateHost(host, port);
} catch (MalformedURLException e) {
if (logger.fineOn()) {
logger.fine("JMXServiceURL",
@@ -338,36 +341,82 @@
validate();
}
- private void validate() throws MalformedURLException {
+ private static final String INVALID_INSTANCE_MSG =
+ "Trying to deserialize an invalid instance of JMXServiceURL";
+ private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = inputStream.readFields();
+ String h = (String)gf.get("host", null);
+ int p = (int)gf.get("port", -1);
+ String proto = (String)gf.get("protocol", null);
+ String url = (String)gf.get("urlPath", null);
+ if (proto == null || url == null || h == null) {
+ StringBuilder sb = new StringBuilder(INVALID_INSTANCE_MSG).append('[');
+ boolean empty = true;
+ if (proto == null) {
+ sb.append("protocol=null");
+ empty = false;
+ }
+ if (h == null) {
+ sb.append(empty ? "" : ",").append("host=null");
+ empty = false;
+ }
+ if (url == null) {
+ sb.append(empty ? "" : ",").append("urlPath=null");
+ }
+ sb.append(']');
+ throw new InvalidObjectException(sb.toString());
+ }
+
+ if (h.contains("[") || h.contains("]")) {
+ throw new InvalidObjectException("Invalid host name: " + h);
+ }
+
+ try {
+ validate(proto, h, p, url);
+ this.protocol = proto;
+ this.host = h;
+ this.port = p;
+ this.urlPath = url;
+ } catch (MalformedURLException e) {
+ throw new InvalidObjectException(INVALID_INSTANCE_MSG + ": " +
+ e.getMessage());
+ }
+
+ }
+
+ private void validate(String proto, String h, int p, String url)
+ throws MalformedURLException {
// Check protocol
-
- final int protoEnd = indexOfFirstNotInSet(protocol, protocolBitSet, 0);
- if (protoEnd == 0 || protoEnd < protocol.length()
- || !alphaBitSet.get(protocol.charAt(0))) {
+ final int protoEnd = indexOfFirstNotInSet(proto, protocolBitSet, 0);
+ if (protoEnd == 0 || protoEnd < proto.length()
+ || !alphaBitSet.get(proto.charAt(0))) {
throw new MalformedURLException("Missing or invalid protocol " +
- "name: \"" + protocol + "\"");
+ "name: \"" + proto + "\"");
}
// Check host
-
- validateHost();
+ validateHost(h, p);
// Check port
-
- if (port < 0)
- throw new MalformedURLException("Bad port: " + port);
+ if (p < 0)
+ throw new MalformedURLException("Bad port: " + p);
// Check URL path
-
- if (urlPath.length() > 0) {
- if (!urlPath.startsWith("/") && !urlPath.startsWith(";"))
- throw new MalformedURLException("Bad URL path: " + urlPath);
+ if (url.length() > 0) {
+ if (!url.startsWith("/") && !url.startsWith(";"))
+ throw new MalformedURLException("Bad URL path: " + url);
}
}
- private void validateHost() throws MalformedURLException {
- if (host.length() == 0) {
+ private void validate() throws MalformedURLException {
+ validate(this.protocol, this.host, this.port, this.urlPath);
+ }
+
+ private static void validateHost(String h, int port)
+ throws MalformedURLException {
+
+ if (h.length() == 0) {
if (port != 0) {
throw new MalformedURLException("Cannot give port number " +
"without host name");
@@ -375,12 +424,6 @@
return;
}
- validateHost(host);
- }
-
- private static void validateHost(String h)
- throws MalformedURLException {
-
if (isNumericIPv6Address(h)) {
/* We assume J2SE >= 1.4 here. Otherwise you can't
use the address anyway. We can't call
@@ -670,22 +713,22 @@
/**
* The value returned by {@link #getProtocol()}.
*/
- private final String protocol;
+ private String protocol;
/**
* The value returned by {@link #getHost()}.
*/
- private final String host;
+ private String host;
/**
* The value returned by {@link #getPort()}.
*/
- private final int port;
+ private int port;
/**
* The value returned by {@link #getURLPath()}.
*/
- private final String urlPath;
+ private String urlPath;
/**
* Cached result of {@link #toString()}.
diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/NotificationResult.java
--- jdk/src/share/classes/javax/management/remote/NotificationResult.java Tue Oct 15 16:47:11 2013 +0100
+++ jdk/src/share/classes/javax/management/remote/NotificationResult.java Thu Jun 20 08:51:47 2013 +0200
@@ -25,6 +25,9 @@
package javax.management.remote;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
/**
@@ -76,17 +79,7 @@
public NotificationResult(long earliestSequenceNumber,
long nextSequenceNumber,
TargetedNotification[] targetedNotifications) {
- if (targetedNotifications == null) {
- final String msg = "Notifications null";
- throw new IllegalArgumentException(msg);
- }
-
- if (earliestSequenceNumber < 0 || nextSequenceNumber < 0)
- throw new IllegalArgumentException("Bad sequence numbers");
- /* We used to check nextSequenceNumber >= earliestSequenceNumber
- here. But in fact the opposite can legitimately be true if
- notifications have been lost. */
-
+ validate(targetedNotifications, earliestSequenceNumber, nextSequenceNumber);
this.earliestSequenceNumber = earliestSequenceNumber;
this.nextSequenceNumber = nextSequenceNumber;
this.targetedNotifications = (targetedNotifications.length == 0 ? targetedNotifications : targetedNotifications.clone());
@@ -138,7 +131,39 @@
getTargetedNotifications().length;
}
- private final long earliestSequenceNumber;
- private final long nextSequenceNumber;
- private final TargetedNotification[] targetedNotifications;
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = ois.readFields();
+ TargetedNotification[] tNotifs = (TargetedNotification[])gf.get("targetedNotifications", null);
+ long snStart = gf.get("earliestSequenceNumber", -1L);
+ long snNext = gf.get("nextSequenceNumber", -1L);
+ try {
+ validate(tNotifs, snStart, snNext);
+
+ this.targetedNotifications = tNotifs.length == 0 ? tNotifs : tNotifs.clone();
+ this.earliestSequenceNumber = snStart;
+ this.nextSequenceNumber = snNext;
+ } catch (IllegalArgumentException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
+ }
+
+ private long earliestSequenceNumber;
+ private long nextSequenceNumber;
+ private TargetedNotification[] targetedNotifications;
+
+ private static void validate(TargetedNotification[] targetedNotifications,
+ long earliestSequenceNumber,
+ long nextSequenceNumber)
+ throws IllegalArgumentException {
+ if (targetedNotifications == null) {
+ final String msg = "Notifications null";
+ throw new IllegalArgumentException(msg);
+ }
+
+ if (earliestSequenceNumber < 0 || nextSequenceNumber < 0)
+ throw new IllegalArgumentException("Bad sequence numbers");
+ /* We used to check nextSequenceNumber >= earliestSequenceNumber
+ here. But in fact the opposite can legitimately be true if
+ notifications have been lost. */
+ }
}
diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/TargetedNotification.java
--- jdk/src/share/classes/javax/management/remote/TargetedNotification.java Tue Oct 15 16:47:11 2013 +0100
+++ jdk/src/share/classes/javax/management/remote/TargetedNotification.java Thu Jun 20 08:51:47 2013 +0200
@@ -26,6 +26,9 @@
package javax.management.remote;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import javax.management.Notification;
@@ -73,12 +76,9 @@
*/
public TargetedNotification(Notification notification,
Integer listenerID) {
+ validate(notification, listenerID);
// If we replace integer with int...
// this(notification,intValue(listenerID));
- if (notification == null) throw new
- IllegalArgumentException("Invalid notification: null");
- if (listenerID == null) throw new
- IllegalArgumentException("Invalid listener ID: null");
this.notif = notification;
this.id = listenerID;
}
@@ -115,13 +115,13 @@
* @serial A notification to transmit to the other side.
* @see #getNotification()
**/
- private final Notification notif;
+ private Notification notif;
/**
* @serial The ID of the listener to which the notification is
* targeted.
* @see #getListenerID()
**/
- private final Integer id;
+ private Integer id;
//private final int id;
// Needed if we use int instead of Integer...
@@ -130,4 +130,26 @@
// IllegalArgumentException("Invalid listener ID: null");
// return id.intValue();
// }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = ois.readFields();
+ Notification notification = (Notification)gf.get("notif", null);
+ Integer listenerId = (Integer)gf.get("id", null);
+ try {
+ validate(notification, listenerId);
+ this.notif = notification;
+ this.id = listenerId;
+ } catch (IllegalArgumentException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
+ }
+
+ private static void validate(Notification notif, Integer id) throws IllegalArgumentException {
+ if (notif == null) {
+ throw new IllegalArgumentException("Invalid notification: null");
+ }
+ if (id == null) {
+ throw new IllegalArgumentException("Invalid listener ID: null");
+ }
+ }
}

View File

@ -0,0 +1,719 @@
# HG changeset patch
# User bae
# Date 1368794871 -14400
# Fri May 17 16:47:51 2013 +0400
# Node ID 5405d79569f76d1285fd3c840489477a81bd9eff
# Parent a9be60a78488c7b261b92d927d1272afe2484e6b
8014093: Improve parsing of images
Reviewed-by: prr
diff -r a9be60a78488 -r 5405d79569f7 src/share/native/sun/awt/image/awt_parseImage.c
--- jdk/src/share/native/sun/awt/image/awt_parseImage.c Thu Jun 20 08:51:47 2013 +0200
+++ jdk/src/share/native/sun/awt/image/awt_parseImage.c Fri May 17 16:47:51 2013 +0400
@@ -797,363 +797,204 @@
return 1;
}
-/*
- * This routine will fill in a buffer of data for either 1 band or all
- * bands (if band == -1).
- */
#define MAX_TO_GRAB (10240)
-int awt_getPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned char *bufferP) {
- int w = rasterP->width;
- int h = rasterP->height;
- int numBands = rasterP->numBands;
+typedef union {
+ void *pv;
+ unsigned char *pb;
+ unsigned short *ps;
+} PixelData_t;
+
+
+int awt_getPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP) {
+ const int w = rasterP->width;
+ const int h = rasterP->height;
+ const int numBands = rasterP->numBands;
int y;
int i;
- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
+ int maxLines;
jobject jsm;
- int off;
+ int off = 0;
jarray jdata = NULL;
jobject jdatabuffer;
int *dataP;
- int maxBytes = w;
+ int maxSamples;
+ PixelData_t p;
+
+ if (bufferP == NULL) {
+ return -1;
+ }
+
+ if (rasterP->dataType != BYTE_DATA_TYPE &&
+ rasterP->dataType != SHORT_DATA_TYPE)
+ {
+ return -1;
+ }
+
+ p.pv = bufferP;
+
+ if (!SAFE_TO_MULT(w, numBands)) {
+ return -1;
+ }
+ maxSamples = w * numBands;
+
+ maxLines = maxSamples > MAX_TO_GRAB ? 1 : (MAX_TO_GRAB / maxSamples);
+ if (maxLines > h) {
+ maxLines = h;
+ }
+
+ if (!SAFE_TO_MULT(maxSamples, maxLines)) {
+ return -1;
+ }
+
+ maxSamples *= maxLines;
jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
g_RasterDataBufferID);
- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
+
+ jdata = (*env)->NewIntArray(env, maxSamples);
if (JNU_IsNull(env, jdata)) {
JNU_ThrowOutOfMemoryError(env, "Out of Memory");
return -1;
}
- /* Here is the generic code */
- if (band >= 0) {
- int dOff;
- if (band >= numBands) {
+ for (y = 0; y < h; y += maxLines) {
+ if (y + maxLines > h) {
+ maxLines = h - y;
+ maxSamples = w * numBands * maxLines;
+ }
+
+ (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
+ 0, y, w,
+ maxLines, jdata, jdatabuffer);
+
+ if ((*env)->ExceptionOccurred(env)) {
(*env)->DeleteLocalRef(env, jdata);
- JNU_ThrowInternalError(env, "Band out of range.");
return -1;
}
- off = 0;
- for (y=0; y < h; ) {
- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
- dOff = band;
- for (i=0; i < maxBytes; i++, dOff += numBands) {
- bufferP[off++] = (unsigned char) dataP[dOff];
- }
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
-
- if (y+maxLines < h) {
- y += maxLines;
- }
- else {
- y++;
- maxBytes = w;
- }
- }
- }
- else {
- off = 0;
- maxBytes *= numBands;
- for (y=0; y < h; ) {
- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
- for (i=0; i < maxBytes; i++) {
- bufferP[off++] = (unsigned char) dataP[i];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
-
- if (y+maxLines < h) {
- y += maxLines;
- }
- else {
- y++;
- maxBytes = w*numBands;
- }
+ dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+ NULL);
+ if (dataP == NULL) {
+ (*env)->DeleteLocalRef(env, jdata);
+ return -1;
}
+ switch (rasterP->dataType) {
+ case BYTE_DATA_TYPE:
+ for (i = 0; i < maxSamples; i ++) {
+ p.pb[off++] = (unsigned char) dataP[i];
+ }
+ break;
+ case SHORT_DATA_TYPE:
+ for (i = 0; i < maxSamples; i ++) {
+ p.ps[off++] = (unsigned short) dataP[i];
+ }
+ break;
+ }
+
+ (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+ JNI_ABORT);
}
(*env)->DeleteLocalRef(env, jdata);
- return 0;
+ return 1;
}
-int awt_setPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned char *bufferP) {
- int w = rasterP->width;
- int h = rasterP->height;
- int numBands = rasterP->numBands;
+
+int awt_setPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP) {
+ const int w = rasterP->width;
+ const int h = rasterP->height;
+ const int numBands = rasterP->numBands;
+
int y;
int i;
- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
+ int maxLines;
jobject jsm;
- int off;
+ int off = 0;
jarray jdata = NULL;
jobject jdatabuffer;
int *dataP;
- int maxBytes = w;
+ int maxSamples;
+ PixelData_t p;
+
+ if (bufferP == NULL) {
+ return -1;
+ }
+
+ if (rasterP->dataType != BYTE_DATA_TYPE &&
+ rasterP->dataType != SHORT_DATA_TYPE)
+ {
+ return -1;
+ }
+
+ p.pv = bufferP;
+
+ if (!SAFE_TO_MULT(w, numBands)) {
+ return -1;
+ }
+ maxSamples = w * numBands;
+
+ maxLines = maxSamples > MAX_TO_GRAB ? 1 : (MAX_TO_GRAB / maxSamples);
+ if (maxLines > h) {
+ maxLines = h;
+ }
+
+ if (!SAFE_TO_MULT(maxSamples, maxLines)) {
+ return -1;
+ }
+
+ maxSamples *= maxLines;
jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
g_RasterDataBufferID);
- /* Here is the generic code */
- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
+
+ jdata = (*env)->NewIntArray(env, maxSamples);
if (JNU_IsNull(env, jdata)) {
JNU_ThrowOutOfMemoryError(env, "Out of Memory");
return -1;
}
- if (band >= 0) {
- int dOff;
- if (band >= numBands) {
+
+ for (y = 0; y < h; y += maxLines) {
+ if (y + maxLines > h) {
+ maxLines = h - y;
+ maxSamples = w * numBands * maxLines;
+ }
+ dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+ NULL);
+ if (dataP == NULL) {
(*env)->DeleteLocalRef(env, jdata);
- JNU_ThrowInternalError(env, "Band out of range.");
return -1;
}
- off = 0;
- for (y=0; y < h; y+=maxLines) {
- if (y+maxLines > h) {
- maxBytes = w*numBands;
- maxLines = h - y;
+
+ switch (rasterP->dataType) {
+ case BYTE_DATA_TYPE:
+ for (i = 0; i < maxSamples; i ++) {
+ dataP[i] = p.pb[off++];
}
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
+ break;
+ case SHORT_DATA_TYPE:
+ for (i = 0; i < maxSamples; i ++) {
+ dataP[i] = p.ps[off++];
}
- dOff = band;
- for (i=0; i < maxBytes; i++, dOff += numBands) {
- dataP[dOff] = bufferP[off++];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
-
- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- }
- }
- else {
- off = 0;
- maxBytes *= numBands;
- for (y=0; y < h; y+=maxLines) {
- if (y+maxLines > h) {
- maxBytes = w*numBands;
- maxLines = h - y;
- }
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
- for (i=0; i < maxBytes; i++) {
- dataP[i] = bufferP[off++];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
-
- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
+ break;
}
+ (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+ JNI_ABORT);
+
+ (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
+ 0, y, w,
+ maxLines, jdata, jdatabuffer);
+
+ if ((*env)->ExceptionOccurred(env)) {
+ (*env)->DeleteLocalRef(env, jdata);
+ return -1;
+ }
}
(*env)->DeleteLocalRef(env, jdata);
- return 0;
+ return 1;
}
-int awt_getPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned short *bufferP) {
- int w = rasterP->width;
- int h = rasterP->height;
- int numBands = rasterP->numBands;
- int y;
- int i;
- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
- jobject jsm;
- int off;
- jarray jdata = NULL;
- jobject jdatabuffer;
- int *dataP;
- int maxBytes = w*maxLines;
-
- jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
- jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
- g_RasterDataBufferID);
- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
- if (JNU_IsNull(env, jdata)) {
- JNU_ThrowOutOfMemoryError(env, "Out of Memory");
- return -1;
- }
- /* Here is the generic code */
- if (band >= 0) {
- int dOff;
- if (band >= numBands) {
- (*env)->DeleteLocalRef(env, jdata);
- JNU_ThrowInternalError(env, "Band out of range.");
- return -1;
- }
- off = 0;
- for (y=0; y < h; y += maxLines) {
- if (y+maxLines > h) {
- maxBytes = w*numBands;
- maxLines = h - y;
- }
- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
-
- dOff = band;
- for (i=0; i < maxBytes; i++, dOff += numBands) {
- bufferP[off++] = (unsigned short) dataP[dOff];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
- }
- }
- else {
- off = 0;
- maxBytes *= numBands;
- for (y=0; y < h; y+=maxLines) {
- if (y+maxLines > h) {
- maxBytes = w*numBands;
- maxLines = h - y;
- }
- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
- for (i=0; i < maxBytes; i++) {
- bufferP[off++] = (unsigned short) dataP[i];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
- }
-
- }
-
- (*env)->DeleteLocalRef(env, jdata);
- return 0;
-}
-int awt_setPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned short *bufferP) {
- int w = rasterP->width;
- int h = rasterP->height;
- int numBands = rasterP->numBands;
- int y;
- int i;
- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
- jobject jsm;
- int off;
- jarray jdata = NULL;
- jobject jdatabuffer;
- int *dataP;
- int maxBytes = w;
-
- jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
- jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
- g_RasterDataBufferID);
- if (band >= numBands) {
- JNU_ThrowInternalError(env, "Band out of range.");
- return -1;
- }
- /* Here is the generic code */
- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
- if (JNU_IsNull(env, jdata)) {
- JNU_ThrowOutOfMemoryError(env, "Out of Memory");
- return -1;
- }
- if (band >= 0) {
- int dOff;
- off = 0;
- for (y=0; y < h; y+=maxLines) {
- if (y+maxLines > h) {
- maxBytes = w*numBands;
- maxLines = h - y;
- }
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
- dOff = band;
- for (i=0; i < maxBytes; i++, dOff += numBands) {
- dataP[dOff] = bufferP[off++];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
-
- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- }
- }
- else {
- off = 0;
- maxBytes *= numBands;
- for (y=0; y < h; y+=maxLines) {
- if (y+maxLines > h) {
- maxBytes = w*numBands;
- maxLines = h - y;
- }
- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
- NULL);
- if (dataP == NULL) {
- (*env)->DeleteLocalRef(env, jdata);
- return -1;
- }
- for (i=0; i < maxBytes; i++) {
- dataP[i] = bufferP[off++];
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
- JNI_ABORT);
-
- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
- 0, y, w,
- maxLines, jdata, jdatabuffer);
- }
-
- }
-
- (*env)->DeleteLocalRef(env, jdata);
- return 0;
-}
diff -r a9be60a78488 -r 5405d79569f7 src/share/native/sun/awt/image/awt_parseImage.h
--- jdk/src/share/native/sun/awt/image/awt_parseImage.h Thu Jun 20 08:51:47 2013 +0200
+++ jdk/src/share/native/sun/awt/image/awt_parseImage.h Fri May 17 16:47:51 2013 +0400
@@ -188,13 +188,8 @@
void awt_freeParsedImage(BufImageS_t *imageP, int freeImageP);
-int awt_getPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned char *bufferP);
-int awt_setPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned char *bufferP);
-int awt_getPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned short *bufferP);
-int awt_setPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
- unsigned short *bufferP);
+int awt_getPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);
+
+int awt_setPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);
#endif /* AWT_PARSE_IMAGE_H */
diff -r a9be60a78488 -r 5405d79569f7 src/share/native/sun/awt/medialib/awt_ImagingLib.c
--- jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Thu Jun 20 08:51:47 2013 +0200
+++ jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Fri May 17 16:47:51 2013 +0400
@@ -700,22 +700,7 @@
/* Means that we couldn't write directly into the destination buffer */
if (ddata == NULL) {
- unsigned char *bdataP;
- unsigned short *sdataP;
-
- /* Punt for now */
- switch (dstRasterP->dataType) {
- case BYTE_DATA_TYPE:
- bdataP = (unsigned char *) mlib_ImageGetData(dst);
- retStatus = (awt_setPixelByte(env, -1, dstRasterP, bdataP) >= 0) ;
- break;
- case SHORT_DATA_TYPE:
- sdataP = (unsigned short *) mlib_ImageGetData(dst);
- retStatus = (awt_setPixelShort(env, -1, dstRasterP, sdataP) >= 0) ;
- break;
- default:
- retStatus = 0;
- }
+ retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
}
/* Release the pinned memory */
@@ -1119,24 +1104,9 @@
/* Means that we couldn't write directly into the destination buffer */
if (ddata == NULL) {
- unsigned char *bdataP;
- unsigned short *sdataP;
-
/* Need to store it back into the array */
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
- /* Punt for now */
- switch (dst->type) {
- case MLIB_BYTE:
- bdataP = (unsigned char *) mlib_ImageGetData(dst);
- retStatus = (awt_setPixelByte(env, -1, dstRasterP, bdataP) >= 0) ;
- break;
- case MLIB_SHORT:
- sdataP = (unsigned short *) mlib_ImageGetData(dst);
- retStatus = (awt_setPixelShort(env, -1, dstRasterP, sdataP) >= 0) ;
- break;
- default:
- retStatus = 0;
- }
+ retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
}
}
@@ -1705,21 +1675,7 @@
* the destination buffer
*/
if (ddata == NULL) {
- unsigned char* bdataP;
- unsigned short* sdataP;
-
- switch (dstRasterP->dataType) {
- case BYTE_DATA_TYPE:
- bdataP = (unsigned char *) mlib_ImageGetData(dst);
- retStatus = (awt_setPixelByte(env, -1, dstRasterP, bdataP) >= 0) ;
- break;
- case SHORT_DATA_TYPE:
- sdataP = (unsigned short *) mlib_ImageGetData(dst);
- retStatus = (awt_setPixelShort(env, -1, dstRasterP, sdataP) >= 0) ;
- break;
- default:
- retStatus = 0;
- }
+ retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
}
/* Release the LUT */
@@ -2299,7 +2255,6 @@
mlib_image **mlibImagePP, void **dataPP, int isSrc) {
void *dataP;
unsigned char *cDataP;
- unsigned short *sdataP;
int dataType = BYTE_DATA_TYPE;
int width;
int height;
@@ -2485,8 +2440,7 @@
return -1;
}
if (isSrc) {
- cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP);
- if (awt_getPixelByte(env, -1, rasterP, cDataP) < 0) {
+ if (awt_getPixels(env, rasterP, mlib_ImageGetData(*mlibImagePP)) < 0) {
(*sMlibSysFns.deleteImageFP)(*mlibImagePP);
return -1;
}
@@ -2500,8 +2454,7 @@
return -1;
}
if (isSrc) {
- sdataP = (unsigned short *) mlib_ImageGetData(*mlibImagePP);
- if (awt_getPixelShort(env, -1, rasterP, sdataP) < 0) {
+ if (awt_getPixels(env, rasterP, mlib_ImageGetData(*mlibImagePP)) < 0) {
(*sMlibSysFns.deleteImageFP)(*mlibImagePP);
return -1;
}
@@ -2551,60 +2504,6 @@
}
}
-static int
-storeDstArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
- mlibHintS_t *hintP, mlib_image *mlibImP, void *ddata) {
- RasterS_t *rasterP = &dstP->raster;
-
- /* Nothing to do since it is the same image type */
- if (srcP->imageType == dstP->imageType
- && srcP->imageType != java_awt_image_BufferedImage_TYPE_CUSTOM
- && srcP->imageType != java_awt_image_BufferedImage_TYPE_BYTE_INDEXED
- && srcP->imageType != java_awt_image_BufferedImage_TYPE_BYTE_BINARY) {
- /* REMIND: Should check the ICM LUTS to see if it is the same */
- return 0;
- }
-
- /* These types are compatible with TYPE_INT_RGB */
- if (srcP->imageType == java_awt_image_BufferedImage_TYPE_INT_RGB
- && (dstP->imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB ||
- dstP->imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE)){
- return 0;
- }
-
- if (hintP->cvtSrcToDefault &&
- (srcP->cmodel.isAlphaPre == dstP->cmodel.isAlphaPre)) {
- if (srcP->cmodel.isAlphaPre) {
- if (dstP->imageType ==
- java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE)
- {
- return 0;
- }
- if (!srcP->cmodel.supportsAlpha &&
- dstP->imageType == java_awt_image_BufferedImage_TYPE_INT_RGB){
- return 0;
- }
- }
- else {
- /* REMIND: */
- }
- }
-
- if (dstP->cmodel.cmType == DIRECT_CM_TYPE) {
- /* Just need to move bits */
- if (mlibImP->type == MLIB_BYTE) {
- return awt_setPixelByte(env, -1, &dstP->raster,
- (unsigned char *) mlibImP->data);
- }
- else if (mlibImP->type == MLIB_SHORT) {
- return awt_setPixelByte(env, -1, &dstP->raster,
- (unsigned char *) mlibImP->data);
- }
- }
-
- return 0;
-}
-
#define ERR_BAD_IMAGE_LAYOUT (-2)
#define CHECK_DST_ARRAY(start_offset, elements_per_pixel) \
@@ -2717,8 +2616,7 @@
}
}
else if (mlibImP->type == MLIB_SHORT) {
- return awt_setPixelShort(env, -1, rasterP,
- (unsigned short *) mlibImP->data);
+ return awt_setPixels(env, rasterP, mlibImP->data);
}
}
else {

View File

@ -0,0 +1,190 @@
# HG changeset patch
# User bae
# Date 1369130199 -14400
# Tue May 21 13:56:39 2013 +0400
# Node ID d55d40616754cd93aa396719ddfd81bae584d4f0
# Parent 5405d79569f76d1285fd3c840489477a81bd9eff
8014102: Improve image conversion
Reviewed-by: prr
diff -r 5405d79569f7 -r d55d40616754 src/share/native/sun/awt/medialib/awt_ImagingLib.c
--- jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Fri May 17 16:47:51 2013 +0400
+++ jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Tue May 21 13:56:39 2013 +0400
@@ -1986,21 +1986,25 @@
return 0;
}
+#define NUM_LINES 10
+
static int
cvtCustomToDefault(JNIEnv *env, BufImageS_t *imageP, int component,
unsigned char *dataP) {
- ColorModelS_t *cmP = &imageP->cmodel;
- RasterS_t *rasterP = &imageP->raster;
+ const RasterS_t *rasterP = &imageP->raster;
+ const int w = rasterP->width;
+ const int h = rasterP->height;
+
int y;
- jobject jpixels = NULL;
+ jintArray jpixels = NULL;
jint *pixels;
unsigned char *dP = dataP;
-#define NUM_LINES 10
- int numLines = NUM_LINES;
+ int numLines = h > NUM_LINES ? NUM_LINES : h;
+
/* it is safe to calculate the scan length, because width has been verified
* on creation of the mlib image
*/
- int scanLength = rasterP->width * 4;
+ const int scanLength = w * 4;
int nbytes = 0;
if (!SAFE_TO_MULT(numLines, scanLength)) {
@@ -2009,71 +2013,99 @@
nbytes = numLines * scanLength;
- for (y=0; y < rasterP->height; y+=numLines) {
- /* getData, one scanline at a time */
- if (y+numLines > rasterP->height) {
- numLines = rasterP->height - y;
- nbytes = numLines * scanLength;
- }
- jpixels = (*env)->CallObjectMethod(env, imageP->jimage,
- g_BImgGetRGBMID, 0, y,
- rasterP->width, numLines,
- jpixels,0, rasterP->width);
- if (jpixels == NULL) {
- JNU_ThrowInternalError(env, "Can't retrieve pixels.");
- return -1;
- }
-
- pixels = (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL);
- memcpy(dP, pixels, nbytes);
- dP += nbytes;
- (*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels,
- JNI_ABORT);
- }
- return 0;
-}
-
-static int
-cvtDefaultToCustom(JNIEnv *env, BufImageS_t *imageP, int component,
- unsigned char *dataP) {
- ColorModelS_t *cmP = &imageP->cmodel;
- RasterS_t *rasterP = &imageP->raster;
- int y;
- jint *pixels;
- unsigned char *dP = dataP;
-#define NUM_LINES 10
- int numLines = NUM_LINES;
- int nbytes = rasterP->width*4*NUM_LINES;
- jintArray jpixels;
-
jpixels = (*env)->NewIntArray(env, nbytes);
if (JNU_IsNull(env, jpixels)) {
JNU_ThrowOutOfMemoryError(env, "Out of Memory");
return -1;
}
- for (y=0; y < rasterP->height; y+=NUM_LINES) {
- if (y+numLines > rasterP->height) {
- numLines = rasterP->height - y;
- nbytes = rasterP->width*4*numLines;
+ for (y = 0; y < h; y += numLines) {
+ if (y + numLines > h) {
+ numLines = h - y;
+ nbytes = numLines * scanLength;
}
+
+ (*env)->CallObjectMethod(env, imageP->jimage,
+ g_BImgGetRGBMID, 0, y,
+ w, numLines,
+ jpixels, 0, w);
+ if ((*env)->ExceptionOccurred(env)) {
+ (*env)->DeleteLocalRef(env, jpixels);
+ return -1;
+ }
+
pixels = (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL);
if (pixels == NULL) {
- /* JNI error */
+ (*env)->DeleteLocalRef(env, jpixels);
return -1;
}
+ memcpy(dP, pixels, nbytes);
+ dP += nbytes;
+
+ (*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels,
+ JNI_ABORT);
+ }
+
+ /* Need to release the array */
+ (*env)->DeleteLocalRef(env, jpixels);
+
+ return 0;
+}
+
+static int
+cvtDefaultToCustom(JNIEnv *env, BufImageS_t *imageP, int component,
+ unsigned char *dataP) {
+ const RasterS_t *rasterP = &imageP->raster;
+ const int w = rasterP->width;
+ const int h = rasterP->height;
+
+ int y;
+ jintArray jpixels = NULL;
+ jint *pixels;
+ unsigned char *dP = dataP;
+ int numLines = h > NUM_LINES ? NUM_LINES : h;
+
+ /* it is safe to calculate the scan length, because width has been verified
+ * on creation of the mlib image
+ */
+ const int scanLength = w * 4;
+
+ int nbytes = 0;
+ if (!SAFE_TO_MULT(numLines, scanLength)) {
+ return -1;
+ }
+
+ nbytes = numLines * scanLength;
+
+ jpixels = (*env)->NewIntArray(env, nbytes);
+ if (JNU_IsNull(env, jpixels)) {
+ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+ return -1;
+ }
+
+ for (y = 0; y < h; y += numLines) {
+ if (y + numLines > h) {
+ numLines = h - y;
+ nbytes = numLines * scanLength;
+ }
+
+ pixels = (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL);
+ if (pixels == NULL) {
+ (*env)->DeleteLocalRef(env, jpixels);
+ return -1;
+ }
+
memcpy(pixels, dP, nbytes);
dP += nbytes;
(*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels, 0);
- /* setData, one scanline at a time */
- /* Fix 4223648, 4184283 */
(*env)->CallVoidMethod(env, imageP->jimage, g_BImgSetRGBMID, 0, y,
- rasterP->width, numLines, jpixels, 0,
- rasterP->width);
+ w, numLines, jpixels,
+ 0, w);
if ((*env)->ExceptionOccurred(env)) {
+ (*env)->DeleteLocalRef(env, jpixels);
return -1;
}
}

View File

@ -0,0 +1,66 @@
# HG changeset patch
# User weijun
# Date 1381852916 -3600
# Tue Oct 15 17:01:56 2013 +0100
# Node ID 698fe468e8b9385c2f74709dca823800b32e0b55
# Parent d55d40616754cd93aa396719ddfd81bae584d4f0
8014341: Better service from Kerberos servers
Summary: read incoming data safely and take care of null return value
Reviewed-by: valeriep, ahgross
diff -r d55d40616754 -r 698fe468e8b9 src/share/classes/sun/security/krb5/KrbKdcReq.java
--- jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java Tue May 21 13:56:39 2013 +0400
+++ jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java Tue Oct 15 17:01:56 2013 +0100
@@ -151,11 +151,15 @@
savedException = e;
}
}
- if (ibuf == null && savedException != null) {
- if (savedException instanceof IOException) {
- throw (IOException) savedException;
+ if (ibuf == null) {
+ if (savedException != null) {
+ if (savedException instanceof IOException) {
+ throw (IOException) savedException;
+ } else {
+ throw (KrbException) savedException;
+ }
} else {
- throw (KrbException) savedException;
+ throw new IOException("Cannot get a KDC reply");
}
}
return tempKdc;
diff -r d55d40616754 -r 698fe468e8b9 src/share/classes/sun/security/krb5/internal/TCPClient.java
--- jdk/src/share/classes/sun/security/krb5/internal/TCPClient.java Tue May 21 13:56:39 2013 +0400
+++ jdk/src/share/classes/sun/security/krb5/internal/TCPClient.java Tue Oct 15 17:01:56 2013 +0100
@@ -30,6 +30,8 @@
package sun.security.krb5.internal;
+import sun.misc.IOUtils;
+
import java.io.*;
import java.net.*;
@@ -79,17 +81,15 @@
return null;
}
- byte data[] = new byte[len];
- count = readFully(data, len);
- if (count != len) {
+ try {
+ return IOUtils.readFully(in, len, true);
+ } catch (IOException ioe) {
if (Krb5.DEBUG) {
System.out.println(
">>>DEBUG: TCPClient could not read complete packet (" +
len + "/" + count + ")");
}
return null;
- } else {
- return data;
}
}

View File

@ -0,0 +1,43 @@
# HG changeset patch
# User jfranck
# Date 1382996803 0
# Mon Oct 28 21:46:43 2013 +0000
# Node ID e5a4a4ec7b21f3d092d0b29024ff903864d05543
# Parent 42fd9f22ae5e9aea017af28a2b5ff7a498753e15
8014349: (cl) Class.getDeclaredClass problematic in some class loader configurations
Reviewed-by: mchung, ahgross, darcy
diff -r 42fd9f22ae5e -r e5a4a4ec7b21 src/share/classes/java/lang/Class.java
--- jdk/src/share/classes/java/lang/Class.java Mon Oct 28 20:09:40 2013 +0000
+++ jdk/src/share/classes/java/lang/Class.java Mon Oct 28 21:46:43 2013 +0000
@@ -1093,7 +1093,17 @@
* @return the declaring class for this class
* @since JDK1.1
*/
- public native Class<?> getDeclaringClass();
+ @CallerSensitive
+ public Class<?> getDeclaringClass() {
+ final Class<?> candidate = getDeclaringClass0();
+
+ if (candidate != null)
+ candidate.checkPackageAccess(
+ ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
+ return candidate;
+ }
+
+ private native Class<?> getDeclaringClass0();
/**
diff -r 42fd9f22ae5e -r e5a4a4ec7b21 src/share/native/java/lang/Class.c
--- jdk/src/share/native/java/lang/Class.c Mon Oct 28 20:09:40 2013 +0000
+++ jdk/src/share/native/java/lang/Class.c Mon Oct 28 21:46:43 2013 +0000
@@ -70,7 +70,7 @@
{"getProtectionDomain0", "()" PD, (void *)&JVM_GetProtectionDomain},
{"setProtectionDomain0", "(" PD ")V", (void *)&JVM_SetProtectionDomain},
{"getDeclaredClasses0", "()[" CLS, (void *)&JVM_GetDeclaredClasses},
- {"getDeclaringClass", "()" CLS, (void *)&JVM_GetDeclaringClass},
+ {"getDeclaringClass0", "()" CLS, (void *)&JVM_GetDeclaringClass},
{"getGenericSignature", "()" STR, (void *)&JVM_GetClassSignature},
{"getRawAnnotations", "()" BA, (void *)&JVM_GetClassAnnotations},
{"getConstantPool", "()" CPL, (void *)&JVM_GetClassConstantPool},

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,156 @@
# HG changeset patch
# User sjiang
# Date 1374135176 -7200
# Thu Jul 18 10:12:56 2013 +0200
# Node ID 1e7a5ebc8013b812de73e452e809a3b545dd252f
# Parent 698fe468e8b9385c2f74709dca823800b32e0b55
8014534: Better profiling support
Summary: Validation of parameters
Reviewed-by: sspitsyn, skoivu, mchung
diff -r 698fe468e8b9 -r 1e7a5ebc8013 src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java
--- jdk/src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java Tue Oct 15 17:01:56 2013 +0100
+++ jdk/src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java Thu Jul 18 10:12:56 2013 +0200
@@ -53,7 +53,10 @@
public static void ObjectInit(Object obj)
{
- if ( engaged != 0 ) {
+ if ( engaged != 0) {
+ if (obj == null) {
+ throw new IllegalArgumentException("Null object.");
+ }
nativeObjectInit(Thread.currentThread(), obj);
}
}
@@ -66,7 +69,10 @@
public static void NewArray(Object obj)
{
- if ( engaged != 0 ) {
+ if ( engaged != 0) {
+ if (obj == null) {
+ throw new IllegalArgumentException("Null object.");
+ }
nativeNewArray(Thread.currentThread(), obj);
}
}
@@ -82,6 +88,14 @@
public static void CallSite(int cnum, int mnum)
{
if ( engaged != 0 ) {
+ if (cnum < 0) {
+ throw new IllegalArgumentException("Negative class index");
+ }
+
+ if (mnum < 0) {
+ throw new IllegalArgumentException("Negative method index");
+ }
+
nativeCallSite(Thread.currentThread(), cnum, mnum);
}
}
@@ -95,6 +109,14 @@
public static void ReturnSite(int cnum, int mnum)
{
if ( engaged != 0 ) {
+ if (cnum < 0) {
+ throw new IllegalArgumentException("Negative class index");
+ }
+
+ if (mnum < 0) {
+ throw new IllegalArgumentException("Negative method index");
+ }
+
nativeReturnSite(Thread.currentThread(), cnum, mnum);
}
}
diff -r 698fe468e8b9 -r 1e7a5ebc8013 src/share/demo/jvmti/hprof/hprof_class.c
--- jdk/src/share/demo/jvmti/hprof/hprof_class.c Tue Oct 15 17:01:56 2013 +0100
+++ jdk/src/share/demo/jvmti/hprof/hprof_class.c Thu Jul 18 10:12:56 2013 +0200
@@ -518,7 +518,12 @@
jmethodID method;
info = get_info(index);
- HPROF_ASSERT(mnum < info->method_count);
+ if (mnum >= info->method_count) {
+ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+ (*env)->ThrowNew(env, newExcCls, "Illegal mnum");
+
+ return NULL;
+ }
method = info->method[mnum].method_id;
if ( method == NULL ) {
char * name;
@@ -526,7 +531,12 @@
jclass clazz;
name = (char *)string_get(info->method[mnum].name_index);
- HPROF_ASSERT(name!=NULL);
+ if (name==NULL) {
+ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+ (*env)->ThrowNew(env, newExcCls, "Name not found");
+
+ return NULL;
+ }
sig = (char *)string_get(info->method[mnum].sig_index);
HPROF_ASSERT(sig!=NULL);
clazz = class_get_class(env, index);
diff -r 698fe468e8b9 -r 1e7a5ebc8013 src/share/demo/jvmti/hprof/hprof_event.c
--- jdk/src/share/demo/jvmti/hprof/hprof_event.c Tue Oct 15 17:01:56 2013 +0100
+++ jdk/src/share/demo/jvmti/hprof/hprof_event.c Thu Jul 18 10:12:56 2013 +0200
@@ -186,7 +186,12 @@
HPROF_ASSERT(env!=NULL);
HPROF_ASSERT(thread!=NULL);
- HPROF_ASSERT(cnum!=0 && cnum!=gdata->tracker_cnum);
+ if (cnum == 0 || cnum == gdata->tracker_cnum) {
+ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+ (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
+
+ return;
+ }
/* Prevent recursion into any BCI function for this thread (pstatus). */
if ( tls_get_tracker_status(env, thread, JNI_FALSE,
@@ -195,8 +200,10 @@
(*pstatus) = 1;
method = class_get_methodID(env, cnum, mnum);
- HPROF_ASSERT(method!=NULL);
- tls_push_method(tls_index, method);
+ if (method != NULL) {
+ tls_push_method(tls_index, method);
+ }
+
(*pstatus) = 0;
}
}
@@ -239,7 +246,13 @@
HPROF_ASSERT(env!=NULL);
HPROF_ASSERT(thread!=NULL);
- HPROF_ASSERT(cnum!=0 && cnum!=gdata->tracker_cnum);
+
+ if (cnum == 0 || cnum == gdata->tracker_cnum) {
+ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+ (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
+
+ return;
+ }
/* Prevent recursion into any BCI function for this thread (pstatus). */
if ( tls_get_tracker_status(env, thread, JNI_FALSE,
@@ -248,8 +261,10 @@
(*pstatus) = 1;
method = class_get_methodID(env, cnum, mnum);
- HPROF_ASSERT(method!=NULL);
- tls_pop_method(tls_index, thread, method);
+ if (method != NULL) {
+ tls_pop_method(tls_index, thread, method);
+ }
+
(*pstatus) = 0;
}
}

View File

@ -0,0 +1,115 @@
# HG changeset patch
# User leonidr
# Date 1382726240 -3600
# Fri Oct 25 19:37:20 2013 +0100
# Node ID e7ed5dad88eefc49130ae02bcbf329d72f18f12e
# Parent 47c881c5439a4542b19ab85f376e94fc2c0a5a57
8014718: Netbeans IDE begins to throw a lot exceptions since 7u25 b10
Summary: Removed logging from SunToolkit
Reviewed-by: art, omajid
diff -r 47c881c5439a -r e7ed5dad88ee src/share/classes/java/awt/Toolkit.java
--- jdk/src/share/classes/java/awt/Toolkit.java Wed May 01 00:49:21 2013 +0200
+++ jdk/src/share/classes/java/awt/Toolkit.java Fri Oct 25 19:37:20 2013 +0100
@@ -48,8 +48,6 @@
import java.io.FileInputStream;
import java.util.*;
-import java.util.logging.*;
-
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import sun.awt.AppContext;
@@ -1922,7 +1920,7 @@
*/
public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
- private static final Logger log = Logger.getLogger("java.awt.Toolkit");
+ // 8014736: logging has been removed from Toolkit
private static final int LONG_BITS = 64;
private int[] calls = new int[LONG_BITS];
@@ -2089,12 +2087,6 @@
}
synchronized int countAWTEventListeners(long eventMask) {
- if (log.isLoggable(Level.FINE)) {
- if (eventMask == 0) {
- log.log(Level.FINE, "Assertion (eventMask != 0) failed");
- }
- }
-
int ci = 0;
for (; eventMask != 0; eventMask >>>= 1, ci++) {
}
diff -r 47c881c5439a -r e7ed5dad88ee src/share/classes/sun/awt/SunToolkit.java
--- jdk/src/share/classes/sun/awt/SunToolkit.java Wed May 01 00:49:21 2013 +0200
+++ jdk/src/share/classes/sun/awt/SunToolkit.java Fri Oct 25 19:37:20 2013 +0100
@@ -58,7 +58,7 @@
implements WindowClosingSupport, WindowClosingListener,
ComponentFactory, InputMethodSupport {
- private static final Logger log = Logger.getLogger("sun.awt.SunToolkit");
+ // 8014736: logging has been removed from SunToolkit
/* Load debug settings for native code */
static {
@@ -554,10 +554,6 @@
if (event == null) {
throw new NullPointerException();
}
- AppContext eventContext = targetToAppContext(event.getSource());
- if (eventContext != null && !eventContext.equals(appContext)) {
- log.fine("Event posted on wrong app context : " + event);
- }
PostEventQueue postEventQueue =
(PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
if(postEventQueue != null) {
@@ -938,10 +934,6 @@
//with scale factors x1, x3/4, x2/3, xN, x1/N.
Image im = i.next();
if (im == null) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "SunToolkit.getScaledIconImage: " +
- "Skipping the image passed into Java because it's null.");
- }
continue;
}
if (im instanceof ToolkitImage) {
@@ -954,10 +946,6 @@
iw = im.getWidth(null);
ih = im.getHeight(null);
} catch (Exception e){
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "SunToolkit.getScaledIconImage: " +
- "Perhaps the image passed into Java is broken. Skipping this icon.");
- }
continue;
}
if (iw > 0 && ih > 0) {
@@ -1029,14 +1017,6 @@
try {
int x = (width - bestWidth) / 2;
int y = (height - bestHeight) / 2;
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "WWindowPeer.getScaledIconData() result : " +
- "w : " + width + " h : " + height +
- " iW : " + bestImage.getWidth(null) + " iH : " + bestImage.getHeight(null) +
- " sim : " + bestSimilarity + " sf : " + bestScaleFactor +
- " adjW : " + bestWidth + " adjH : " + bestHeight +
- " x : " + x + " y : " + y);
- }
g.drawImage(bestImage, x, y, bestWidth, bestHeight, null);
} finally {
g.dispose();
@@ -1047,10 +1027,6 @@
public static DataBufferInt getScaledIconData(java.util.List<Image> imageList, int width, int height) {
BufferedImage bimage = getScaledIconImage(imageList, width, height);
if (bimage == null) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "SunToolkit.getScaledIconData: " +
- "Perhaps the image passed into Java is broken. Skipping this icon.");
- }
return null;
}
Raster raster = bimage.getRaster();

View File

@ -0,0 +1,205 @@
# HG changeset patch
# User mchung
# Date 1368826191 25200
# Fri May 17 14:29:51 2013 -0700
# Node ID 0bf55b4c8a7bbea02a9d848b2a5451adbd6a6ac4
# Parent 8733761ca20bb4e46405e274c514bda0e0616a21
8014745: Provide a switch to allow stack walk search of resource bundle
Reviewed-by: alanb, jgish
diff -r 8733761ca20b -r 0bf55b4c8a7b make/java/java/mapfile-vers
--- jdk/make/java/java/mapfile-vers Wed Jun 26 22:50:47 2013 -0500
+++ jdk/make/java/java/mapfile-vers Fri May 17 14:29:51 2013 -0700
@@ -271,6 +271,7 @@
Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0;
Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
Java_sun_reflect_Reflection_getCallerClass;
+ Java_sun_reflect_Reflection_getCallerClass0;
Java_sun_reflect_Reflection_getClassAccessFlags;
Java_sun_misc_Version_getJdkVersionInfo;
Java_sun_misc_Version_getJdkSpecialVersion;
diff -r 8733761ca20b -r 0bf55b4c8a7b src/share/classes/java/util/logging/Logger.java
--- jdk/src/share/classes/java/util/logging/Logger.java Wed Jun 26 22:50:47 2013 -0500
+++ jdk/src/share/classes/java/util/logging/Logger.java Fri May 17 14:29:51 2013 -0700
@@ -303,8 +303,13 @@
// null, we assume it's a system logger and add it to the system context.
// These system loggers only set the resource bundle to the given
// resource bundle name (rather than the default system resource bundle).
- private static class SystemLoggerHelper {
- static boolean disableCallerCheck = getBooleanProperty("sun.util.logging.disableCallerCheck");
+ private static class LoggerHelper {
+ static boolean disableCallerCheck =
+ getBooleanProperty("sun.util.logging.disableCallerCheck");
+
+ // workaround to turn on the old behavior for resource bundle search
+ static boolean allowStackWalkSearch =
+ getBooleanProperty("jdk.logging.allowStackWalkSearch");
private static boolean getBooleanProperty(final String key) {
String s = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
@@ -318,7 +323,7 @@
private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
LogManager manager = LogManager.getLogManager();
SecurityManager sm = System.getSecurityManager();
- if (sm != null && !SystemLoggerHelper.disableCallerCheck) {
+ if (sm != null && !LoggerHelper.disableCallerCheck) {
if (caller.getClassLoader() == null) {
return manager.demandSystemLogger(name, resourceBundleName);
}
@@ -1407,25 +1412,61 @@
if (useCallersClassLoader) {
// Try with the caller's ClassLoader
ClassLoader callersClassLoader = getCallersClassLoader();
+ if (callersClassLoader != null && callersClassLoader != cl) {
+ try {
+ catalog = ResourceBundle.getBundle(name, currentLocale,
+ callersClassLoader);
+ catalogName = name;
+ catalogLocale = currentLocale;
+ return catalog;
+ } catch (MissingResourceException ex) {
+ }
+ }
+ }
- if (callersClassLoader == null || callersClassLoader == cl) {
- return null;
- }
-
- try {
- catalog = ResourceBundle.getBundle(name, currentLocale,
- callersClassLoader);
- catalogName = name;
- catalogLocale = currentLocale;
- return catalog;
- } catch (MissingResourceException ex) {
- return null; // no luck
- }
+ // If -Djdk.logging.allowStackWalkSearch=true is set,
+ // does stack walk to search for the resource bundle
+ if (LoggerHelper.allowStackWalkSearch) {
+ return findResourceBundleFromStack(name, currentLocale, cl);
} else {
return null;
}
}
+ /**
+ * This method will fail when running with a VM that enforces caller-sensitive
+ * methods and only allows to get the immediate caller.
+ */
+ @CallerSensitive
+ private synchronized ResourceBundle findResourceBundleFromStack(String name,
+ Locale locale,
+ ClassLoader cl)
+ {
+ for (int ix = 0; ; ix++) {
+ Class<?> clz = sun.reflect.Reflection.getCallerClass(ix);
+ if (clz == null) {
+ break;
+ }
+ ClassLoader cl2 = clz.getClassLoader();
+ if (cl2 == null) {
+ cl2 = ClassLoader.getSystemClassLoader();
+ }
+ if (cl == cl2) {
+ // We've already checked this classloader.
+ continue;
+ }
+ cl = cl2;
+ try {
+ catalog = ResourceBundle.getBundle(name, locale, cl);
+ catalogName = name;
+ catalogLocale = locale;
+ return catalog;
+ } catch (MissingResourceException ex) {
+ }
+ }
+ return null;
+ }
+
// Private utility method to initialize our one entry
// resource bundle name cache and the callers ClassLoader
// Note: for consistency reasons, we are careful to check
diff -r 8733761ca20b -r 0bf55b4c8a7b src/share/classes/sun/reflect/Reflection.java
--- jdk/src/share/classes/sun/reflect/Reflection.java Wed Jun 26 22:50:47 2013 -0500
+++ jdk/src/share/classes/sun/reflect/Reflection.java Fri May 17 14:29:51 2013 -0700
@@ -58,6 +58,21 @@
@CallerSensitive
public static native Class getCallerClass();
+ /**
+ * @deprecated No replacement. This method will be removed in the next
+ * JDK 7 update release.
+ */
+ @Deprecated
+ @CallerSensitive
+ public static Class getCallerClass(int depth) {
+ return getCallerClass0(depth);
+ }
+
+ // If the VM enforces getting caller class with @CallerSensitive,
+ // this will fail anyway.
+ @CallerSensitive
+ private static native Class getCallerClass0(int depth);
+
/** Retrieves the access flags written to the class file. For
inner classes these flags may differ from those returned by
Class.getModifiers(), which searches the InnerClasses
diff -r 8733761ca20b -r 0bf55b4c8a7b src/share/native/sun/reflect/Reflection.c
--- jdk/src/share/native/sun/reflect/Reflection.c Wed Jun 26 22:50:47 2013 -0500
+++ jdk/src/share/native/sun/reflect/Reflection.c Fri May 17 14:29:51 2013 -0700
@@ -34,6 +34,12 @@
return JVM_GetCallerClass(env, 2);
}
+JNIEXPORT jclass JNICALL Java_sun_reflect_Reflection_getCallerClass0
+(JNIEnv *env, jclass unused, jint depth)
+{
+ return JVM_GetCallerClass(env, depth);
+}
+
JNIEXPORT jint JNICALL Java_sun_reflect_Reflection_getClassAccessFlags
(JNIEnv *env, jclass unused, jclass cls)
{
diff -r 8733761ca20b -r 0bf55b4c8a7b test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
--- jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Wed Jun 26 22:50:47 2013 -0500
+++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Fri May 17 14:29:51 2013 -0700
@@ -28,6 +28,7 @@
* @author Jim Gish
* @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker
* @run main/othervm ResourceBundleSearchTest
+ * @run main/othervm -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest
*/
import java.net.URL;
import java.net.URLClassLoader;
@@ -79,7 +80,15 @@
// Test 1 - can we find a Logger bundle from doing a stack search?
// We shouldn't be able to
- assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
+ // unless -Djdk.logging.allowStackWalkSearch=true is set
+
+ boolean allowStackWalkSearch = Boolean.getBoolean("jdk.logging.allowStackWalkSearch");
+ if (allowStackWalkSearch) {
+ assertTrue(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
+ } else {
+ // default behavior
+ assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
+ }
// Test 2 - can we find a Logger bundle off of the Thread context class
// loader? We should be able to.
@@ -111,8 +120,10 @@
// Test 6 - first call getLogger("myLogger").
// Then call getLogger("myLogger","bundleName") from a different ClassLoader
// Make sure we find the bundle
- assertTrue(testGetBundleFromSecondCallersClassLoader(),
- "6-testGetBundleFromSecondCallersClassLoader");
+ if (!allowStackWalkSearch) {
+ assertTrue(testGetBundleFromSecondCallersClassLoader(),
+ "6-testGetBundleFromSecondCallersClassLoader");
+ }
report();
}

View File

@ -0,0 +1,100 @@
# HG changeset patch
# User smarks
# Date 1381854512 -3600
# Tue Oct 15 17:28:32 2013 +0100
# Node ID a1bc92467cc07e1cb3c93d0b3b629eda4c45238f
# Parent 1e7a5ebc8013b812de73e452e809a3b545dd252f
8014987: Augment serialization handling
Reviewed-by: alanb, coffeys, skoivu
diff -r 1e7a5ebc8013 -r a1bc92467cc0 src/share/classes/java/io/ObjectInputStream.java
--- jdk/src/share/classes/java/io/ObjectInputStream.java Thu Jul 18 10:12:56 2013 +0200
+++ jdk/src/share/classes/java/io/ObjectInputStream.java Tue Oct 15 17:28:32 2013 +0100
@@ -489,11 +489,12 @@
public void defaultReadObject()
throws IOException, ClassNotFoundException
{
- if (curContext == null) {
+ SerialCallbackContext ctx = curContext;
+ if (ctx == null) {
throw new NotActiveException("not in call to readObject");
}
- Object curObj = curContext.getObj();
- ObjectStreamClass curDesc = curContext.getDesc();
+ Object curObj = ctx.getObj();
+ ObjectStreamClass curDesc = ctx.getDesc();
bin.setBlockDataMode(false);
defaultReadFields(curObj, curDesc);
bin.setBlockDataMode(true);
@@ -527,11 +528,12 @@
public ObjectInputStream.GetField readFields()
throws IOException, ClassNotFoundException
{
- if (curContext == null) {
+ SerialCallbackContext ctx = curContext;
+ if (ctx == null) {
throw new NotActiveException("not in call to readObject");
}
- Object curObj = curContext.getObj();
- ObjectStreamClass curDesc = curContext.getDesc();
+ Object curObj = ctx.getObj();
+ ObjectStreamClass curDesc = ctx.getDesc();
bin.setBlockDataMode(false);
GetFieldImpl getField = new GetFieldImpl(curDesc);
getField.readFields();
@@ -1964,7 +1966,6 @@
private void defaultReadFields(Object obj, ObjectStreamClass desc)
throws IOException
{
- // REMIND: is isInstance check necessary?
Class cl = desc.forClass();
if (cl != null && obj != null && !cl.isInstance(obj)) {
throw new ClassCastException();
diff -r 1e7a5ebc8013 -r a1bc92467cc0 src/share/classes/java/io/ObjectOutputStream.java
--- jdk/src/share/classes/java/io/ObjectOutputStream.java Thu Jul 18 10:12:56 2013 +0200
+++ jdk/src/share/classes/java/io/ObjectOutputStream.java Tue Oct 15 17:28:32 2013 +0100
@@ -430,11 +430,12 @@
* <code>OutputStream</code>
*/
public void defaultWriteObject() throws IOException {
- if ( curContext == null ) {
+ SerialCallbackContext ctx = curContext;
+ if (ctx == null) {
throw new NotActiveException("not in call to writeObject");
}
- Object curObj = curContext.getObj();
- ObjectStreamClass curDesc = curContext.getDesc();
+ Object curObj = ctx.getObj();
+ ObjectStreamClass curDesc = ctx.getDesc();
bout.setBlockDataMode(false);
defaultWriteFields(curObj, curDesc);
bout.setBlockDataMode(true);
@@ -452,11 +453,12 @@
*/
public ObjectOutputStream.PutField putFields() throws IOException {
if (curPut == null) {
- if (curContext == null) {
+ SerialCallbackContext ctx = curContext;
+ if (ctx == null) {
throw new NotActiveException("not in call to writeObject");
}
- Object curObj = curContext.getObj();
- ObjectStreamClass curDesc = curContext.getDesc();
+ Object curObj = ctx.getObj();
+ ObjectStreamClass curDesc = ctx.getDesc();
curPut = new PutFieldImpl(curDesc);
}
return curPut;
@@ -1516,7 +1518,11 @@
private void defaultWriteFields(Object obj, ObjectStreamClass desc)
throws IOException
{
- // REMIND: perform conservative isInstance check here?
+ Class<?> cl = desc.forClass();
+ if (cl != null && obj != null && !cl.isInstance(obj)) {
+ throw new ClassCastException();
+ }
+
desc.checkDefaultSerialize();
int primDataSize = desc.getPrimDataSize();

View File

@ -0,0 +1,273 @@
# HG changeset patch
# User prr
# Date 1383010378 0
# Tue Oct 29 01:32:58 2013 +0000
# Node ID bac5d0b011562017738501f02f7db4f39522a62e
# Parent 35c5b3f404aac29ec5cccaeb32106af47546b6db
8015144: Performance regression in ICU OpenType Layout library
Reviewed-by: srl, jgodinez
diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/GlyphIterator.cpp
--- jdk/src/share/native/sun/font/layout/GlyphIterator.cpp Wed Jun 05 18:39:44 2013 +0100
+++ jdk/src/share/native/sun/font/layout/GlyphIterator.cpp Tue Oct 29 01:32:58 2013 +0000
@@ -66,6 +66,7 @@
nextLimit = -1;
prevLimit = glyphCount;
}
+ filterResetCache();
}
GlyphIterator::GlyphIterator(GlyphIterator &that)
@@ -84,6 +85,7 @@
glyphGroup = that.glyphGroup;
glyphClassDefinitionTable = that.glyphClassDefinitionTable;
markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
+ filterResetCache();
}
GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask)
@@ -102,6 +104,7 @@
glyphGroup = 0;
glyphClassDefinitionTable = that.glyphClassDefinitionTable;
markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
+ filterResetCache();
}
GlyphIterator::GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags)
@@ -120,6 +123,7 @@
glyphGroup = that.glyphGroup;
glyphClassDefinitionTable = that.glyphClassDefinitionTable;
markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
+ filterResetCache();
}
GlyphIterator::~GlyphIterator()
@@ -133,6 +137,7 @@
featureMask = newFeatureMask;
glyphGroup = 0;
lookupFlags = newLookupFlags;
+ filterResetCache();
}
LEGlyphID *GlyphIterator::insertGlyphs(le_int32 count, LEErrorCode& success)
@@ -381,53 +386,68 @@
glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd());
}
-le_bool GlyphIterator::filterGlyph(le_uint32 index) const
-{
- LEErrorCode success = LE_NO_ERROR;
- LEGlyphID glyphID = glyphStorage[index];
- le_int32 glyphClass = gcdNoGlyphClass;
-
- if (LE_GET_GLYPH(glyphID) >= 0xFFFE) {
- return TRUE;
+void GlyphIterator::filterResetCache(void) {
+ filterCacheValid = FALSE;
}
+le_bool GlyphIterator::filterGlyph(le_uint32 index)
+{
+ LEGlyphID glyphID = glyphStorage[index];
+
+ if (!filterCacheValid || filterCache.id != glyphID) {
+ filterCache.id = glyphID;
+
+ le_bool &filterResult = filterCache.result; // NB: Making this a reference to accept the updated value, in case
+ // we want more fancy cacheing in the future.
+ if (LE_GET_GLYPH(glyphID) >= 0xFFFE) {
+ filterResult = TRUE;
+ } else {
+ LEErrorCode success = LE_NO_ERROR;
+ le_int32 glyphClass = gcdNoGlyphClass;
if (glyphClassDefinitionTable.isValid()) {
glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphClassDefinitionTable, glyphID, success);
}
-
- switch (glyphClass)
- {
+ switch (glyphClass) {
case gcdNoGlyphClass:
- return FALSE;
+ filterResult = FALSE;
+ break;
case gcdSimpleGlyph:
- return (lookupFlags & lfIgnoreBaseGlyphs) != 0;
+ filterResult = (lookupFlags & lfIgnoreBaseGlyphs) != 0;
+ break;
case gcdLigatureGlyph:
- return (lookupFlags & lfIgnoreLigatures) != 0;
+ filterResult = (lookupFlags & lfIgnoreLigatures) != 0;
+ break;
case gcdMarkGlyph:
- {
if ((lookupFlags & lfIgnoreMarks) != 0) {
- return TRUE;
- }
-
+ filterResult = TRUE;
+ } else {
le_uint16 markAttachType = (lookupFlags & lfMarkAttachTypeMask) >> lfMarkAttachTypeShift;
if ((markAttachType != 0) && (markAttachClassDefinitionTable.isValid())) {
- return markAttachClassDefinitionTable
- -> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType;
+ filterResult = (markAttachClassDefinitionTable
+ -> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType);
+ } else {
+ filterResult = FALSE;
+ }
+ }
+ break;
+
+ case gcdComponentGlyph:
+ filterResult = ((lookupFlags & lfIgnoreBaseGlyphs) != 0);
+ break;
+
+ default:
+ filterResult = FALSE;
+ break;
+ }
+ }
+ filterCacheValid = TRUE;
}
- return FALSE;
- }
-
- case gcdComponentGlyph:
- return (lookupFlags & lfIgnoreBaseGlyphs) != 0;
-
- default:
- return FALSE;
- }
+ return filterCache.result;
}
le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup) const
diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/GlyphIterator.h
--- jdk/src/share/native/sun/font/layout/GlyphIterator.h Wed Jun 05 18:39:44 2013 +0100
+++ jdk/src/share/native/sun/font/layout/GlyphIterator.h Tue Oct 29 01:32:58 2013 +0000
@@ -98,7 +98,7 @@
le_int32 applyInsertions();
private:
- le_bool filterGlyph(le_uint32 index) const;
+ le_bool filterGlyph(le_uint32 index);
le_bool hasFeatureTag(le_bool matchGroup) const;
le_bool nextInternal(le_uint32 delta = 1);
le_bool prevInternal(le_uint32 delta = 1);
@@ -121,6 +121,14 @@
LEReferenceTo<MarkAttachClassDefinitionTable> markAttachClassDefinitionTable;
GlyphIterator &operator=(const GlyphIterator &other); // forbid copying of this class
+
+ struct {
+ LEGlyphID id;
+ le_bool result;
+ } filterCache;
+ le_bool filterCacheValid;
+
+ void filterResetCache(void);
};
U_NAMESPACE_END
diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/LETableReference.h
--- jdk/src/share/native/sun/font/layout/LETableReference.h Wed Jun 05 18:39:44 2013 +0100
+++ jdk/src/share/native/sun/font/layout/LETableReference.h Tue Oct 29 01:32:58 2013 +0000
@@ -431,7 +431,7 @@
* @param success error status
* @param atPtr location of reference - if NULL, will be at offset zero (i.e. downcast of parent). Otherwise must be a pointer within parent's bounds.
*/
- LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
+ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
: LETableReference(parent, parent.ptrToOffset(atPtr, success), LE_UINTPTR_MAX, success) {
verifyLength(parent.ptrToOffset(atPtr,success), LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
@@ -439,31 +439,31 @@
/**
* ptr plus offset
*/
- LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
+ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
: LETableReference(parent, parent.ptrToOffset(atPtr, success)+offset, LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
- LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
+ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
: LETableReference(parent, offset, LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
- LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
+ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
: LETableReference(parent, 0, LE_UINTPTR_MAX, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
- LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
+ inline LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
: LETableReference(font, tableTag, success) {
verifyLength(0, LETableVarSizer<T>::getSize(), success);
if(LE_FAILURE(success)) clear();
}
- LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
- LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
- LEReferenceTo() : LETableReference(NULL) {}
+ inline LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
+ inline LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
+ inline LEReferenceTo() : LETableReference(NULL) {}
- LEReferenceTo<T>& operator=(const T* other) {
+ inline LEReferenceTo<T>& operator=(const T* other) {
setRaw(other);
return *this;
}
diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/OpenTypeUtilities.cpp
--- jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp Wed Jun 05 18:39:44 2013 +0100
+++ jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp Tue Oct 29 01:32:58 2013 +0000
@@ -79,6 +79,7 @@
Offset OpenTypeUtilities::getTagOffset(LETag tag, const LEReferenceToArrayOf<TagAndOffsetRecord> &records, LEErrorCode &success)
{
+ const TagAndOffsetRecord *r0 = (const TagAndOffsetRecord*)records.getAlias();
if(LE_FAILURE(success)) return 0;
le_uint32 recordCount = records.getCount();
@@ -89,17 +90,17 @@
le_int32 index = 0;
{
- const ATag &aTag = records.getAlias(extra,success)->tag;
+ const ATag &aTag = (r0+extra)->tag;
if (SWAPT(aTag) <= tag) {
index = extra;
}
}
- while (probe > (1 << 0) && LE_SUCCESS(success)) {
+ while (probe > (1 << 0)) {
probe >>= 1;
{
- const ATag &aTag = records.getAlias(index+probe,success)->tag;
+ const ATag &aTag = (r0+index+probe)->tag;
if (SWAPT(aTag) <= tag) {
index += probe;
}
@@ -107,9 +108,9 @@
}
{
- const ATag &aTag = records.getAlias(index,success)->tag;
+ const ATag &aTag = (r0+index)->tag;
if (SWAPT(aTag) == tag) {
- return SWAPW(records.getAlias(index,success)->offset);
+ return SWAPW((r0+index)->offset);
}
}

View File

@ -0,0 +1,60 @@
# HG changeset patch
# User erikj
# Date 1381419677 -3600
# Thu Oct 10 16:41:17 2013 +0100
# Node ID 918a90950fa69e5247e3af2599d2e7674d64e3d6
# Parent d0b5dc55e72cde11331399cbb960458b8f45ea4a
8015614: Update build settings
Reviewed-by: tbell, dholmes, ahgross
diff -r d0b5dc55e72c -r 918a90950fa6 make/windows/makefiles/compile.make
--- hotspot/make/windows/makefiles/compile.make Tue Sep 17 12:04:11 2013 +0200
+++ hotspot/make/windows/makefiles/compile.make Thu Oct 10 16:41:17 2013 +0100
@@ -140,6 +140,7 @@
!if "$(MSC_VER)" == "1600"
COMPILER_NAME=VS2010
!endif
+SAFESEH_FLAG = /SAFESEH
!endif
# By default, we do not want to use the debug version of the msvcrt.dll file
@@ -170,6 +171,7 @@
PRODUCT_OPT_OPTION = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION = /Od
+SAFESEH_FLAG = /SAFESEH
!endif
!if "$(COMPILER_NAME)" == "VS2005"
@@ -186,6 +188,7 @@
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
MT=mt.exe
+SAFESEH_FLAG = /SAFESEH
!endif
!if "$(COMPILER_NAME)" == "VS2008"
@@ -209,8 +212,8 @@
# as resources inside build artifacts.
MT=mt.exe
!if "$(BUILDARCH)" == "i486"
-LD_FLAGS = /SAFESEH $(LD_FLAGS)
-!endif
+LD_FLAGS = $(SAFESEH_FLAG) $(LD_FLAGS)
+SAFESEH_FLAG = /SAFESEH
!endif
# Compile for space above time.
diff -r d0b5dc55e72c -r 918a90950fa6 make/windows/makefiles/sa.make
--- hotspot/make/windows/makefiles/sa.make Tue Sep 17 12:04:11 2013 +0200
+++ hotspot/make/windows/makefiles/sa.make Thu Oct 10 16:41:17 2013 +0100
@@ -107,6 +107,9 @@
!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
SA_LFLAGS = $(SA_LFLAGS) /map /debug
!endif
+!if "$(BUILDARCH)" == "i486"
+SA_LFLAGS = $(SAFESEH_FLAG) $(SA_LFLAGS)
+!endif
# Note that we do not keep sawindbj.obj around as it would then
# get included in the dumpbin command in build_vm_def.sh

View File

@ -0,0 +1,28 @@
# HG changeset patch
# User weijun
# Date 1371090681 -28800
# Thu Jun 13 10:31:21 2013 +0800
# Node ID e10e9bfb11b073ee1c108e7a51078d3ead7a2d72
# Parent a1bc92467cc07e1cb3c93d0b3b629eda4c45238f
8015731: Subject java.security.auth.subject to improvements
Reviewed-by: skoivu, mullan
diff -r a1bc92467cc0 -r e10e9bfb11b0 src/share/classes/javax/security/auth/Subject.java
--- jdk/src/share/classes/javax/security/auth/Subject.java Tue Oct 15 17:28:32 2013 +0100
+++ jdk/src/share/classes/javax/security/auth/Subject.java Thu Jun 13 10:31:21 2013 +0800
@@ -1305,8 +1305,14 @@
{
ObjectInputStream.GetField fields = ois.readFields();
subject = (Subject) fields.get("this$0", null);
- elements = (LinkedList<E>) fields.get("elements", null);
which = fields.get("which", 0);
+
+ LinkedList<E> tmp = (LinkedList<E>) fields.get("elements", null);
+ if (tmp.getClass() != LinkedList.class) {
+ elements = new LinkedList<E>(tmp);
+ } else {
+ elements = tmp;
+ }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
# HG changeset patch
# User coffeys
# Date 1370453984 -3600
# Wed Jun 05 18:39:44 2013 +0100
# Node ID 35c5b3f404aac29ec5cccaeb32106af47546b6db
# Parent 20c88fd14959c6a4df2e0f36bd759b56efa6f2cb
8015965: (process) Typo in name of property to allow ambiguous commands
Reviewed-by: alanb
diff -r 20c88fd14959 -r 35c5b3f404aa src/windows/classes/java/lang/ProcessImpl.java
--- jdk/src/windows/classes/java/lang/ProcessImpl.java Tue Oct 29 01:07:01 2013 +0000
+++ jdk/src/windows/classes/java/lang/ProcessImpl.java Wed Jun 05 18:39:44 2013 +0100
@@ -218,13 +218,13 @@
{
String cmdstr;
SecurityManager security = System.getSecurityManager();
- boolean allowAmbigousCommands = false;
+ boolean allowAmbiguousCommands = false;
if (security == null) {
- String value = System.getProperty("jdk.lang.Process.allowAmbigousCommands");
+ String value = System.getProperty("jdk.lang.Process.allowAmbiguousCommands");
if (value != null)
- allowAmbigousCommands = !"false".equalsIgnoreCase(value);
+ allowAmbiguousCommands = !"false".equalsIgnoreCase(value);
}
- if (allowAmbigousCommands) {
+ if (allowAmbiguousCommands) {
// Legacy mode.
// Normalize path if possible.
diff -r 20c88fd14959 -r 35c5b3f404aa test/java/lang/Runtime/exec/ExecCommand.java
--- jdk/test/java/lang/Runtime/exec/ExecCommand.java Tue Oct 29 01:07:01 2013 +0000
+++ jdk/test/java/lang/Runtime/exec/ExecCommand.java Wed Jun 05 18:39:44 2013 +0100
@@ -129,7 +129,7 @@
for (int k = 0; k < 3; ++k) {
switch (k) {
case 1:
- System.setProperty("jdk.lang.Process.allowAmbigousCommands", "");
+ System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
break;
case 2:
System.setSecurityManager( new SecurityMan() );

View File

@ -0,0 +1,22 @@
# HG changeset patch
# User aefimov
# Date 1383034304 0
# Tue Oct 29 08:11:44 2013 +0000
# Node ID efb24af909a020f3a3b3d446f6db15fc8b1c309a
# Parent 20ffb814205c67b5ded678ee6c69b2aa0d6cebb1
8015978: Incorrect transformation of XPath expression "string(-0)"
Reviewed-by: darcy, joehw
diff -r 20ffb814205c -r efb24af909a0 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Tue Oct 29 08:10:15 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Tue Oct 29 08:11:44 2013 +0000
@@ -950,6 +950,9 @@
if (Double.isNaN(d) || Double.isInfinite(d))
return(Double.toString(d));
+ //Convert -0.0 to +0.0 other values remains the same
+ d = d + 0.0;
+
// Use the XPath formatter to ignore locales
StringBuffer result = threadLocalStringBuffer.get();
result.setLength(0);

View File

@ -0,0 +1,24 @@
# HG changeset patch
# User sgabdura
# Date 1373869363 -14400
# Mon Jul 15 10:22:43 2013 +0400
# Node ID bbd051c9089f61c65fe7d95487d47920164c7ee0
# Parent 918a90950fa69e5247e3af2599d2e7674d64e3d6
8016256: Make finalization final
Reviewed-by: hseigel
diff -r 918a90950fa6 -r bbd051c9089f src/share/vm/classfile/classFileParser.cpp
--- hotspot/src/share/vm/classfile/classFileParser.cpp Thu Oct 10 16:41:17 2013 +0100
+++ hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jul 15 10:22:43 2013 +0400
@@ -3762,9 +3762,8 @@
for (int index = 0; index < num_methods; index++) {
methodOop m = (methodOop)methods->obj_at(index);
- // skip private, static and <init> methods
- if ((!m->is_private()) &&
- (!m->is_static()) &&
+ // skip static and <init> methods
+ if ((!m->is_static()) &&
(m->name() != vmSymbols::object_initializer_name())) {
Symbol* name = m->name();

View File

@ -0,0 +1,71 @@
# HG changeset patch
# User sgabdura
# Date 1381896654 -3600
# Wed Oct 16 05:10:54 2013 +0100
# Node ID 1ed7c9cea8c508e60d6df30c046ab48b1f1d3ab9
# Parent 96aee3742c52d2d1a83a3db0be2c14892a511c67
8016357: Update hotspot diagnostic class
Summary: Add security check to HotSpotDiagnostic.dumpHeap
Reviewed-by: fparain, sla, ahgross
diff -r 96aee3742c52 -r 1ed7c9cea8c5 make/java/management/mapfile-vers
--- jdk/make/java/management/mapfile-vers Tue Oct 15 21:28:50 2013 +0100
+++ jdk/make/java/management/mapfile-vers Wed Oct 16 05:10:54 2013 +0100
@@ -50,7 +50,7 @@
Java_sun_management_GcInfoBuilder_fillGcAttributeInfo;
Java_sun_management_GcInfoBuilder_getLastGcInfo0;
Java_sun_management_GcInfoBuilder_getNumGcExtAttributes;
- Java_sun_management_HotSpotDiagnostic_dumpHeap;
+ Java_sun_management_HotSpotDiagnostic_dumpHeap0;
Java_sun_management_HotspotThread_getInternalThreadCount;
Java_sun_management_HotspotThread_getInternalThreadTimes0;
Java_sun_management_MemoryImpl_getMemoryManagers0;
diff -r 96aee3742c52 -r 1ed7c9cea8c5 src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java
--- jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Tue Oct 15 21:28:50 2013 +0100
+++ jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Wed Oct 16 05:10:54 2013 +0100
@@ -54,6 +54,11 @@
* cannot be created, opened, or written to.
* @throws UnsupportedOperationException if this operation is not supported.
* @throws NullPointerException if <tt>outputFile</tt> is <tt>null</tt>.
+ * @throws SecurityException
+ * If a security manager exists and its {@link
+ * java.lang.SecurityManager#checkWrite(java.lang.String)}
+ * method denies write access to the named file
+ * or the caller does not have ManagmentPermission("control").
*/
public void dumpHeap(String outputFile, boolean live) throws java.io.IOException;
diff -r 96aee3742c52 -r 1ed7c9cea8c5 src/share/classes/sun/management/HotSpotDiagnostic.java
--- jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Tue Oct 15 21:28:50 2013 +0100
+++ jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Wed Oct 16 05:10:54 2013 +0100
@@ -38,7 +38,17 @@
public HotSpotDiagnostic() {
}
- public native void dumpHeap(String outputFile, boolean live) throws IOException;
+ public void dumpHeap(String outputFile, boolean live) throws IOException {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkWrite(outputFile);
+ ManagementFactory.checkControlAccess();
+ }
+
+ dumpHeap0(outputFile, live);
+ }
+
+ private native void dumpHeap0(String outputFile, boolean live) throws IOException;
public List<VMOption> getDiagnosticOptions() {
List<Flag> allFlags = Flag.getAllFlags();
diff -r 96aee3742c52 -r 1ed7c9cea8c5 src/share/native/sun/management/HotSpotDiagnostic.c
--- jdk/src/share/native/sun/management/HotSpotDiagnostic.c Tue Oct 15 21:28:50 2013 +0100
+++ jdk/src/share/native/sun/management/HotSpotDiagnostic.c Wed Oct 16 05:10:54 2013 +0100
@@ -29,7 +29,7 @@
#include "sun_management_HotSpotDiagnostic.h"
JNIEXPORT void JNICALL
-Java_sun_management_HotSpotDiagnostic_dumpHeap
+Java_sun_management_HotSpotDiagnostic_dumpHeap0
(JNIEnv *env, jobject dummy, jstring outputfile, jboolean live)
{
jmm_interface->DumpHeap0(env, outputfile, live);

View File

@ -0,0 +1,101 @@
# HG changeset patch
# User robm
# Date 1383034867 0
# Tue Oct 29 08:21:07 2013 +0000
# Node ID e6d4480e2b11853e5ec5bbced3d351564e174632
# Parent 843659ece699889459239c6470e67265de2b3f73
8016653: javadoc should ignore ignoreable characters in names
Reviewed-by: jjg
diff -r 843659ece699 -r e6d4480e2b11 src/share/classes/com/sun/tools/javac/parser/Scanner.java
--- langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Fri Jul 19 16:02:59 2013 -0700
+++ langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Tue Oct 29 08:21:07 2013 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -514,11 +514,10 @@
private void scanIdent() {
boolean isJavaIdentifierPart;
char high;
+ if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
+ // optimization, was: putChar(ch);
+ scanChar();
do {
- if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
- // optimization, was: putChar(ch);
-
- scanChar();
switch (ch) {
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
@@ -535,6 +534,7 @@
case '$': case '_':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
+ break;
case '\u0000': case '\u0001': case '\u0002': case '\u0003':
case '\u0004': case '\u0005': case '\u0006': case '\u0007':
case '\u0008': case '\u000E': case '\u000F': case '\u0010':
@@ -542,30 +542,37 @@
case '\u0015': case '\u0016': case '\u0017':
case '\u0018': case '\u0019': case '\u001B':
case '\u007F':
- break;
+ scanChar();
+ continue;
case '\u001A': // EOI is also a legal identifier part
if (bp >= buflen) {
name = names.fromChars(sbuf, 0, sp);
token = keywords.key(name);
return;
}
- break;
+ scanChar();
+ continue;
default:
if (ch < '\u0080') {
// all ASCII range chars already handled, above
isJavaIdentifierPart = false;
} else {
- high = scanSurrogates();
- if (high != 0) {
- if (sp == sbuf.length) {
- putChar(high);
+ if (Character.isIdentifierIgnorable(ch)) {
+ scanChar();
+ continue;
+ } else {
+ high = scanSurrogates();
+ if (high != 0) {
+ if (sp == sbuf.length) {
+ putChar(high);
+ } else {
+ sbuf[sp++] = high;
+ }
+ isJavaIdentifierPart = Character.isJavaIdentifierPart(
+ Character.toCodePoint(high, ch));
} else {
- sbuf[sp++] = high;
+ isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
}
- isJavaIdentifierPart = Character.isJavaIdentifierPart(
- Character.toCodePoint(high, ch));
- } else {
- isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
}
}
if (!isJavaIdentifierPart) {
@@ -574,6 +581,9 @@
return;
}
}
+ if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
+ // optimization, was: putChar(ch);
+ scanChar();
} while (true);
}

View File

@ -0,0 +1,75 @@
# HG changeset patch
# User bpatel
# Date 1374274979 25200
# Fri Jul 19 16:02:59 2013 -0700
# Node ID 843659ece699889459239c6470e67265de2b3f73
# Parent 9083313d5733ca9be66bc52cf64b9b5d4dd2e39a
8016675: Make Javadoc pages more robust
Reviewed-by: jlaskey, ksrini
diff -r 9083313d5733 -r 843659ece699 src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
--- langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Oct 25 16:10:09 2013 +0100
+++ langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Jul 19 16:02:59 2013 -0700
@@ -289,7 +289,7 @@
script.addAttr(HtmlAttr.TYPE, "text/javascript");
String scriptCode = "<!--" + DocletConstants.NL +
" if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
- " parent.document.title=\"" + winTitle + "\";" + DocletConstants.NL +
+ " parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";" + DocletConstants.NL +
" }" + DocletConstants.NL +
"//-->" + DocletConstants.NL;
RawHtml scriptContent = new RawHtml(scriptCode);
@@ -299,6 +299,53 @@
}
/**
+ * Returns a String with escaped special JavaScript characters.
+ *
+ * @param s String that needs to be escaped
+ * @return a valid escaped JavaScript string
+ */
+ private static String escapeJavaScriptChars(String s) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ switch (ch) {
+ case '\b':
+ sb.append("\\b");
+ break;
+ case '\t':
+ sb.append("\\t");
+ break;
+ case '\n':
+ sb.append("\\n");
+ break;
+ case '\f':
+ sb.append("\\f");
+ break;
+ case '\r':
+ sb.append("\\r");
+ break;
+ case '"':
+ sb.append("\\\"");
+ break;
+ case '\'':
+ sb.append("\\\'");
+ break;
+ case '\\':
+ sb.append("\\\\");
+ break;
+ default:
+ if (ch < 32 || ch >= 127) {
+ sb.append(String.format("\\u%04X", (int)ch));
+ } else {
+ sb.append(ch);
+ }
+ break;
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
* Returns a content tree for the SCRIPT tag for the main page(index.html).
*
* @return a content for the SCRIPT tag

View File

@ -0,0 +1,107 @@
# HG changeset patch
# User mchung
# Date 1382731288 -3600
# Fri Oct 25 21:01:28 2013 +0100
# Node ID 43b600fed0e8ac9d5ffe7556617d4850143e2dcd
# Parent a2b63addc0633a5ef8d196d1019d78b920cb4b1a
8017196: Ensure Proxies are handled appropriately
Reviewed-by: dfuchs, jrose, jdn, ahgross, chegar
diff -r a2b63addc063 -r 43b600fed0e8 src/share/classes/java/lang/reflect/Proxy.java
--- jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 19:45:04 2013 +0100
+++ jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 21:01:28 2013 +0100
@@ -787,6 +787,7 @@
* @throws IllegalArgumentException if the argument is not a
* proxy instance
*/
+ @CallerSensitive
public static InvocationHandler getInvocationHandler(Object proxy)
throws IllegalArgumentException
{
@@ -797,8 +798,19 @@
throw new IllegalArgumentException("not a proxy instance");
}
- Proxy p = (Proxy) proxy;
- return p.h;
+ final Proxy p = (Proxy) proxy;
+ final InvocationHandler ih = p.h;
+ if (System.getSecurityManager() != null) {
+ Class<?> ihClass = ih.getClass();
+ Class<?> caller = Reflection.getCallerClass();
+ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(),
+ ihClass.getClassLoader()))
+ {
+ ReflectUtil.checkPackageAccess(ihClass);
+ }
+ }
+
+ return ih;
}
private static native Class defineClass0(ClassLoader loader, String name,
diff -r a2b63addc063 -r 43b600fed0e8 src/share/classes/sun/reflect/misc/ReflectUtil.java
--- jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 19:45:04 2013 +0100
+++ jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 21:01:28 2013 +0100
@@ -26,8 +26,10 @@
package sun.reflect.misc;
+import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
+import java.util.Arrays;
import sun.reflect.Reflection;
public final class ReflectUtil {
@@ -257,4 +259,50 @@
String pkg = (i != -1) ? name.substring(0, i) : "";
return Proxy.isProxyClass(cls) && !pkg.equals(PROXY_PACKAGE);
}
+
+ /**
+ * Check if the given method is a method declared in the proxy interface
+ * implemented by the given proxy instance.
+ *
+ * @param proxy a proxy instance
+ * @param method an interface method dispatched to a InvocationHandler
+ *
+ * @throws IllegalArgumentException if the given proxy or method is invalid.
+ */
+ public static void checkProxyMethod(Object proxy, Method method) {
+ // check if it is a valid proxy instance
+ if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
+ throw new IllegalArgumentException("Not a Proxy instance");
}
+ if (Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalArgumentException("Can't handle static method");
+ }
+
+ Class<?> c = method.getDeclaringClass();
+ if (c == Object.class) {
+ String name = method.getName();
+ if (name.equals("hashCode") || name.equals("equals") || name.equals("toString")) {
+ return;
+ }
+ }
+
+ if (isSuperInterface(proxy.getClass(), c)) {
+ return;
+ }
+
+ // disallow any method not declared in one of the proxy intefaces
+ throw new IllegalArgumentException("Can't handle: " + method);
+ }
+
+ private static boolean isSuperInterface(Class<?> c, Class<?> intf) {
+ for (Class<?> i : c.getInterfaces()) {
+ if (i == intf) {
+ return true;
+ }
+ if (isSuperInterface(i, intf)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}

View File

@ -0,0 +1,94 @@
# HG changeset patch
# User mchung
# Date 1374193345 25200
# Thu Jul 18 17:22:25 2013 -0700
# Node ID 2a415f9ee0976719ac79e6e5e2b1f00b29636427
# Parent 9e7e1b6ab5cdf0096c9c16d991e6a982771a15f1
8017196: Ensure Proxies are handled appropriately
Reviewed-by: dfuchs, jrose, jdn, ahgross, chegar
diff -r 9e7e1b6ab5cd -r 2a415f9ee097 src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java
--- corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java Tue Oct 15 15:24:25 2013 +0100
+++ corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java Thu Jul 18 17:22:25 2013 -0700
@@ -43,6 +43,8 @@
import com.sun.corba.se.spi.orbutil.proxy.DelegateInvocationHandlerImpl ;
import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandler ;
import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl ;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory
{
@@ -114,24 +116,32 @@
// which extends org.omg.CORBA.Object. This handler delegates all
// calls directly to a DynamicStubImpl, which extends
// org.omg.CORBA.portable.ObjectImpl.
- InvocationHandler dynamicStubHandler =
+ final InvocationHandler dynamicStubHandler =
DelegateInvocationHandlerImpl.create( stub ) ;
// Create an invocation handler that handles any remote interface
// methods.
- InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
+ final InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
pm, classData, stub ) ;
// Create a composite handler that handles the DynamicStub interface
// as well as the remote interfaces.
final CompositeInvocationHandler handler =
new CustomCompositeInvocationHandlerImpl( stub ) ;
+
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
handler.addInvocationHandler( DynamicStub.class,
dynamicStubHandler ) ;
handler.addInvocationHandler( org.omg.CORBA.Object.class,
dynamicStubHandler ) ;
handler.addInvocationHandler( Object.class,
dynamicStubHandler ) ;
+ return null;
+ }
+ });
+
// If the method passed to invoke is not from DynamicStub or its superclasses,
// it must be from an implemented interface, so we just handle
diff -r 9e7e1b6ab5cd -r 2a415f9ee097 src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java
--- corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java Tue Oct 15 15:24:25 2013 +0100
+++ corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java Thu Jul 18 17:22:25 2013 -0700
@@ -36,6 +36,7 @@
import com.sun.corba.se.spi.logging.CORBALogDomains ;
import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
+import com.sun.corba.se.impl.presentation.rmi.DynamicAccessPermission;
public class CompositeInvocationHandlerImpl implements
CompositeInvocationHandler
@@ -46,11 +47,13 @@
public void addInvocationHandler( Class interf,
InvocationHandler handler )
{
+ checkAccess();
classToInvocationHandler.put( interf, handler ) ;
}
public void setDefaultHandler( InvocationHandler handler )
{
+ checkAccess();
defaultHandler = handler ;
}
@@ -78,4 +81,12 @@
return handler.invoke( proxy, method, args ) ;
}
+
+ private static final DynamicAccessPermission perm = new DynamicAccessPermission("access");
+ private void checkAccess() {
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(perm);
}
+ }
+}

View File

@ -0,0 +1,22 @@
# HG changeset patch
# User bae
# Date 1382732366 -3600
# Fri Oct 25 21:19:26 2013 +0100
# Node ID 768afb4062fb6653278e5f7e5304a623fcd80c9c
# Parent 43b600fed0e8ac9d5ffe7556617d4850143e2dcd
8017287: Better resource disposal
Reviewed-by: vadim
diff -r 43b600fed0e8 -r 768afb4062fb src/share/classes/sun/java2d/Disposer.java
--- jdk/src/share/classes/sun/java2d/Disposer.java Fri Oct 25 21:01:28 2013 +0100
+++ jdk/src/share/classes/sun/java2d/Disposer.java Fri Oct 25 21:19:26 2013 +0100
@@ -147,8 +147,7 @@
obj = null;
rec = null;
} catch (Exception e) {
- System.out.println("Exception while removing reference: " + e);
- e.printStackTrace();
+ System.out.println("Exception while removing reference.");
}
}
}

View File

@ -0,0 +1,34 @@
# HG changeset patch
# User mchung
# Date 1373884816 25200
# Mon Jul 15 03:40:16 2013 -0700
# Node ID 011d86bdcbf8d4fe0016351b775ff1f48f3620a1
# Parent 768afb4062fb6653278e5f7e5304a623fcd80c9c
8017291: Cast Proxies Aside
Reviewed-by: alanb, ahgross
diff -r 768afb4062fb -r 011d86bdcbf8 src/share/classes/java/lang/ClassLoader.java
--- jdk/src/share/classes/java/lang/ClassLoader.java Fri Oct 25 21:19:26 2013 +0100
+++ jdk/src/share/classes/java/lang/ClassLoader.java Mon Jul 15 03:40:16 2013 -0700
@@ -54,6 +54,7 @@
import sun.misc.VM;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
+import sun.reflect.misc.ReflectUtil;
import sun.security.util.SecurityConstants;
/**
@@ -338,6 +339,13 @@
private void checkPackageAccess(Class cls, ProtectionDomain pd) {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
+ if (ReflectUtil.isNonPublicProxyClass(cls)) {
+ for (Class intf: cls.getInterfaces()) {
+ checkPackageAccess(intf, pd);
+ }
+ return;
+ }
+
final String name = cls.getName();
final int i = name.lastIndexOf('.');
if (i != -1) {

View File

@ -0,0 +1,999 @@
# HG changeset patch
# User joehw
# Date 1383031104 0
# Tue Oct 29 07:18:24 2013 +0000
# Node ID 3dc769c632a1d6a8f69d2857b3c13c43a83481be
# Parent 7799c3bd00f5a4fda6448cb8bcd7768c66ec166d
8017298: Better XML support
Reviewed-by: alanb, dfuchs, mullan
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Oct 29 07:18:24 2013 +0000
@@ -50,8 +50,8 @@
import com.sun.org.apache.xerces.internal.xni.Augmentations;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.events.XMLEvent;
@@ -350,7 +350,7 @@
protected boolean foundBuiltInRefs = false;
- protected SecurityManager fSecurityManager = null;
+ protected XMLSecurityManager fSecurityManager = null;
//skip element algorithm
static final short MAX_DEPTH_LIMIT = 5 ;
@@ -555,11 +555,13 @@
}
try {
- fSecurityManager = (SecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER);
+ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER);
} catch (XMLConfigurationException e) {
fSecurityManager = null;
}
- fElementAttributeLimit = (fSecurityManager != null)?fSecurityManager.getElementAttrLimit():0;
+ fElementAttributeLimit = (fSecurityManager != null)?
+ fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT):0;
+
try {
fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS);
@@ -929,6 +931,7 @@
// scan decl
super.scanXMLDeclOrTextDecl(scanningTextDecl, fStrings);
+
fMarkupDepth--;
// pseudo-attribute values
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Oct 29 07:18:24 2013 +0000
@@ -64,8 +64,8 @@
import com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler;
import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.URI;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
/**
@@ -321,7 +321,7 @@
// stores defaults for entity expansion limit if it has
// been set on the configuration.
- protected SecurityManager fSecurityManager = null;
+ protected XMLSecurityManager fSecurityManager = null;
/**
* True if the document entity is standalone. This should really
@@ -1531,7 +1531,7 @@
fValidationManager = null;
}
try {
- fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
}
catch (XMLConfigurationException e) {
fSecurityManager = null;
@@ -1549,7 +1549,9 @@
// a class acting as a component manager but not
// implementing that interface for whatever reason.
public void reset() {
- fEntityExpansionLimit = (fSecurityManager != null)?fSecurityManager.getEntityExpansionLimit():0;
+ fEntityExpansionLimit = (fSecurityManager != null)?
+ fSecurityManager.getLimit(XMLSecurityManager.Limit.ENTITY_EXPANSION_LIMIT):0;
+
// initialize state
fStandalone = false;
@@ -1689,8 +1691,9 @@
}
if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
- fSecurityManager = (SecurityManager)value;
- fEntityExpansionLimit = (fSecurityManager != null)?fSecurityManager.getEntityExpansionLimit():0;
+ fSecurityManager = (XMLSecurityManager)value;
+ fEntityExpansionLimit = (fSecurityManager != null)?
+ fSecurityManager.getLimit(XMLSecurityManager.Limit.ENTITY_EXPANSION_LIMIT):0;
}
}
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Oct 29 07:18:24 2013 +0000
@@ -515,7 +515,7 @@
reportFatalError("SDDeclInvalid", new Object[] {standalone});
}
} else {
- reportFatalError("EncodingDeclRequired", null);
+ reportFatalError("SDDeclNameInvalid", null);
}
break;
}
@@ -580,7 +580,7 @@
XMLString value)
throws IOException, XNIException {
- String name = fEntityScanner.scanName();
+ String name = scanPseudoAttributeName();
// XMLEntityManager.print(fEntityManager.getCurrentEntity());
if (name == null) {
@@ -633,6 +633,35 @@
} // scanPseudoAttribute(XMLString):String
/**
+ * Scans the name of a pseudo attribute. The only legal names
+ * in XML 1.0/1.1 documents are 'version', 'encoding' and 'standalone'.
+ *
+ * @return the name of the pseudo attribute or <code>null</code>
+ * if a legal pseudo attribute name could not be scanned.
+ */
+ private String scanPseudoAttributeName() throws IOException, XNIException {
+ final int ch = fEntityScanner.peekChar();
+ switch (ch) {
+ case 'v':
+ if (fEntityScanner.skipString(fVersionSymbol)) {
+ return fVersionSymbol;
+ }
+ break;
+ case 'e':
+ if (fEntityScanner.skipString(fEncodingSymbol)) {
+ return fEncodingSymbol;
+ }
+ break;
+ case 's':
+ if (fEntityScanner.skipString(fStandaloneSymbol)) {
+ return fStandaloneSymbol;
+ }
+ break;
+ }
+ return null;
+ } // scanPseudoAttributeName()
+
+ /**
* Scans a processing instruction.
* <p>
* <pre>
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Tue Oct 29 07:18:24 2013 +0000
@@ -43,6 +43,7 @@
# 2.9 Standalone Document Declaration
SDDeclInvalid = The standalone document declaration value must be \"yes\" or \"no\", not \"{0}\".
+ SDDeclNameInvalid = The standalone name in XML declaration may be misspelled.
# 2.12 Language Identification
XMLLangInvalid = The xml:lang attribute value \"{0}\" is an invalid language identifier.
# 3. Logical Structures
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java Tue Oct 29 07:18:24 2013 +0000
@@ -21,13 +21,13 @@
package com.sun.org.apache.xerces.internal.impl.xs.models;
+import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode;
+import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
-import com.sun.org.apache.xerces.internal.util.SecurityManager ;
-import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode;
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
-import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
-import com.sun.org.apache.xerces.internal.impl.Constants;
/**
*
@@ -68,7 +68,7 @@
// stores defaults for different security holes (maxOccurLimit in current context) if it has
// been set on the configuration.
- private SecurityManager fSecurityManager = null;
+ private XMLSecurityManager fSecurityManager = null;
/** default constructor */
public CMNodeFactory() {
@@ -77,10 +77,10 @@
public void reset(XMLComponentManager componentManager){
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
try {
- fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
//we are setting the limit of number of nodes to 3times the maxOccur value..
if(fSecurityManager != null){
- maxNodeLimit = fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY ;
+ maxNodeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY ;
}
}
catch (XMLConfigurationException e) {
@@ -152,8 +152,9 @@
if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
- fSecurityManager = (SecurityManager)value;
- maxNodeLimit = (fSecurityManager != null) ? fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY : 0 ;
+ fSecurityManager = (XMLSecurityManager)value;
+ maxNodeLimit = (fSecurityManager != null) ?
+ fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
return;
}
if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Oct 29 07:18:24 2013 +0000
@@ -38,6 +38,7 @@
import com.sun.org.apache.xerces.internal.util.DOMUtil;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xs.XSConstants;
import org.w3c.dom.Attr;
@@ -1235,7 +1236,7 @@
if (!optimize) {
//Revisit :: IMO this is not right place to check
// maxOccurNodeLimit.
- int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getMaxOccurNodeLimit();
+ int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
if (max > maxOccurNodeLimit) {
reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Tue Oct 29 07:18:24 2013 +0000
@@ -56,10 +56,10 @@
import com.sun.org.apache.xerces.internal.util.DOMInputSource;
import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
import com.sun.org.apache.xerces.internal.util.SAXInputSource;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
@@ -210,7 +210,7 @@
*
* <p>Protected to allow access by any traverser.</p>
*/
- protected SecurityManager fSecureProcessing = null;
+ protected XMLSecurityManager fSecureProcessing = null;
// These tables correspond to the symbol spaces defined in the
@@ -1963,7 +1963,7 @@
fSecureProcessing = null;
if( componentManager!=null ) {
try {
- fSecureProcessing = (SecurityManager) componentManager.getProperty(SECURE_PROCESSING);
+ fSecureProcessing = (XMLSecurityManager) componentManager.getProperty(SECURE_PROCESSING);
} catch (XMLConfigurationException xmlConfigurationException) {
;
}
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 07:18:24 2013 +0000
@@ -34,7 +34,7 @@
import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;
import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
@@ -153,7 +153,7 @@
// If the secure processing feature is on set a security manager.
if (secureProcessing) {
- domParser.setProperty(SECURITY_MANAGER, new SecurityManager());
+ domParser.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
}
this.grammar = dbf.getSchema();
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 07:18:24 2013 +0000
@@ -36,7 +36,7 @@
import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
@@ -143,7 +143,7 @@
// If the secure processing feature is on set a security manager.
if (secureProcessing) {
- xmlReader.setProperty0(SECURITY_MANAGER, new SecurityManager());
+ xmlReader.setProperty0(SECURITY_MANAGER, new XMLSecurityManager());
}
// Set application's features, followed by validation features.
@@ -349,7 +349,7 @@
}
if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
try {
- setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null);
+ setProperty(SECURITY_MANAGER, value ? new XMLSecurityManager() : null);
}
catch (SAXNotRecognizedException exc) {
// If the property is not supported
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 07:18:24 2013 +0000
@@ -24,7 +24,7 @@
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
@@ -167,7 +167,7 @@
private XMLParserConfiguration initialize() {
XML11Configuration config = new XML11Configuration();
if (fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
- config.setProperty(SECURITY_MANAGER, new SecurityManager());
+ config.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
}
config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Oct 29 07:18:24 2013 +0000
@@ -47,10 +47,10 @@
import com.sun.org.apache.xerces.internal.util.SAXLocatorWrapper;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.URI;
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
@@ -677,7 +677,7 @@
reader = spf.newSAXParser().getXMLReader();
// If this is a Xerces SAX parser, set the security manager if there is one
if (reader instanceof com.sun.org.apache.xerces.internal.parsers.SAXParser) {
- SecurityManager securityManager = (SecurityManager) fComponentManager.getProperty(SECURITY_MANAGER);
+ XMLSecurityManager securityManager = (XMLSecurityManager) fComponentManager.getProperty(SECURITY_MANAGER);
if (securityManager != null) {
try {
reader.setProperty(SECURITY_MANAGER, securityManager);
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 07:18:24 2013 +0000
@@ -39,8 +39,8 @@
import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.SAXInputSource;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
@@ -74,7 +74,7 @@
private static final String XMLGRAMMAR_POOL =
Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
- /** Property identifier: SecurityManager. */
+ /** Property identifier: XMLSecurityManager. */
private static final String SECURITY_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
@@ -97,8 +97,8 @@
/** The ErrorHandlerWrapper */
private ErrorHandlerWrapper fErrorHandlerWrapper;
- /** The SecurityManager. */
- private SecurityManager fSecurityManager;
+ /** The XMLSecurityManager. */
+ private XMLSecurityManager fSecurityManager;
/** The container for the real grammar pool. */
private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper;
@@ -113,7 +113,7 @@
fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
// Enable secure processing feature by default
- fSecurityManager = new SecurityManager();
+ fSecurityManager = new XMLSecurityManager();
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
}
@@ -321,7 +321,7 @@
SAXMessageFormatter.formatMessage(null,
"jaxp-secureprocessing-feature", null));
}
- fSecurityManager = value ? new SecurityManager() : null;
+ fSecurityManager = value ? new XMLSecurityManager() : null;
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
return;
}
@@ -350,7 +350,7 @@
"ProperyNameNull", null));
}
if (name.equals(SECURITY_MANAGER)) {
- fSecurityManager = (SecurityManager) object;
+ fSecurityManager = (XMLSecurityManager) object;
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
return;
}
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 07:18:24 2013 +0000
@@ -37,8 +37,8 @@
import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
@@ -173,7 +173,7 @@
private final HashMap fInitProperties = new HashMap();
/** Stores the initial security manager. */
- private final SecurityManager fInitSecurityManager;
+ private final XMLSecurityManager fInitSecurityManager;
//
// User Objects
@@ -212,7 +212,7 @@
if (System.getSecurityManager() != null) {
_isSecureMode = true;
- setProperty(SECURITY_MANAGER, new SecurityManager());
+ setProperty(SECURITY_MANAGER, new XMLSecurityManager());
} else {
fComponents.put(SECURITY_MANAGER, null);
}
@@ -233,7 +233,7 @@
// if the secure processing feature is set to true, add a security manager to the configuration
Boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
if (Boolean.TRUE.equals(secureProcessing)) {
- fInitSecurityManager = new SecurityManager();
+ fInitSecurityManager = new XMLSecurityManager();
}
else {
fInitSecurityManager = null;
@@ -296,7 +296,7 @@
if (_isSecureMode && !value) {
throw new XMLConfigurationException(XMLConfigurationException.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
}
- setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null);
+ setProperty(SECURITY_MANAGER, value ? new XMLSecurityManager() : null);
return;
}
fConfigUpdated = true;
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Tue Oct 29 07:18:24 2013 +0000
@@ -25,9 +25,9 @@
import com.sun.org.apache.xerces.internal.util.EntityResolverWrapper;
import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.SymbolHash;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
@@ -1649,7 +1649,7 @@
else if (featureId.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
if (state) {
if (fConfiguration.getProperty(SECURITY_MANAGER )==null) {
- fConfiguration.setProperty(SECURITY_MANAGER, new SecurityManager());
+ fConfiguration.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
}
}
}
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java Tue Oct 29 07:18:24 2013 +0000
@@ -23,8 +23,8 @@
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
/**
* This configuration allows Xerces to behave in a security-conscious manner; that is,
@@ -106,8 +106,8 @@
XMLComponentManager parentSettings) {
super(symbolTable, grammarPool, parentSettings);
- // create the SecurityManager property:
- setProperty(SECURITY_MANAGER_PROPERTY, new SecurityManager());
+ // create the XMLSecurityManager property:
+ setProperty(SECURITY_MANAGER_PROPERTY, new XMLSecurityManager());
} // <init>(SymbolTable,XMLGrammarPool)
} // class SecurityConfiguration
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java Tue Oct 29 05:50:44 2013 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2003 The Apache Software Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xerces" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-package com.sun.org.apache.xerces.internal.util;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-/**
- * This class is a container for parser settings that relate to
- * security, or more specifically, it is intended to be used to prevent denial-of-service
- * attacks from being launched against a system running Xerces.
- * Any component that is aware of a denial-of-service attack that can arise
- * from its processing of a certain kind of document may query its Component Manager
- * for the property (http://apache.org/xml/properties/security-manager)
- * whose value will be an instance of this class.
- * If no value has been set for the property, the component should proceed in the "usual" (spec-compliant)
- * manner. If a value has been set, then it must be the case that the component in
- * question needs to know what method of this class to query. This class
- * will provide defaults for all known security issues, but will also provide
- * setters so that those values can be tailored by applications that care.
- *
- * @author Neil Graham, IBM
- *
- * @version $Id: SecurityManager.java,v 1.5 2010-11-01 04:40:14 joehw Exp $
- */
-public final class SecurityManager {
-
- //
- // Constants
- //
-
- // default value for entity expansion limit
- private final static int DEFAULT_ENTITY_EXPANSION_LIMIT = 64000;
-
- /** Default value of number of nodes created. **/
- private final static int DEFAULT_MAX_OCCUR_NODE_LIMIT = 5000;
-
- //
- // Data
- //
-
- private final static int DEFAULT_ELEMENT_ATTRIBUTE_LIMIT = 10000;
-
- /** Entity expansion limit. **/
- private int entityExpansionLimit;
-
- /** W3C XML Schema maxOccurs limit. **/
- private int maxOccurLimit;
-
- private int fElementAttributeLimit;
- // default constructor. Establishes default values for
- // all known security holes.
- /**
- * Default constructor. Establishes default values
- * for known security vulnerabilities.
- */
- public SecurityManager() {
- entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
- maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT ;
- fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
- //We are reading system properties only once ,
- //at the time of creation of this object ,
- readSystemProperties();
- }
-
- /**
- * <p>Sets the number of entity expansions that the
- * parser should permit in a document.</p>
- *
- * @param limit the number of entity expansions
- * permitted in a document
- */
- public void setEntityExpansionLimit(int limit) {
- entityExpansionLimit = limit;
- }
-
- /**
- * <p>Returns the number of entity expansions
- * that the parser permits in a document.</p>
- *
- * @return the number of entity expansions
- * permitted in a document
- */
- public int getEntityExpansionLimit() {
- return entityExpansionLimit;
- }
-
- /**
- * <p>Sets the limit of the number of content model nodes
- * that may be created when building a grammar for a W3C
- * XML Schema that contains maxOccurs attributes with values
- * other than "unbounded".</p>
- *
- * @param limit the maximum value for maxOccurs other
- * than "unbounded"
- */
- public void setMaxOccurNodeLimit(int limit){
- maxOccurLimit = limit;
- }
-
- /**
- * <p>Returns the limit of the number of content model nodes
- * that may be created when building a grammar for a W3C
- * XML Schema that contains maxOccurs attributes with values
- * other than "unbounded".</p>
- *
- * @return the maximum value for maxOccurs other
- * than "unbounded"
- */
- public int getMaxOccurNodeLimit(){
- return maxOccurLimit;
- }
-
- public int getElementAttrLimit(){
- return fElementAttributeLimit;
- }
-
- public void setElementAttrLimit(int limit){
- fElementAttributeLimit = limit;
- }
-
- private void readSystemProperties(){
-
- //TODO: also read SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT
- try {
- String value = getSystemProperty(Constants.ENTITY_EXPANSION_LIMIT);
- if(value != null && !value.equals("")){
- entityExpansionLimit = Integer.parseInt(value);
- if (entityExpansionLimit < 0)
- entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
- }
- else
- entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
- }catch(Exception ex){}
-
- try {
- String value = getSystemProperty(Constants.MAX_OCCUR_LIMIT);
- if(value != null && !value.equals("")){
- maxOccurLimit = Integer.parseInt(value);
- if (maxOccurLimit < 0)
- maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
- }
- else
- maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
- }catch(Exception ex){}
-
- try {
- String value = getSystemProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
- if(value != null && !value.equals("")){
- fElementAttributeLimit = Integer.parseInt(value);
- if ( fElementAttributeLimit < 0)
- fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
- }
- else
- fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
-
- }catch(Exception ex){}
-
- }
-
- private String getSystemProperty(final String propName) {
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- return System.getProperty(propName);
- }
- });
- }
-} // class SecurityManager
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java Tue Oct 29 07:18:24 2013 +0000
@@ -173,7 +173,7 @@
for (int i = 0; i < length; i++) {
code = code * 37 + symbol.charAt(i);
}
- return code & 0x7FFFFFF;
+ return code & 0x7FFFFFFF;
} // hash(String):int
@@ -194,7 +194,7 @@
for (int i = 0; i < length; i++) {
code = code * 37 + buffer[offset + i];
}
- return code & 0x7FFFFFF;
+ return code & 0x7FFFFFFF;
} // hash(char[],int,int):int
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Oct 29 07:18:24 2013 +0000
@@ -0,0 +1,147 @@
+/*
+ * 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 com.sun.org.apache.xerces.internal.utils;
+
+import com.sun.org.apache.xerces.internal.impl.Constants;
+
+/**
+ * This class manages standard and implementation-specific limitations.
+ *
+ */
+public final class XMLSecurityManager {
+
+ /**
+ * States of the settings of a property, in the order: default value, value
+ * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system
+ * properties, and jaxp api properties
+ */
+ public static enum State {
+ //this order reflects the overriding order
+ DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY
+ }
+
+ /**
+ * Limits managed by the security manager
+ */
+ public static enum Limit {
+ ENTITY_EXPANSION_LIMIT(64000),
+ MAX_OCCUR_NODE_LIMIT(5000),
+ ELEMENT_ATTRIBUTE_LIMIT(10000);
+
+ final int defaultValue;
+
+ Limit(int value) {
+ this.defaultValue = value;
+ }
+
+ int defaultValue() {
+ return defaultValue;
+ }
+ }
+
+ /**
+ * Values of the limits as defined in enum Limit
+ */
+ private final int[] limits;
+ /**
+ * States of the settings for each limit in limits above
+ */
+ private State[] states = {State.DEFAULT, State.DEFAULT, State.DEFAULT, State.DEFAULT};
+
+ /**
+ * Default constructor. Establishes default values for known security
+ * vulnerabilities.
+ */
+ public XMLSecurityManager() {
+ limits = new int[Limit.values().length];
+ for (Limit limit : Limit.values()) {
+ limits[limit.ordinal()] = limit.defaultValue();
+ }
+ //read system properties or jaxp.properties
+ readSystemProperties();
+ }
+
+ /**
+ * Sets the limit for a specific type of XML constructs. This can be either
+ * the size or the number of the constructs.
+ *
+ * @param type the type of limitation
+ * @param state the state of limitation
+ * @param limit the limit to the type
+ */
+ public void setLimit(Limit limit, State state, int value) {
+ //only update if it shall override
+ if (state.compareTo(states[limit.ordinal()]) >= 0) {
+ limits[limit.ordinal()] = value;
+ states[limit.ordinal()] = state;
+ }
+ }
+
+ /**
+ * Returns the limit set for the type specified
+ *
+ * @param limit the type of limitation
+ * @return the limit to the type
+ */
+ public int getLimit(Limit limit) {
+ return limits[limit.ordinal()];
+ }
+
+ /**
+ * Read from system properties, or those in jaxp.properties
+ */
+ private void readSystemProperties() {
+ getSystemProperty(Limit.ENTITY_EXPANSION_LIMIT, Constants.ENTITY_EXPANSION_LIMIT);
+ getSystemProperty(Limit.MAX_OCCUR_NODE_LIMIT, Constants.MAX_OCCUR_LIMIT);
+ getSystemProperty(Limit.ELEMENT_ATTRIBUTE_LIMIT,
+ Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
+ }
+
+ /**
+ * Read from system properties, or those in jaxp.properties
+ *
+ * @param limit the type of the property
+ * @param property the property name
+ */
+ private void getSystemProperty(Limit limit, String property) {
+ try {
+ String value = SecuritySupport.getSystemProperty(property);
+ if (value != null && !value.equals("")) {
+ limits[limit.ordinal()] = Integer.parseInt(value);
+ states[limit.ordinal()] = State.SYSTEMPROPERTY;
+ return;
+ }
+
+ value = SecuritySupport.readJAXPProperty(property);
+ if (value != null && !value.equals("")) {
+ limits[limit.ordinal()] = Integer.parseInt(value);
+ states[limit.ordinal()] = State.JAXPDOTPROPERTIES;
+ }
+ } catch (NumberFormatException e) {
+ //invalid setting ignored
+ }
+ }
+}
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Tue Oct 29 07:18:24 2013 +0000
@@ -36,7 +36,6 @@
import com.sun.org.apache.xerces.internal.util.HTTPInputSource;
import com.sun.org.apache.xerces.internal.util.IntStack;
import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
-import com.sun.org.apache.xerces.internal.util.SecurityManager;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.URI;
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
@@ -44,6 +43,7 @@
import com.sun.org.apache.xerces.internal.util.XMLChar;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
@@ -280,7 +280,7 @@
protected SymbolTable fSymbolTable;
protected XMLErrorReporter fErrorReporter;
protected XMLEntityResolver fEntityResolver;
- protected SecurityManager fSecurityManager;
+ protected XMLSecurityManager fSecurityManager;
// these are needed for text include processing
protected XIncludeTextReader fXInclude10TextReader;
@@ -506,8 +506,8 @@
// Get security manager.
try {
- SecurityManager value =
- (SecurityManager)componentManager.getProperty(
+ XMLSecurityManager value =
+ (XMLSecurityManager)componentManager.getProperty(
SECURITY_MANAGER);
if (value != null) {
@@ -656,7 +656,7 @@
return;
}
if (propertyId.equals(SECURITY_MANAGER)) {
- fSecurityManager = (SecurityManager)value;
+ fSecurityManager = (XMLSecurityManager)value;
if (fChildConfig != null) {
fChildConfig.setProperty(propertyId, value);
}
diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java
--- jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Oct 29 05:50:44 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Oct 29 07:18:24 2013 +0000
@@ -248,7 +248,7 @@
public int fBufferSize = DEFAULT_BUFFER_SIZE;
/** Default buffer size before we've finished with the XMLDecl: */
- public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 28;
+ public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
/** Default internal entity buffer size (1024). */
public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;

View File

@ -0,0 +1,129 @@
# HG changeset patch
# User sundar
# Date 1382737389 -3600
# Fri Oct 25 22:43:09 2013 +0100
# Node ID de490a43861e05f3da489db136687b1dc6f1949a
# Parent 0b0490779c5b643b7a3e90ac6870c1ee4bd5a155
8017300: Improve Interface Implementation
Reviewed-by: ahgross, jlaskey, mchung
diff -r 0b0490779c5b -r de490a43861e src/share/classes/com/sun/script/util/InterfaceImplementor.java
--- jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java Tue Jul 16 10:58:46 2013 +0100
+++ jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java Fri Oct 25 22:43:09 2013 +0100
@@ -28,6 +28,7 @@
import javax.script.*;
import java.lang.reflect.*;
import java.security.*;
+import sun.reflect.misc.ReflectUtil;
/*
* java.lang.reflect.Proxy based interface implementor. This is meant
@@ -82,8 +83,18 @@
if (iface == null || !iface.isInterface()) {
throw new IllegalArgumentException("interface Class expected");
}
+
+ if (System.getSecurityManager() != null &&
+ !Modifier.isPublic(iface.getModifiers())) {
+ throw new SecurityException("attempt to implement non-public interface");
+ }
+
+ // make sure restricted package interfaces are not attempted.
+ ReflectUtil.checkPackageAccess(iface.getName());
+
AccessControlContext accCtxt = AccessController.getContext();
- return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(),
+ return iface.cast(Proxy.newProxyInstance(
+ getLoaderForProxy(iface),
new Class[]{iface},
new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
}
@@ -101,4 +112,20 @@
// default is identity conversion
return args;
}
+
+ // get appropriate ClassLoader for generated Proxy class
+ private static ClassLoader getLoaderForProxy(Class<?> iface) {
+ ClassLoader loader = iface.getClassLoader();
+
+ // if bootstrap class, try TCCL
+ if (loader == null) {
+ loader = Thread.currentThread().getContextClassLoader();
+ }
+
+ // if TCCL is also null, try System class loader
+ if (loader == null) {
+ loader = ClassLoader.getSystemClassLoader();
+ }
+ return loader;
+ }
}
diff -r 0b0490779c5b -r de490a43861e src/share/lib/security/java.security-linux
--- jdk/src/share/lib/security/java.security-linux Tue Jul 16 10:58:46 2013 +0100
+++ jdk/src/share/lib/security/java.security-linux Fri Oct 25 22:43:09 2013 +0100
@@ -133,6 +133,7 @@
com.sun.istack.internal.,\
com.sun.jmx.,\
com.sun.proxy.,\
+ com.sun.script.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
@@ -169,6 +170,7 @@
com.sun.istack.internal.,\
com.sun.jmx.,\
com.sun.proxy.,\
+ com.sun.script.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
diff -r 0b0490779c5b -r de490a43861e src/share/lib/security/java.security-solaris
--- jdk/src/share/lib/security/java.security-solaris Tue Jul 16 10:58:46 2013 +0100
+++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:43:09 2013 +0100
@@ -134,6 +134,7 @@
com.sun.istack.internal.,\
com.sun.jmx.,\
com.sun.proxy.,\
+ com.sun.script.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
@@ -171,6 +172,7 @@
com.sun.istack.internal.,\
com.sun.jmx.,\
com.sun.proxy.,\
+ com.sun.script.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
diff -r 0b0490779c5b -r de490a43861e src/share/lib/security/java.security-windows
--- jdk/src/share/lib/security/java.security-windows Tue Jul 16 10:58:46 2013 +0100
+++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:43:09 2013 +0100
@@ -134,6 +134,7 @@
com.sun.istack.internal.,\
com.sun.jmx.,\
com.sun.proxy.,\
+ com.sun.script.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
@@ -172,6 +173,7 @@
com.sun.istack.internal.,\
com.sun.jmx.,\
com.sun.proxy.,\
+ com.sun.script.,\
com.sun.org.apache.bcel.internal.,\
com.sun.org.apache.regexp.internal.,\
com.sun.org.apache.xerces.internal.,\
diff -r 0b0490779c5b -r de490a43861e test/java/lang/SecurityManager/CheckPackageAccess.java
--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Tue Jul 16 10:58:46 2013 +0100
+++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:43:09 2013 +0100
@@ -74,6 +74,7 @@
"com.sun.org.apache.xml.internal.serializer.utils.",
"com.sun.org.apache.xml.internal.utils.",
"com.sun.org.glassfish.",
+ "com.sun.script.",
"oracle.jrockit.jfr.",
"org.jcp.xml.dsig.internal.",
};

View File

@ -0,0 +1,560 @@
# HG changeset patch
# User mkos
# Date 1383022122 0
# Tue Oct 29 04:48:42 2013 +0000
# Node ID 4ea4a060f3748510aedf4355ae2dbf2921f15494
# Parent 60ca74797572c7fb8682802738dda073e44aeea0
8017505: Better Client Service
Reviewed-by: mullan, ahgross, mgrebac
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/InstanceResolver.java
--- jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/InstanceResolver.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/InstanceResolver.java Tue Oct 29 04:48:42 2013 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -232,7 +232,7 @@
public Object invoke(Packet p, Method m, Object... args) throws InvocationTargetException, IllegalAccessException {
T t = resolve(p);
try {
- return m.invoke(t, args );
+ return MethodUtil.invoke(t, m, args );
} finally {
postInvoke(p,t);
}
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/MethodUtil.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
@@ -0,0 +1,109 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.xml.internal.ws.api.server;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ *
+ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/MethodUtil.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
@@ -0,0 +1,109 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.xml.internal.ws.client.sei;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ * <p/>
+ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/SEIStub.java
--- jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/SEIStub.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/SEIStub.java Tue Oct 29 04:48:42 2013 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -33,8 +33,8 @@
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.model.MEP;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
+import com.sun.xml.internal.ws.api.pipe.Fiber;
import com.sun.xml.internal.ws.api.pipe.Tube;
-import com.sun.xml.internal.ws.api.pipe.Fiber;
import com.sun.xml.internal.ws.binding.BindingImpl;
import com.sun.xml.internal.ws.client.RequestContext;
import com.sun.xml.internal.ws.client.ResponseContextReceiver;
@@ -47,6 +47,8 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
@@ -102,13 +104,14 @@
private final Map<Method, MethodHandler> methodHandlers = new HashMap<Method, MethodHandler>();
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ validateInputs(proxy, method);
MethodHandler handler = methodHandlers.get(method);
if (handler != null) {
return handler.invoke(proxy, args);
} else {
// we handle the other method invocations by ourselves
try {
- return method.invoke(this, args);
+ return MethodUtil.invoke(this, method, args);
} catch (IllegalAccessException e) {
// impossible
throw new AssertionError(e);
@@ -120,6 +123,17 @@
}
}
+ private void validateInputs(Object proxy, Method method) {
+ if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
+ throw new IllegalStateException("Passed object is not proxy!");
+ }
+ Class<?> declaringClass = method.getDeclaringClass();
+ if (method == null || declaringClass == null
+ || Modifier.isStatic(method.getModifiers())) {
+ throw new IllegalStateException("Invoking static method is not allowed!");
+ }
+ }
+
public final Packet doProcess(Packet request, RequestContext rc, ResponseContextReceiver receiver) {
return super.process(request, rc, receiver);
}
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
@@ -0,0 +1,107 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.xml.internal.ws.policy.privateutil;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/AbstractInstanceResolver.java
--- jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/AbstractInstanceResolver.java Fri Oct 04 12:22:34 2013 -0400
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/AbstractInstanceResolver.java Tue Oct 29 04:48:42 2013 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 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
@@ -157,7 +157,7 @@
if (!method.isAccessible()) {
method.setAccessible(true);
}
- method.invoke(instance,args);
+ MethodUtil.invoke(instance,method,args);
} catch (IllegalAccessException e) {
throw new ServerRtException("server.rt.err",e);
} catch (InvocationTargetException e) {
diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/MethodUtil.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
@@ -0,0 +1,109 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
+ * or packager/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at packager/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.xml.internal.ws.server;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
+ * to java.lang,reflect.Method.invoke()
+ *
+ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
+ */
+class MethodUtil {
+
+ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
+ private static final Method INVOKE_METHOD;
+
+ static {
+ Method method;
+ try {
+ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
+ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
+ }
+ } catch (Throwable t) {
+ method = null;
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
+ }
+ }
+ INVOKE_METHOD = method;
+ }
+
+ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
+ if (INVOKE_METHOD != null) {
+ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
+ }
+ try {
+ return INVOKE_METHOD.invoke(null, method, target, args);
+ } catch (InvocationTargetException ite) {
+ // unwrap invocation exception added by reflection code ...
+ throw unwrapException(ite);
+ }
+ } else {
+ // other then Oracle JDK ...
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
+ }
+ return method.invoke(target, args);
+ }
+ }
+
+ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
+ Throwable targetException = ite.getTargetException();
+ if (targetException != null && targetException instanceof InvocationTargetException) {
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
+ }
+ return (InvocationTargetException) targetException;
+ } else {
+ return ite;
+ }
+ }
+
+}

View File

@ -0,0 +1,77 @@
# HG changeset patch
# User coffeys
# Date 1373968726 -3600
# Tue Jul 16 10:58:46 2013 +0100
# Node ID 0b0490779c5b643b7a3e90ac6870c1ee4bd5a155
# Parent 2a023db33371ce5ee42134cf0d860ab9f0adff92
8017566: Backout 8000450 - Cannot access to com.sun.corba.se.impl.orb.ORBImpl
Reviewed-by: mchung, chegar
diff -r 2a023db33371 -r 0b0490779c5b src/share/lib/security/java.security-linux
--- jdk/src/share/lib/security/java.security-linux Fri Oct 25 22:35:06 2013 +0100
+++ jdk/src/share/lib/security/java.security-linux Tue Jul 16 10:58:46 2013 +0100
@@ -128,7 +128,6 @@
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,\
- com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
@@ -165,7 +164,6 @@
# checkPackageDefinition.
#
package.definition=sun.,\
- com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
diff -r 2a023db33371 -r 0b0490779c5b src/share/lib/security/java.security-solaris
--- jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:35:06 2013 +0100
+++ jdk/src/share/lib/security/java.security-solaris Tue Jul 16 10:58:46 2013 +0100
@@ -129,7 +129,6 @@
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,\
- com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
@@ -167,7 +166,6 @@
# checkPackageDefinition.
#
package.definition=sun.,\
- com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
diff -r 2a023db33371 -r 0b0490779c5b src/share/lib/security/java.security-windows
--- jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:35:06 2013 +0100
+++ jdk/src/share/lib/security/java.security-windows Tue Jul 16 10:58:46 2013 +0100
@@ -129,7 +129,6 @@
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,\
- com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
@@ -168,7 +167,6 @@
# checkPackageDefinition.
#
package.definition=sun.,\
- com.sun.corba.se.impl.,\
com.sun.xml.internal.,\
com.sun.imageio.,\
com.sun.istack.internal.,\
diff -r 2a023db33371 -r 0b0490779c5b test/java/lang/SecurityManager/CheckPackageAccess.java
--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:35:06 2013 +0100
+++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Tue Jul 16 10:58:46 2013 +0100
@@ -50,7 +50,6 @@
*/
private static final String[] packages = {
"sun.",
- "com.sun.corba.se.impl.",
"com.sun.xml.internal.",
"com.sun.imageio.",
"com.sun.istack.internal.",

View File

@ -0,0 +1,57 @@
# HG changeset patch
# User sjiang
# Date 1375797854 -7200
# Tue Aug 06 16:04:14 2013 +0200
# Node ID d80e6f4a4eec26137af6726cfb8abfe108ce23ea
# Parent de490a43861e05f3da489db136687b1dc6f1949a
8019292: Better Attribute Value Exceptions
Reviewed-by: dfuchs, dholmes, ahgross
diff -r de490a43861e -r d80e6f4a4eec src/share/classes/javax/management/BadAttributeValueExpException.java
--- jdk/src/share/classes/javax/management/BadAttributeValueExpException.java Fri Oct 25 22:43:09 2013 +0100
+++ jdk/src/share/classes/javax/management/BadAttributeValueExpException.java Tue Aug 06 16:04:14 2013 +0200
@@ -25,6 +25,9 @@
package javax.management;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
/**
* Thrown when an invalid MBean attribute is passed to a query
@@ -51,7 +54,7 @@
* @param val the inappropriate value.
*/
public BadAttributeValueExpException (Object val) {
- this.val = val;
+ this.val = val == null ? null : val.toString();
}
@@ -62,4 +65,25 @@
return "BadAttributeValueException: " + val;
}
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gf = ois.readFields();
+ Object valObj = gf.get("val", null);
+
+ if (valObj == null) {
+ val = null;
+ } else if (valObj instanceof String) {
+ val= valObj;
+ } else if (System.getSecurityManager() == null
+ || valObj instanceof Long
+ || valObj instanceof Integer
+ || valObj instanceof Float
+ || valObj instanceof Double
+ || valObj instanceof Byte
+ || valObj instanceof Short
+ || valObj instanceof Boolean) {
+ val = valObj.toString();
+ } else { // the serialized object is from a version without JDK-8019292 fix
+ val = System.identityHashCode(valObj) + "@" + valObj.getClass().getName();
+ }
+ }
}

View File

@ -0,0 +1,69 @@
# HG changeset patch
# User jbachorik
# Date 1374244166 -7200
# Fri Jul 19 16:29:26 2013 +0200
# Node ID 42cdf6988c2b81b322bf89778ddeb47265cd3bba
# Parent a8132d72370c1f2467c9bb966d9355b387c35039
8019584: javax/management/remote/mandatory/loading/MissingClassTest.java failed in nightly against jdk7u45: java.io.InvalidObjectException: Invalid notification: null
Reviewed-by: mchung, sjiang, dfuchs, ahgross
diff -r a8132d72370c -r 42cdf6988c2b src/share/classes/javax/management/remote/NotificationResult.java
--- jdk/src/share/classes/javax/management/remote/NotificationResult.java Mon Jul 15 16:00:57 2013 +0100
+++ jdk/src/share/classes/javax/management/remote/NotificationResult.java Fri Jul 19 16:29:26 2013 +0200
@@ -132,16 +132,17 @@
}
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- ObjectInputStream.GetField gf = ois.readFields();
- TargetedNotification[] tNotifs = (TargetedNotification[])gf.get("targetedNotifications", null);
- long snStart = gf.get("earliestSequenceNumber", -1L);
- long snNext = gf.get("nextSequenceNumber", -1L);
+ ois.defaultReadObject();
try {
- validate(tNotifs, snStart, snNext);
+ validate(
+ this.targetedNotifications,
+ this.earliestSequenceNumber,
+ this.nextSequenceNumber
+ );
- this.targetedNotifications = tNotifs.length == 0 ? tNotifs : tNotifs.clone();
- this.earliestSequenceNumber = snStart;
- this.nextSequenceNumber = snNext;
+ this.targetedNotifications = this.targetedNotifications.length == 0 ?
+ this.targetedNotifications :
+ this.targetedNotifications.clone();
} catch (IllegalArgumentException e) {
throw new InvalidObjectException(e.getMessage());
}
diff -r a8132d72370c -r 42cdf6988c2b src/share/classes/javax/management/remote/TargetedNotification.java
--- jdk/src/share/classes/javax/management/remote/TargetedNotification.java Mon Jul 15 16:00:57 2013 +0100
+++ jdk/src/share/classes/javax/management/remote/TargetedNotification.java Fri Jul 19 16:29:26 2013 +0200
@@ -132,13 +132,9 @@
// }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- ObjectInputStream.GetField gf = ois.readFields();
- Notification notification = (Notification)gf.get("notif", null);
- Integer listenerId = (Integer)gf.get("id", null);
+ ois.defaultReadObject();
try {
- validate(notification, listenerId);
- this.notif = notification;
- this.id = listenerId;
+ validate(this.notif, this.id);
} catch (IllegalArgumentException e) {
throw new InvalidObjectException(e.getMessage());
}
diff -r a8132d72370c -r 42cdf6988c2b test/javax/management/remote/mandatory/loading/MissingClassTest.java
--- jdk/test/javax/management/remote/mandatory/loading/MissingClassTest.java Mon Jul 15 16:00:57 2013 +0100
+++ jdk/test/javax/management/remote/mandatory/loading/MissingClassTest.java Fri Jul 19 16:29:26 2013 +0200
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4915825 4921009 4934965 4977469
+ * @bug 4915825 4921009 4934965 4977469 8019584
* @summary Tests behavior when client or server gets object of unknown class
* @author Eamonn McManus
* @run clean MissingClassTest SingleClassLoader

View File

@ -0,0 +1,68 @@
# HG changeset patch
# User malenkov
# Date 1373994034 -14400
# Tue Jul 16 21:00:34 2013 +0400
# Node ID 9cfb9105241489a5fbc3fcfdea15a6aee15b2cfc
# Parent d80e6f4a4eec26137af6726cfb8abfe108ce23ea
8019617: Better view of objects
Reviewed-by: art, skoivu
diff -r d80e6f4a4eec -r 9cfb91052414 src/share/classes/javax/swing/text/html/ObjectView.java
--- jdk/src/share/classes/javax/swing/text/html/ObjectView.java Tue Aug 06 16:04:14 2013 +0200
+++ jdk/src/share/classes/javax/swing/text/html/ObjectView.java Tue Jul 16 21:00:34 2013 +0400
@@ -31,6 +31,9 @@
import java.beans.*;
import java.lang.reflect.*;
+import sun.reflect.misc.MethodUtil;
+import sun.reflect.misc.ReflectUtil;
+
/**
* Component decorator that implements the view interface
* for &lt;object&gt; elements.
@@ -87,6 +90,7 @@
AttributeSet attr = getElement().getAttributes();
String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID);
try {
+ ReflectUtil.checkPackageAccess(classname);
Class c = Class.forName(classname, true,Thread.currentThread().
getContextClassLoader());
Object o = c.newInstance();
@@ -116,28 +120,6 @@
}
/**
- * Get a Class object to use for loading the
- * classid. If possible, the Classloader
- * used to load the associated Document is used.
- * This would typically be the same as the ClassLoader
- * used to load the EditorKit. If the documents
- * ClassLoader is null,
- * <code>Class.forName</code> is used.
- */
- private Class getClass(String classname) throws ClassNotFoundException {
- Class klass;
-
- Class docClass = getDocument().getClass();
- ClassLoader loader = docClass.getClassLoader();
- if (loader != null) {
- klass = loader.loadClass(classname);
- } else {
- klass = Class.forName(classname);
- }
- return klass;
- }
-
- /**
* Initialize this component according the KEY/VALUEs passed in
* via the &lt;param&gt; elements in the corresponding
* &lt;object&gt; element.
@@ -170,7 +152,7 @@
}
Object [] args = { value };
try {
- writer.invoke(comp, args);
+ MethodUtil.invoke(writer, comp, args);
} catch (Exception ex) {
System.err.println("Invocation failed");
// invocation code

View File

@ -0,0 +1,33 @@
# HG changeset patch
# User michaelm
# Date 1373900457 -3600
# Mon Jul 15 16:00:57 2013 +0100
# Node ID a8132d72370c1f2467c9bb966d9355b387c35039
# Parent bac5d0b011562017738501f02f7db4f39522a62e
8019969: nioNetworkChannelInet6/SetOptionGetOptionTestInet6 test case crashes
Reviewed-by: chegar
diff -r bac5d0b01156 -r a8132d72370c src/windows/native/java/net/net_util_md.c
--- jdk/src/windows/native/java/net/net_util_md.c Tue Oct 29 01:32:58 2013 +0000
+++ jdk/src/windows/native/java/net/net_util_md.c Mon Jul 15 16:00:57 2013 +0100
@@ -879,7 +879,6 @@
family = (iafam == IPv4)? AF_INET : AF_INET6;
if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) {
struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
- jbyteArray ipaddress;
jbyte caddr[16];
jint address, scopeid = 0;
jint cached_scope_id = 0;
@@ -900,10 +899,9 @@
caddr[15] = (address & 0xff);
}
} else {
- ipaddress = (*env)->GetObjectField(env, iaObj, ia6_ipaddressID);
- scopeid = (jint)(*env)->GetIntField(env, iaObj, ia6_scopeidID);
+ getInet6Address_ipaddress(env, iaObj, (char *)caddr);
+ scopeid = getInet6Address_scopeid(env, iaObj);
cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
- (*env)->GetByteArrayRegion(env, ipaddress, 0, 16, caddr);
}
memset((char *)him6, 0, sizeof(struct SOCKADDR_IN6));

View File

@ -0,0 +1,154 @@
# HG changeset patch
# User coffeys
# Date 1373625375 -3600
# Fri Jul 12 11:36:15 2013 +0100
# Node ID 3b6f55f02122398ba662fb581352c9c9b102c2e3
# Parent f7a7c7d70e4968eb99e42f812c59900f545d7fa7
8019979: Replace CheckPackageAccess test with better one from closed repo
Reviewed-by: mullan, robilad
diff -r f7a7c7d70e49 -r 3b6f55f02122 test/java/lang/SecurityManager/CheckPackageAccess.java
--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:18:57 2013 +0100
+++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Jul 12 11:36:15 2013 +0100
@@ -22,31 +22,128 @@
*/
/*
- * @test
- * @bug 7146431 8000450
- * @summary Test that internal packages cannot be accessed
+ * @test
+ * @bug 6741606 7146431 8000450
+ * @summary Make sure all restricted packages listed in the package.access
+ * property in the java.security file are blocked
+ * @run main/othervm CheckPackageAccess
*/
+import java.security.Security;
+import java.util.Collections;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/*
+ * The main benefit of this test is to catch merge errors or other types
+ * of issues where one or more of the packages are accidentally
+ * removed. This is why the packages that are known to be restricted have to
+ * be explicitly listed below.
+ */
public class CheckPackageAccess {
+ /*
+ * This array should be updated whenever new packages are added to the
+ * package.access property in the java.security file
+ */
+ private static final String[] packages = {
+ "sun.",
+ "com.sun.corba.se.impl.",
+ "com.sun.xml.internal.",
+ "com.sun.imageio.",
+ "com.sun.istack.internal.",
+ "com.sun.jmx.",
+ "com.sun.proxy.",
+ "com.sun.org.apache.bcel.internal.",
+ "com.sun.org.apache.regexp.internal.",
+ "com.sun.org.apache.xerces.internal.",
+ "com.sun.org.apache.xpath.internal.",
+ "com.sun.org.apache.xalan.internal.extensions.",
+ "com.sun.org.apache.xalan.internal.lib.",
+ "com.sun.org.apache.xalan.internal.res.",
+ "com.sun.org.apache.xalan.internal.templates.",
+ "com.sun.org.apache.xalan.internal.utils.",
+ "com.sun.org.apache.xalan.internal.xslt.",
+ "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
+ "com.sun.org.apache.xalan.internal.xsltc.compiler.",
+ "com.sun.org.apache.xalan.internal.xsltc.trax.",
+ "com.sun.org.apache.xalan.internal.xsltc.util.",
+ "com.sun.org.apache.xml.internal.res.",
+ "com.sun.org.apache.xml.internal.security.",
+ "com.sun.org.apache.xml.internal.serializer.utils.",
+ "com.sun.org.apache.xml.internal.utils.",
+ "com.sun.org.glassfish.",
+ "oracle.jrockit.jfr.",
+ "org.jcp.xml.dsig.internal.",
+ };
+
public static void main(String[] args) throws Exception {
+ List<String> pkgs = new ArrayList<>(Arrays.asList(packages));
+ String osName = System.getProperty("os.name");
+ if (osName.contains("OS X")) {
+ pkgs.add("apple."); // add apple package for OS X
+ } else if (osName.startsWith("Windows")) {
+ pkgs.add("com.sun.java.accessibility.");
+ }
- String[] pkgs = new String[] {
- "com.sun.corba.se.impl.",
- "com.sun.org.apache.xerces.internal.utils.",
- "com.sun.org.apache.xalan.internal.utils." };
- SecurityManager sm = new SecurityManager();
- System.setSecurityManager(sm);
- for (String pkg : pkgs) {
- System.out.println("Checking package access for " + pkg);
+ List<String> jspkgs =
+ getPackages(Security.getProperty("package.access"));
+
+ // Sort to ensure lists are comparable
+ Collections.sort(pkgs);
+ Collections.sort(jspkgs);
+
+ if (!pkgs.equals(jspkgs)) {
+ for (String p : pkgs)
+ if (!jspkgs.contains(p))
+ System.out.println("In golden set, but not in j.s file: " + p);
+ for (String p : jspkgs)
+ if (!pkgs.contains(p))
+ System.out.println("In j.s file, but not in golden set: " + p);
+
+
+ throw new RuntimeException("restricted packages are not " +
+ "consistent with java.security file");
+ }
+ System.setSecurityManager(new SecurityManager());
+ SecurityManager sm = System.getSecurityManager();
+ for (String pkg : packages) {
+ String subpkg = pkg + "foo";
try {
sm.checkPackageAccess(pkg);
- throw new Exception("Expected PackageAccess SecurityException not thrown");
+ throw new RuntimeException("Able to access " + pkg +
+ " package");
+ } catch (SecurityException se) { }
+ try {
+ sm.checkPackageAccess(subpkg);
+ throw new RuntimeException("Able to access " + subpkg +
+ " package");
} catch (SecurityException se) { }
try {
sm.checkPackageDefinition(pkg);
- throw new Exception("Expected PackageDefinition SecurityException not thrown");
+ throw new RuntimeException("Able to define class in " + pkg +
+ " package");
+ } catch (SecurityException se) { }
+ try {
+ sm.checkPackageDefinition(subpkg);
+ throw new RuntimeException("Able to define class in " + subpkg +
+ " package");
} catch (SecurityException se) { }
}
+ System.out.println("Test passed");
+ }
+
+ private static List<String> getPackages(String p) {
+ List<String> packages = new ArrayList<>();
+ if (p != null && !p.equals("")) {
+ StringTokenizer tok = new StringTokenizer(p, ",");
+ while (tok.hasMoreElements()) {
+ String s = tok.nextToken().trim();
+ packages.add(s);
+ }
+ }
+ return packages;
}
}

View File

@ -0,0 +1,40 @@
# HG changeset patch
# User jchen
# Date 1374527199 25200
# Mon Jul 22 14:06:39 2013 -0700
# Node ID 2adb9f71f6c0723acf40877f059d276557b71034
# Parent 150e0c3e95ce6869f8e7b42c6d8683817433e124
8020293: JVM crash
Reviewed-by: prr, jgodinez
diff -r 150e0c3e95ce -r 2adb9f71f6c0 src/share/classes/sun/font/GlyphLayout.java
--- jdk/src/share/classes/sun/font/GlyphLayout.java Mon Oct 28 20:56:09 2013 +0000
+++ jdk/src/share/classes/sun/font/GlyphLayout.java Mon Jul 22 14:06:39 2013 -0700
@@ -468,9 +468,10 @@
_gvdata.grow();
}
}
- if (_gvdata._count < 0) {
- break;
- }
+ }
+ // Break out of the outer for loop if layout fails.
+ if (_gvdata._count < 0) {
+ break;
}
}
diff -r 150e0c3e95ce -r 2adb9f71f6c0 src/share/native/sun/font/layout/SunLayoutEngine.cpp
--- jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Mon Oct 28 20:56:09 2013 +0000
+++ jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Mon Jul 22 14:06:39 2013 -0700
@@ -104,6 +104,10 @@
int putGV(JNIEnv* env, jint gmask, jint baseIndex, jobject gvdata, const LayoutEngine* engine, int glyphCount) {
int count = env->GetIntField(gvdata, gvdCountFID);
+ if (count < 0) {
+ JNU_ThrowInternalError(env, "count negative");
+ return 0;
+ }
jarray glyphArray = (jarray)env->GetObjectField(gvdata, gvdGlyphsFID);
if (IS_NULL(glyphArray)) {

View File

@ -0,0 +1,32 @@
# HG changeset patch
# User kevinw
# Date 1375442806 -3600
# Fri Aug 02 12:26:46 2013 +0100
# Node ID 2660219948088d89dd3fc285e093dab2520349e5
# Parent 4b3487aa553cca3fb7ecb74d284b9524d0bf5bf8
8020943: Memory leak when GCNotifier uses create_from_platform_dependent_str()
Reviewed-by: mgerdin, fparain, dcubed
diff -r 4b3487aa553c -r 266021994808 src/share/vm/services/gcNotifier.cpp
--- hotspot/src/share/vm/services/gcNotifier.cpp Thu Oct 17 19:28:00 2013 +0100
+++ hotspot/src/share/vm/services/gcNotifier.cpp Fri Aug 02 12:26:46 2013 +0100
@@ -1,5 +1,5 @@
/*
- * 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
@@ -211,9 +211,9 @@
NotificationMark nm(request);
Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
- Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
- Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
- Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
+ Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
+ Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
+ Handle objCause = java_lang_String::create_from_str(request->gcCause, CHECK);
klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
instanceKlassHandle gc_mbean_klass(THREAD, k);

View File

@ -0,0 +1,55 @@
# HG changeset patch
# User mullan
# Date 1375219222 14400
# Tue Jul 30 17:20:22 2013 -0400
# Node ID 3e758b40337ef9da5ad030d0ac60ab4407357277
# Parent 5e3c766d18092d498d9019827c1058a32f1c4e2a
8021290: Better signature validation
Reviewed-by: xuelei, ahgross
diff -r 5e3c766d1809 -r 3e758b40337e src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
--- jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Fri Oct 15 10:55:59 2010 -0400
+++ jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Tue Jul 30 17:20:22 2013 -0400
@@ -44,6 +44,9 @@
}
public void write(byte[] arg0) {
+ if ((Integer.MAX_VALUE - pos) < arg0.length) {
+ throw new OutOfMemoryError();
+ }
int newPos = pos + arg0.length;
if (newPos > size) {
expandSize(newPos);
@@ -53,6 +56,9 @@
}
public void write(byte[] arg0, int arg1, int arg2) {
+ if ((Integer.MAX_VALUE - pos) < arg2) {
+ throw new OutOfMemoryError();
+ }
int newPos = pos + arg2;
if (newPos > size) {
expandSize(newPos);
@@ -62,6 +68,9 @@
}
public void write(int arg0) {
+ if ((Integer.MAX_VALUE - pos) == 0) {
+ throw new OutOfMemoryError();
+ }
int newPos = pos + 1;
if (newPos > size) {
expandSize(newPos);
@@ -82,7 +91,11 @@
private void expandSize(int newPos) {
int newSize = size;
while (newPos > newSize) {
- newSize = newSize<<2;
+ newSize = newSize << 1;
+ // Deal with overflow
+ if (newSize < 0) {
+ newSize = Integer.MAX_VALUE;
+ }
}
byte newBuf[] = new byte[newSize];
System.arraycopy(buf, 0, newBuf, 0, pos);

View File

@ -0,0 +1,53 @@
# HG changeset patch
# User ksrini
# Date 1383014349 0
# Tue Oct 29 02:39:09 2013 +0000
# Node ID a5d00a180798f25254bf6f15b7dc31a0d5df60c2
# Parent 5896fe42b0a429fb5be7abee630b98fa2ec00df3
8021355: REGRESSION: Five closed/java/awt/SplashScreen tests fail since 7u45 b01 on Linux, Solaris
Reviewed-by: dholmes, anthony, ahgross, erikj, omajid
diff -r 5896fe42b0a4 -r a5d00a180798 src/solaris/bin/java_md.c
--- jdk/src/solaris/bin/java_md.c Wed Aug 07 16:51:59 2013 +0400
+++ jdk/src/solaris/bin/java_md.c Tue Oct 29 02:39:09 2013 +0000
@@ -46,6 +46,10 @@
#define JVM_DLL "libjvm.so"
#define JAVA_DLL "libjava.so"
+#define JRE_ERROR1 "Error: Could not find Java SE Runtime Environment."
+#define JRE_ERROR11 "Error: Path length exceeds maximum length (PATH_MAX)"
+#define JRE_ERROR13 "Error: String processing operation failed"
+
/*
* If a processor / os combination has the ability to run binaries of
* two data models and cohabitation of jre/jdk bits with both data
@@ -1700,7 +1704,28 @@
void* SplashProcAddress(const char* name) {
if (!hSplashLib) {
- hSplashLib = dlopen(SPLASHSCREEN_SO, RTLD_LAZY | RTLD_GLOBAL);
+ int ret;
+ char jrePath[MAXPATHLEN];
+ char splashPath[MAXPATHLEN];
+
+ if (!GetJREPath(jrePath, sizeof(jrePath), GetArch(), JNI_FALSE)) {
+ ReportErrorMessage(JRE_ERROR1, JNI_TRUE);
+ return NULL;
+ }
+ ret = snprintf(splashPath, sizeof(splashPath), "%s/lib/%s/%s",
+ jrePath, GetArch(), SPLASHSCREEN_SO);
+
+ if (ret >= (int) sizeof(splashPath)) {
+ ReportErrorMessage(JRE_ERROR11, JNI_TRUE);
+ return NULL;
+ }
+ if (ret < 0) {
+ ReportErrorMessage(JRE_ERROR13, JNI_TRUE);
+ return NULL;
+ }
+ hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL);
+ if (_launcher_debug)
+ printf("Info: loaded %s\n", splashPath);
}
if (hSplashLib) {
void* sym = dlsym(hSplashLib, name);

View File

@ -0,0 +1,21 @@
# HG changeset patch
# User joehw
# Date 1375178534 25200
# Tue Jul 30 03:02:14 2013 -0700
# Node ID 674ada27a93f4ecd359617d5a27cb2dfe52c44b4
# Parent 0927621944ccb163d7dcdea7b94b10dfab58f5f1
8021366: java_util/Properties/PropertiesWithOtherEncodings fails during 7u45 nightly testing
Reviewed-by: lancea, alanb, dfuchs, mullan
diff -r 0927621944cc -r 674ada27a93f drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java
--- jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Oct 29 08:01:29 2013 +0000
+++ jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Jul 30 03:02:14 2013 -0700
@@ -248,7 +248,7 @@
public int fBufferSize = DEFAULT_BUFFER_SIZE;
/** Default buffer size before we've finished with the XMLDecl: */
- public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
+ public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 28;
/** Default internal entity buffer size (1024). */
public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;

View File

@ -0,0 +1,25 @@
# HG changeset patch
# User jbachorik
# Date 1375098221 25200
# Mon Jul 29 04:43:41 2013 -0700
# Node ID 21358b9e406319f4d9ddfd663572dd71a093ce08
# Parent 42cdf6988c2b81b322bf89778ddeb47265cd3bba
8021577: JCK test api/javax_management/jmx_serial/modelmbean/ModelMBeanNotificationInfo/serial/index.html#Input has failed since jdk 7u45 b01
Reviewed-by: alanb, dfuchs, ahgross
diff -r 42cdf6988c2b -r 21358b9e4063 src/share/classes/javax/management/MBeanNotificationInfo.java
--- jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Fri Jul 19 16:29:26 2013 +0200
+++ jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Mon Jul 29 04:43:41 2013 -0700
@@ -210,11 +210,6 @@
ObjectInputStream.GetField gf = ois.readFields();
String[] t = (String[])gf.get("types", null);
- if (t == null) {
- throw new InvalidObjectException("Trying to deserialize an invalid " +
- "instance of " + MBeanNotificationInfo.class +
- "[types=null]");
- }
- types = t.length == 0 ? t : t.clone();
+ types = (t != null && t.length != 0) ? t.clone() : NO_TYPES;
}
}

View File

@ -0,0 +1,33 @@
# HG changeset patch
# User joehw
# Date 1375252858 25200
# Tue Jul 30 23:40:58 2013 -0700
# Node ID dce0c261a1837e664e4d8739b97e8758a1fa0de2
# Parent 674ada27a93f4ecd359617d5a27cb2dfe52c44b4
8021933: Add extra check for fix # JDK-8014530
Reviewed-by: alanb, lancea
diff -r 674ada27a93f -r dce0c261a183 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Jul 30 03:02:14 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Jul 30 23:40:58 2013 -0700
@@ -1237,7 +1237,7 @@
//Revisit :: IMO this is not right place to check
// maxOccurNodeLimit.
int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
- if (max > maxOccurNodeLimit) {
+ if (max > maxOccurNodeLimit && !fSchemaHandler.fSecureProcessing.isNoLimit(maxOccurNodeLimit)) {
reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
// reset max values in case processing continues on error
diff -r 674ada27a93f -r dce0c261a183 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Jul 30 03:02:14 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Jul 30 23:40:58 2013 -0700
@@ -257,7 +257,7 @@
"FeatureNameNull", null));
}
if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
- return (fSecurityManager != null);
+ return (fSecurityManager !=null && fSecurityManager.isSecureProcessing());
}
try {
return fXMLSchemaLoader.getFeature(name);

View File

@ -0,0 +1,25 @@
# HG changeset patch
# User malenkov
# Date 1375879919 -14400
# Wed Aug 07 16:51:59 2013 +0400
# Node ID 5896fe42b0a429fb5be7abee630b98fa2ec00df3
# Parent 21358b9e406319f4d9ddfd663572dd71a093ce08
8021969: The index_AccessAllowed jnlp can not load successfully with exception thrown in the log.
Reviewed-by: art, skoivu
diff -r 21358b9e4063 -r 5896fe42b0a4 src/share/classes/java/awt/datatransfer/DataFlavor.java
--- jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Mon Jul 29 04:43:41 2013 -0700
+++ jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Wed Aug 07 16:51:59 2013 +0400
@@ -145,11 +145,7 @@
} catch (SecurityException exception) {
// ignore secured class loaders
}
- if (fallback != null) {
- return Class.forName(className, true, fallback);
- } else {
- throw new ClassNotFoundException(className);
- }
+ return Class.forName(className, true, fallback);
}
/*

View File

@ -0,0 +1,20 @@
# HG changeset patch
# User chegar
# Date 1376052613 -3600
# Fri Aug 09 13:50:13 2013 +0100
# Node ID 6c0b775b1ff2a0a0ba0fe797cfe18c511f9ee3c1
# Parent a5d00a180798f25254bf6f15b7dc31a0d5df60c2
8022661: InetAddress.writeObject() performs flush() on object output stream
Reviewed-by: michaelm, alanb
diff -r a5d00a180798 -r 6c0b775b1ff2 src/share/classes/java/net/InetAddress.java
--- jdk/src/share/classes/java/net/InetAddress.java Tue Oct 29 02:39:09 2013 +0000
+++ jdk/src/share/classes/java/net/InetAddress.java Fri Aug 09 13:50:13 2013 +0100
@@ -1586,7 +1586,6 @@
pf.put("address", holder().address);
pf.put("family", holder().family);
s.writeFields();
- s.flush();
}
}

View File

@ -0,0 +1,250 @@
# HG changeset patch
# User joehw
# Date 1383034215 0
# Tue Oct 29 08:10:15 2013 +0000
# Node ID 20ffb814205c67b5ded678ee6c69b2aa0d6cebb1
# Parent dce0c261a1837e664e4d8739b97e8758a1fa0de2
8022682: Supporting XOM
Reviewed-by: alanb, chegar, lancea
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Oct 29 08:10:15 2013 +0000
@@ -168,6 +168,17 @@
//add internal stax property
supportedProps.put( Constants.XERCES_PROPERTY_PREFIX + Constants.STAX_ENTITY_RESOLVER_PROPERTY , new StaxEntityResolverWrapper((XMLResolver)value)) ;
}
+
+ /**
+ * It's possible for users to set a security manager through the interface.
+ * If it's the old SecurityManager, convert it to the new XMLSecurityManager
+ */
+ if (property.equals(Constants.SECURITY_MANAGER)) {
+ fSecurityManager = XMLSecurityManager.convert(value, fSecurityManager);
+ supportedProps.put(Constants.SECURITY_MANAGER, fSecurityManager);
+ return;
+ }
+
supportedProps.put(property, value ) ;
if(equivalentProperty != null){
supportedProps.put(equivalentProperty, value ) ;
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 08:10:15 2013 +0000
@@ -352,7 +352,7 @@
"ProperyNameNull", null));
}
if (name.equals(SECURITY_MANAGER)) {
- fSecurityManager = (XMLSecurityManager) object;
+ fSecurityManager = XMLSecurityManager.convert(object, fSecurityManager);
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
return;
}
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java Tue Oct 29 08:10:15 2013 +0000
@@ -28,6 +28,7 @@
import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
@@ -528,7 +529,30 @@
*/
public void setProperty(String propertyId, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
+ /**
+ * It's possible for users to set a security manager through the interface.
+ * If it's the old SecurityManager, convert it to the new XMLSecurityManager
+ */
+ if (propertyId.equals(Constants.SECURITY_MANAGER)) {
+ securityManager = XMLSecurityManager.convert(value, securityManager);
+ setProperty0(Constants.SECURITY_MANAGER, securityManager);
+ return;
+ }
+ if (securityManager == null) {
+ securityManager = new XMLSecurityManager(true);
+ setProperty0(Constants.SECURITY_MANAGER, securityManager);
+ }
+
+ //check if the property is managed by security manager
+ if (!securityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) {
+ //fall back to the default configuration to handle the property
+ setProperty0(propertyId, value);
+ }
+ }
+
+ public void setProperty0(String propertyId, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
try {
fConfiguration.setProperty(propertyId, value);
}
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java Tue Oct 29 08:10:15 2013 +0000
@@ -181,6 +181,9 @@
protected static final String LOCALE =
Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
+ /** Property identifier: Security manager. */
+ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
+
// debugging
/** Set to true and recompile to print exception stack trace. */
@@ -325,7 +328,8 @@
VALIDATION_MANAGER,
JAXP_SCHEMA_SOURCE,
JAXP_SCHEMA_LANGUAGE,
- LOCALE
+ LOCALE,
+ SECURITY_MANAGER
};
addRecognizedProperties(recognizedProperties);
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java Tue Oct 29 08:10:15 2013 +0000
@@ -154,6 +154,9 @@
protected static final String LOCALE =
Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
+ /** Property identifier: Security manager. */
+ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
+
// debugging
/** Set to true and recompile to print exception stack trace. */
@@ -307,7 +310,8 @@
XMLGRAMMAR_POOL,
DATATYPE_VALIDATOR_FACTORY,
VALIDATION_MANAGER,
- LOCALE
+ LOCALE,
+ SECURITY_MANAGER
};
addRecognizedProperties(recognizedProperties);
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Oct 29 08:10:15 2013 +0000
@@ -74,7 +74,7 @@
XMLGRAMMAR_POOL,
};
- XMLSecurityManager securityManager;
+
//
// Constructors
//
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Oct 29 08:10:15 2013 +0000
@@ -563,8 +563,6 @@
fVersionDetector = new XMLVersionDetector();
- fProperties.put(SECURITY_MANAGER, new XMLSecurityManager(true));
-
// add message formatters
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
XMLMessageFormatter xmft = new XMLMessageFormatter();
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java Tue Oct 29 08:10:15 2013 +0000
@@ -23,6 +23,7 @@
import java.io.IOException;
import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
@@ -78,6 +79,10 @@
/** The parser configuration. */
protected XMLParserConfiguration fConfiguration;
+ /** The XML Security Manager. */
+ XMLSecurityManager securityManager;
+
+
//
// Constructors
//
@@ -118,6 +123,11 @@
*/
public void parse(XMLInputSource inputSource)
throws XNIException, IOException {
+ // null indicates that the parser is called directly, initialize them
+ if (securityManager == null) {
+ securityManager = new XMLSecurityManager(true);
+ fConfiguration.setProperty(Constants.SECURITY_MANAGER, securityManager);
+ }
reset();
fConfiguration.parse(inputSource);
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Tue Oct 29 08:10:15 2013 +0000
@@ -203,6 +203,9 @@
}
public boolean isTracking(String name) {
+ if (entityStart == null) {
+ return false;
+ }
return entityStart.equals(name);
}
/**
diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Jul 30 23:40:58 2013 -0700
+++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Oct 29 08:10:15 2013 +0000
@@ -26,6 +26,7 @@
package com.sun.org.apache.xerces.internal.utils;
import com.sun.org.apache.xerces.internal.impl.Constants;
+import com.sun.org.apache.xerces.internal.util.SecurityManager;
/**
* This class manages standard and implementation-specific limitations.
@@ -518,4 +519,37 @@
}
return false;
}
+
+
+ /**
+ * Convert a value set through setProperty to XMLSecurityManager.
+ * If the value is an instance of XMLSecurityManager, use it to override the default;
+ * If the value is an old SecurityManager, convert to the new XMLSecurityManager.
+ *
+ * @param value user specified security manager
+ * @param securityManager an instance of XMLSecurityManager
+ * @return an instance of the new security manager XMLSecurityManager
+ */
+ static public XMLSecurityManager convert(Object value, XMLSecurityManager securityManager) {
+ if (value == null) {
+ if (securityManager == null) {
+ securityManager = new XMLSecurityManager(true);
+ }
+ return securityManager;
+ }
+ if (XMLSecurityManager.class.isAssignableFrom(value.getClass())) {
+ return (XMLSecurityManager)value;
+ } else {
+ if (securityManager == null) {
+ securityManager = new XMLSecurityManager(true);
+ }
+ if (SecurityManager.class.isAssignableFrom(value.getClass())) {
+ SecurityManager origSM = (SecurityManager)value;
+ securityManager.setLimit(Limit.MAX_OCCUR_NODE_LIMIT, State.APIPROPERTY, origSM.getMaxOccurNodeLimit());
+ securityManager.setLimit(Limit.ENTITY_EXPANSION_LIMIT, State.APIPROPERTY, origSM.getEntityExpansionLimit());
+ securityManager.setLimit(Limit.ELEMENT_ATTRIBUTE_LIMIT, State.APIPROPERTY, origSM.getElementAttrLimit());
+ }
+ return securityManager;
+ }
+ }
}

View File

@ -0,0 +1,41 @@
# HG changeset patch
# User msheppar
# Date 1376928111 -3600
# Mon Aug 19 17:01:51 2013 +0100
# Node ID b449df31dbfbf08d0f58a887649c2acacd5d834f
# Parent 2a415f9ee0976719ac79e6e5e2b1f00b29636427
8022940: Enhance CORBA translations
Reviewed-by: coffeys, alanb, skoivu
diff -r 2a415f9ee097 -r b449df31dbfb src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java
--- corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java Thu Jul 18 17:22:25 2013 -0700
+++ corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java Mon Aug 19 17:01:51 2013 +0100
@@ -905,28 +905,4 @@
return contents.toString();
}
-
- public static void main(String[] args) {
-
- Class remoteInterface = java.rmi.Remote.class;
-
- if( args.length > 0 ) {
- String className = args[0];
- try {
- remoteInterface = Class.forName(className);
- } catch(Exception e) {
- e.printStackTrace();
- System.exit(-1);
- }
- }
-
- System.out.println("Building name translation for " + remoteInterface);
- try {
- IDLNameTranslator nameTranslator =
- IDLNameTranslatorImpl.get(remoteInterface);
- System.out.println(nameTranslator);
- } catch(IllegalStateException ise) {
- ise.printStackTrace();
- }
- }
}

View File

@ -0,0 +1,79 @@
# HG changeset patch
# User mgronlun
# Date 1382034480 -3600
# Thu Oct 17 19:28:00 2013 +0100
# Node ID 4b3487aa553cca3fb7ecb74d284b9524d0bf5bf8
# Parent 3091721c83780cbb9a946f05007651e0bd09490b
8023457: Event based tracing framework needs a mutex for thread groups
Reviewed-by: acorn, sla
diff -r 3091721c8378 -r 4b3487aa553c src/share/vm/runtime/mutexLocker.cpp
--- hotspot/src/share/vm/runtime/mutexLocker.cpp Sat Aug 24 00:14:46 2013 -0700
+++ hotspot/src/share/vm/runtime/mutexLocker.cpp Thu Oct 17 19:28:00 2013 +0100
@@ -134,12 +134,16 @@
Mutex* Management_lock = NULL;
Monitor* Service_lock = NULL;
-Mutex* Stacktrace_lock = NULL;
+Monitor* PeriodicTask_lock = NULL;
+#ifdef INCLUDE_TRACE
Monitor* JfrQuery_lock = NULL;
+Mutex* JfrStacktrace_lock = NULL;
Monitor* JfrMsg_lock = NULL;
Mutex* JfrBuffer_lock = NULL;
Mutex* JfrStream_lock = NULL;
+Mutex* JfrThreadGroups_lock = NULL;
+#endif
#define MAX_NUM_MUTEX 128
static Monitor * _mutex_array[MAX_NUM_MUTEX];
@@ -215,7 +219,6 @@
def(Patching_lock , Mutex , special, true ); // used for safepointing and code patching.
def(ObjAllocPost_lock , Monitor, special, false);
def(Service_lock , Monitor, special, true ); // used for service thread operations
- def(Stacktrace_lock , Mutex, special, true ); // used for JFR stacktrace database
def(JmethodIdCreation_lock , Mutex , leaf, true ); // used for creating jmethodIDs.
def(SystemDictionary_lock , Monitor, leaf, true ); // lookups done by VM thread
@@ -279,12 +282,18 @@
def(Debug2_lock , Mutex , nonleaf+4, true );
def(Debug3_lock , Mutex , nonleaf+4, true );
def(ProfileVM_lock , Monitor, nonleaf+4, false); // used for profiling of the VMThread
- def(CompileThread_lock , Monitor, nonleaf+5, false );
+ def(CompileThread_lock , Monitor, nonleaf+5, false);
+ def(PeriodicTask_lock , Monitor, nonleaf+5, true);
+#ifdef INCLUDE_TRACE
def(JfrQuery_lock , Monitor, nonleaf, true); // JFR locks, keep these in consecutive order
def(JfrMsg_lock , Monitor, nonleaf+2, true);
def(JfrBuffer_lock , Mutex, nonleaf+3, true);
+ def(JfrThreadGroups_lock , Mutex, nonleaf+1, true);
def(JfrStream_lock , Mutex, nonleaf+4, true);
+ def(JfrStacktrace_lock , Mutex, special, true );
+#endif
+
}
GCMutexLocker::GCMutexLocker(Monitor * mutex) {
diff -r 3091721c8378 -r 4b3487aa553c src/share/vm/runtime/mutexLocker.hpp
--- hotspot/src/share/vm/runtime/mutexLocker.hpp Sat Aug 24 00:14:46 2013 -0700
+++ hotspot/src/share/vm/runtime/mutexLocker.hpp Thu Oct 17 19:28:00 2013 +0100
@@ -136,12 +136,16 @@
extern Mutex* Management_lock; // a lock used to serialize JVM management
extern Monitor* Service_lock; // a lock used for service thread operation
-extern Mutex* Stacktrace_lock; // used to guard access to the stacktrace table
+extern Monitor* PeriodicTask_lock; // protects the periodic task structure
+#ifdef INCLUDE_TRACE
+extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table
extern Monitor* JfrQuery_lock; // protects JFR use
extern Monitor* JfrMsg_lock; // protects JFR messaging
extern Mutex* JfrBuffer_lock; // protects JFR buffer operations
extern Mutex* JfrStream_lock; // protects JFR stream access
+extern Mutex* JfrThreadGroups_lock; // protects JFR access to Thread Groups
+#endif
// A MutexLocker provides mutual exclusion with respect to a given mutex
// for the scope which contains the locker. The lock is an OS lock, not

View File

@ -0,0 +1,21 @@
# HG changeset patch
# User kevinw
# Date 1379364550 25200
# Mon Sep 16 13:49:10 2013 -0700
# Node ID e8d1979fe077eda9a94528c4b76dd4c5243d5dec
# Parent 2660219948088d89dd3fc285e093dab2520349e5
8023478: Test fails with HS crash in GCNotifier.
Reviewed-by: sla
diff -r 266021994808 -r e8d1979fe077 src/share/vm/services/gcNotifier.cpp
--- hotspot/src/share/vm/services/gcNotifier.cpp Fri Aug 02 12:26:46 2013 +0100
+++ hotspot/src/share/vm/services/gcNotifier.cpp Mon Sep 16 13:49:10 2013 -0700
@@ -209,7 +209,7 @@
GCNotificationRequest *request = getRequest();
if (request != NULL) {
NotificationMark nm(request);
- Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
+ Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, CHECK);
Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);

View File

@ -0,0 +1,35 @@
# HG changeset patch
# User iklam
# Date 1377328486 25200
# Sat Aug 24 00:14:46 2013 -0700
# Node ID 3091721c83780cbb9a946f05007651e0bd09490b
# Parent bbd051c9089f61c65fe7d95487d47920164c7ee0
8023683: Enhance class file parsing
Summary: Use the value returned by REALLOC_RESOURCE_ARRAY()
Reviewed-by: coleenp, ahgross
diff -r bbd051c9089f -r 3091721c8378 src/share/vm/classfile/classFileParser.cpp
--- hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jul 15 10:22:43 2013 +0400
+++ hotspot/src/share/vm/classfile/classFileParser.cpp Sat Aug 24 00:14:46 2013 -0700
@@ -1821,8 +1821,8 @@
}
if (lvt_cnt == max_lvt_cnt) {
max_lvt_cnt <<= 1;
- REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
- REALLOC_RESOURCE_ARRAY(u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
+ localvariable_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
+ localvariable_table_start = REALLOC_RESOURCE_ARRAY(u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
}
localvariable_table_start[lvt_cnt] =
parse_localvariable_table(code_length,
@@ -1851,8 +1851,8 @@
// Parse local variable type table
if (lvtt_cnt == max_lvtt_cnt) {
max_lvtt_cnt <<= 1;
- REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
- REALLOC_RESOURCE_ARRAY(u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
+ localvariable_type_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
+ localvariable_type_table_start = REALLOC_RESOURCE_ARRAY(u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
}
localvariable_type_table_start[lvtt_cnt] =
parse_localvariable_table(code_length,

Some files were not shown because too many files have changed in this diff Show More