From 65d83871e2a784c12e9edc3f1115991161b6138f Mon Sep 17 00:00:00 2001 From: Yunda Date: Tue, 23 Jul 2013 14:32:37 +0200 Subject: [PATCH 001/117] 8011888: sa.js: TypeError: [object JSAdapter] has no such function "__has__" Reviewed-by: sla, sundar, kmo --- .../sun/jvm/hotspot/utilities/soql/sa.js | 90 +++++++++++++------ 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index ec22e35e633..4253740369b 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -35,8 +35,9 @@ sapkg.c1 = sapkg.hotspot.c1; sapkg.code = sapkg.hotspot.code; sapkg.compiler = sapkg.hotspot.compiler; -// 'debugger' is a JavaScript keyword :-( -// sapkg.debugger = sapkg.hotspot.debugger; +// 'debugger' is a JavaScript keyword, but ES5 relaxes the +// restriction of using keywords as property name +sapkg.debugger = sapkg.hotspot.debugger; sapkg.interpreter = sapkg.hotspot.interpreter; sapkg.jdi = sapkg.hotspot.jdi; @@ -116,27 +117,36 @@ function main(globals, jvmarg) { return args; } + // Handle __has__ specially to avoid metacircularity problems + // when called from __get__. + // Calling + // this.__has__(name) + // will in turn call + // this.__call__('__has__', name) + // which is not handled below + function __has__(name) { + if (typeof(name) == 'number') { + return so["has(int)"](name); + } else { + if (name == '__wrapped__') { + return true; + } else if (so["has(java.lang.String)"](name)) { + return true; + } else if (name.equals('toString')) { + return true; + } else { + return false; + } + } + } + if (so instanceof sapkg.utilities.soql.ScriptObject) { return new JSAdapter() { - __getIds__: function() { - return so.getIds(); + __getIds__: function() { + return so.getIds(); }, - __has__ : function(name) { - if (typeof(name) == 'number') { - return so["has(int)"](name); - } else { - if (name == '__wrapped__') { - return true; - } else if (so["has(java.lang.String)"](name)) { - return true; - } else if (name.equals('toString')) { - return true; - } else { - return false; - } - } - }, + __has__ : __has__, __delete__ : function(name) { if (typeof(name) == 'number') { @@ -147,7 +157,8 @@ function main(globals, jvmarg) { }, __get__ : function(name) { - if (! this.__has__(name)) { + // don't call this.__has__(name); see comments above function __has__ + if (! __has__.call(this, name)) { return undefined; } if (typeof(name) == 'number') { @@ -162,7 +173,7 @@ function main(globals, jvmarg) { var args = prepareArgsArray(arguments); var r; try { - r = value.call(args); + r = value.call(Java.to(args, 'java.lang.Object[]')); } catch (e) { println("call to " + name + " failed!"); throw e; @@ -204,6 +215,18 @@ function main(globals, jvmarg) { } // define "writeln" and "write" if not defined + if (typeof(println) == 'undefined') { + println = function (str) { + java.lang.System.out.println(String(str)); + } + } + + if (typeof(print) == 'undefined') { + print = function (str) { + java.lang.System.out.print(String(str)); + } + } + if (typeof(writeln) == 'undefined') { writeln = println; } @@ -235,7 +258,7 @@ function main(globals, jvmarg) { this.jclasses = function() { forEachKlass(function (clazz) { - writeln(clazz.getName().asString() + " @" + clazz.getHandle().toString()); + writeln(clazz.getName().asString() + " @" + clazz.getAddress().toString()); }); } registerCommand("classes", "classes", "jclasses"); @@ -490,14 +513,14 @@ function systemLoader() { function forEachKlass(callback) { var VisitorClass = sapkg.memory.SystemDictionary.ClassVisitor; var visitor = new VisitorClass() { visit: callback }; - sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary$ClassVisitor)"](visitor); + sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary.ClassVisitor)"](visitor); } // iterate system dictionary for each 'Klass' and initiating loader function forEachKlassAndLoader(callback) { var VisitorClass = sapkg.memory.SystemDictionary.ClassAndLoaderVisitor; var visitor = new VisitorClass() { visit: callback }; - sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary$ClassAndLoaderVisitor)"](visitor); + sa.sysDict["classesDo(sun.jvm.hotspot.memory.SystemDictionary.ClassAndLoaderVisitor)"](visitor); } // iterate system dictionary for each primitive array klass @@ -522,7 +545,12 @@ function obj2oop(obj) { // iterates Java heap for each Oop function forEachOop(callback) { - sa.objHeap.iterate(new sapkg.oops.HeapVisitor() { doObj: callback }); + function empty() { } + sa.objHeap.iterate(new sapkg.oops.HeapVisitor() { + prologue: empty, + doObj: callback, + epilogue: empty + }); } // iterates Java heap for each Oop of given 'klass'. @@ -536,8 +564,14 @@ function forEachOopOfKlass(callback, klass, includeSubtypes) { if (includeSubtypes == undefined) { includeSubtypes = true; } + + function empty() { } sa.objHeap.iterateObjectsOfKlass( - new sapkg.oops.HeapVisitor() { doObj: callback }, + new sapkg.oops.HeapVisitor() { + prologue: empty, + doObj: callback, + epilogue: empty + }, klass, includeSubtypes); } @@ -746,9 +780,9 @@ while (tmp.itr.hasNext()) { // ignore; continue; } else { - // some type names have ':'. replace to make it as a + // some type names have ':', '<', '>', '*', ' '. replace to make it as a // JavaScript identifier - tmp.name = tmp.name.replace(':', '_').replace('<', '_').replace('>', '_').replace('*', '_').replace(' ', '_'); + tmp.name = ("" + tmp.name).replace(/[:<>* ]/g, '_'); eval("function read" + tmp.name + "(addr) {" + " return readVMType('" + tmp.name + "', addr);}"); eval("function print" + tmp.name + "(addr) {" + From 7d471dd141cca96be282d0dbe3019011068cc5ab Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Fri, 9 Aug 2013 09:05:20 -0700 Subject: [PATCH 002/117] 8023681: Fix raw type warning caused by Sink Reviewed-by: mduigou, briangoetz --- .../classes/java/util/stream/Collectors.java | 40 +++++++++---------- .../classes/java/util/stream/DistinctOps.java | 4 +- .../java/util/stream/DoublePipeline.java | 15 ++++--- .../classes/java/util/stream/IntPipeline.java | 21 +++++----- .../java/util/stream/LongPipeline.java | 19 ++++----- .../java/util/stream/ReferencePipeline.java | 26 ++++++------ .../share/classes/java/util/stream/Sink.java | 28 ++++++------- .../classes/java/util/stream/SliceOps.java | 25 +++++++----- .../classes/java/util/stream/SortedOps.java | 34 ++++++++-------- 9 files changed, 101 insertions(+), 111 deletions(-) diff --git a/jdk/src/share/classes/java/util/stream/Collectors.java b/jdk/src/share/classes/java/util/stream/Collectors.java index 27c7c83ead4..bdbd8ad0774 100644 --- a/jdk/src/share/classes/java/util/stream/Collectors.java +++ b/jdk/src/share/classes/java/util/stream/Collectors.java @@ -137,6 +137,11 @@ public final class Collectors { return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; } + @SuppressWarnings("unchecked") + private static Function castingIdentity() { + return i -> (R) i; + } + /** * Simple implementation class for {@code Collector}. * @@ -166,7 +171,7 @@ public final class Collectors { BiConsumer accumulator, BinaryOperator combiner, Set characteristics) { - this(supplier, accumulator, combiner, i -> (R) i, characteristics); + this(supplier, accumulator, combiner, castingIdentity(), characteristics); } @Override @@ -209,7 +214,7 @@ public final class Collectors { */ public static > Collector toCollection(Supplier collectionFactory) { - return new CollectorImpl<>(collectionFactory, Collection::add, + return new CollectorImpl<>(collectionFactory, Collection::add, (r1, r2) -> { r1.addAll(r2); return r1; }, CH_ID); } @@ -1046,30 +1051,23 @@ public final class Collectors { public static Collector> partitioningBy(Predicate predicate, Collector downstream) { - @SuppressWarnings("unchecked") - BiConsumer downstreamAccumulator = (BiConsumer) downstream.accumulator(); - BiConsumer, T> accumulator = (result, t) -> { - Partition asPartition = ((Partition) result); - downstreamAccumulator.accept(predicate.test(t) ? asPartition.forTrue : asPartition.forFalse, t); - }; + BiConsumer downstreamAccumulator = downstream.accumulator(); + BiConsumer, T> accumulator = (result, t) -> + downstreamAccumulator.accept(predicate.test(t) ? result.forTrue : result.forFalse, t); BinaryOperator op = downstream.combiner(); - BinaryOperator> merger = (m1, m2) -> { - Partition left = (Partition) m1; - Partition right = (Partition) m2; - return new Partition<>(op.apply(left.forTrue, right.forTrue), - op.apply(left.forFalse, right.forFalse)); - }; - Supplier> supplier = () -> new Partition<>(downstream.supplier().get(), - downstream.supplier().get()); + BinaryOperator> merger = (left, right) -> + new Partition<>(op.apply(left.forTrue, right.forTrue), + op.apply(left.forFalse, right.forFalse)); + Supplier> supplier = () -> + new Partition<>(downstream.supplier().get(), + downstream.supplier().get()); if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { return new CollectorImpl<>(supplier, accumulator, merger, CH_ID); } else { - Function, Map> finisher = (Map par) -> { - Partition asAPartition = (Partition) par; - return new Partition<>(downstream.finisher().apply(asAPartition.forTrue), - downstream.finisher().apply(asAPartition.forFalse)); - }; + Function, Map> finisher = par -> + new Partition<>(downstream.finisher().apply(par.forTrue), + downstream.finisher().apply(par.forFalse)); return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID); } } diff --git a/jdk/src/share/classes/java/util/stream/DistinctOps.java b/jdk/src/share/classes/java/util/stream/DistinctOps.java index 69d231f88f5..1c4dfee5d67 100644 --- a/jdk/src/share/classes/java/util/stream/DistinctOps.java +++ b/jdk/src/share/classes/java/util/stream/DistinctOps.java @@ -101,7 +101,7 @@ final class DistinctOps { if (StreamOpFlag.DISTINCT.isKnown(flags)) { return sink; } else if (StreamOpFlag.SORTED.isKnown(flags)) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { boolean seenNull; T lastSeen; @@ -132,7 +132,7 @@ final class DistinctOps { } }; } else { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { Set seen; @Override diff --git a/jdk/src/share/classes/java/util/stream/DoublePipeline.java b/jdk/src/share/classes/java/util/stream/DoublePipeline.java index 44c8ff0f5e7..f894fa0abb9 100644 --- a/jdk/src/share/classes/java/util/stream/DoublePipeline.java +++ b/jdk/src/share/classes/java/util/stream/DoublePipeline.java @@ -191,7 +191,7 @@ abstract class DoublePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsDouble(t)); @@ -208,9 +208,8 @@ abstract class DoublePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override - @SuppressWarnings("unchecked") public void accept(double t) { downstream.accept(mapper.apply(t)); } @@ -226,7 +225,7 @@ abstract class DoublePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsInt(t)); @@ -243,7 +242,7 @@ abstract class DoublePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override public void accept(double t) { downstream.accept(mapper.applyAsLong(t)); @@ -259,7 +258,7 @@ abstract class DoublePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override public void begin(long size) { downstream.begin(-1); @@ -296,7 +295,7 @@ abstract class DoublePipeline StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override public void begin(long size) { downstream.begin(-1); @@ -319,7 +318,7 @@ abstract class DoublePipeline 0) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { @Override public void accept(double t) { consumer.accept(t); diff --git a/jdk/src/share/classes/java/util/stream/IntPipeline.java b/jdk/src/share/classes/java/util/stream/IntPipeline.java index d380e4a3bf5..f7dc79317d3 100644 --- a/jdk/src/share/classes/java/util/stream/IntPipeline.java +++ b/jdk/src/share/classes/java/util/stream/IntPipeline.java @@ -189,9 +189,8 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override - @SuppressWarnings("unchecked") public void accept(int t) { downstream.accept((long) t); } @@ -206,9 +205,8 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override - @SuppressWarnings("unchecked") public void accept(int t) { downstream.accept((double) t); } @@ -229,7 +227,7 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsInt(t)); @@ -246,9 +244,8 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override - @SuppressWarnings("unchecked") public void accept(int t) { downstream.accept(mapper.apply(t)); } @@ -264,7 +261,7 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsLong(t)); @@ -281,7 +278,7 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override public void accept(int t) { downstream.accept(mapper.applyAsDouble(t)); @@ -297,7 +294,7 @@ abstract class IntPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override public void begin(long size) { downstream.begin(-1); @@ -334,7 +331,7 @@ abstract class IntPipeline StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override public void begin(long size) { downstream.begin(-1); @@ -357,7 +354,7 @@ abstract class IntPipeline 0) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { @Override public void accept(int t) { consumer.accept(t); diff --git a/jdk/src/share/classes/java/util/stream/LongPipeline.java b/jdk/src/share/classes/java/util/stream/LongPipeline.java index 083f7bb8b2b..3c199feab59 100644 --- a/jdk/src/share/classes/java/util/stream/LongPipeline.java +++ b/jdk/src/share/classes/java/util/stream/LongPipeline.java @@ -186,7 +186,7 @@ abstract class LongPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override public void accept(long t) { downstream.accept((double) t); @@ -208,9 +208,8 @@ abstract class LongPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override - @SuppressWarnings("unchecked") public void accept(long t) { downstream.accept(mapper.applyAsLong(t)); } @@ -226,9 +225,8 @@ abstract class LongPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override - @SuppressWarnings("unchecked") public void accept(long t) { downstream.accept(mapper.apply(t)); } @@ -244,9 +242,8 @@ abstract class LongPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override - @SuppressWarnings("unchecked") public void accept(long t) { downstream.accept(mapper.applyAsInt(t)); } @@ -262,7 +259,7 @@ abstract class LongPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override public void accept(long t) { downstream.accept(mapper.applyAsDouble(t)); @@ -278,7 +275,7 @@ abstract class LongPipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override public void begin(long size) { downstream.begin(-1); @@ -315,7 +312,7 @@ abstract class LongPipeline StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override public void begin(long size) { downstream.begin(-1); @@ -338,7 +335,7 @@ abstract class LongPipeline 0) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { @Override public void accept(long t) { consumer.accept(t); diff --git a/jdk/src/share/classes/java/util/stream/ReferencePipeline.java b/jdk/src/share/classes/java/util/stream/ReferencePipeline.java index c201950d88c..1fffff48b18 100644 --- a/jdk/src/share/classes/java/util/stream/ReferencePipeline.java +++ b/jdk/src/share/classes/java/util/stream/ReferencePipeline.java @@ -163,17 +163,16 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override - @SuppressWarnings("unchecked") public void accept(P_OUT u) { if (predicate.test(u)) - downstream.accept((Object) u); + downstream.accept(u); } }; } @@ -188,7 +187,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override public void accept(P_OUT u) { downstream.accept(mapper.apply(u)); @@ -205,7 +204,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override public void accept(P_OUT u) { downstream.accept(mapper.applyAsInt(u)); @@ -222,7 +221,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override public void accept(P_OUT u) { downstream.accept(mapper.applyAsLong(u)); @@ -239,7 +238,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override public void accept(P_OUT u) { downstream.accept(mapper.applyAsDouble(u)); @@ -257,14 +256,13 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override public void begin(long size) { downstream.begin(-1); } @Override - @SuppressWarnings("unchecked") public void accept(P_OUT u) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it Stream result = mapper.apply(u); @@ -284,7 +282,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { IntConsumer downstreamAsInt = downstream::accept; @Override public void begin(long size) { @@ -311,7 +309,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { DoubleConsumer downstreamAsDouble = downstream::accept; @Override public void begin(long size) { @@ -338,7 +336,7 @@ abstract class ReferencePipeline StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { LongConsumer downstreamAsLong = downstream::accept; @Override public void begin(long size) { @@ -364,9 +362,8 @@ abstract class ReferencePipeline 0) { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { @Override - @SuppressWarnings("unchecked") public void accept(P_OUT u) { tee.accept(u); downstream.accept(u); @@ -495,6 +492,7 @@ abstract class ReferencePipeline } @Override + @SuppressWarnings("unchecked") public final R collect(Collector collector) { A container; if (isParallel() diff --git a/jdk/src/share/classes/java/util/stream/Sink.java b/jdk/src/share/classes/java/util/stream/Sink.java index 987d0e9efa7..d2a366df16e 100644 --- a/jdk/src/share/classes/java/util/stream/Sink.java +++ b/jdk/src/share/classes/java/util/stream/Sink.java @@ -241,11 +241,10 @@ interface Sink extends Consumer { * implementation of the {@code accept()} method must call the correct * {@code accept()} method on the downstream {@code Sink}. */ - static abstract class ChainedReference implements Sink { - @SuppressWarnings("rawtypes") - protected final Sink downstream; + static abstract class ChainedReference implements Sink { + protected final Sink downstream; - public ChainedReference(Sink downstream) { + public ChainedReference(Sink downstream) { this.downstream = Objects.requireNonNull(downstream); } @@ -274,11 +273,10 @@ interface Sink extends Consumer { * The implementation of the {@code accept()} method must call the correct * {@code accept()} method on the downstream {@code Sink}. */ - static abstract class ChainedInt implements Sink.OfInt { - @SuppressWarnings("rawtypes") - protected final Sink downstream; + static abstract class ChainedInt implements Sink.OfInt { + protected final Sink downstream; - public ChainedInt(Sink downstream) { + public ChainedInt(Sink downstream) { this.downstream = Objects.requireNonNull(downstream); } @@ -307,11 +305,10 @@ interface Sink extends Consumer { * The implementation of the {@code accept()} method must call the correct * {@code accept()} method on the downstream {@code Sink}. */ - static abstract class ChainedLong implements Sink.OfLong { - @SuppressWarnings("rawtypes") - protected final Sink downstream; + static abstract class ChainedLong implements Sink.OfLong { + protected final Sink downstream; - public ChainedLong(Sink downstream) { + public ChainedLong(Sink downstream) { this.downstream = Objects.requireNonNull(downstream); } @@ -340,11 +337,10 @@ interface Sink extends Consumer { * The implementation of the {@code accept()} method must call the correct * {@code accept()} method on the downstream {@code Sink}. */ - static abstract class ChainedDouble implements Sink.OfDouble { - @SuppressWarnings("rawtypes") - protected final Sink downstream; + static abstract class ChainedDouble implements Sink.OfDouble { + protected final Sink downstream; - public ChainedDouble(Sink downstream) { + public ChainedDouble(Sink downstream) { this.downstream = Objects.requireNonNull(downstream); } diff --git a/jdk/src/share/classes/java/util/stream/SliceOps.java b/jdk/src/share/classes/java/util/stream/SliceOps.java index 09e14f637f4..34d55309d2d 100644 --- a/jdk/src/share/classes/java/util/stream/SliceOps.java +++ b/jdk/src/share/classes/java/util/stream/SliceOps.java @@ -96,6 +96,11 @@ final class SliceOps { } } + @SuppressWarnings("unchecked") + private static IntFunction castingArray() { + return size -> (T[]) new Object[size]; + } + /** * Appends a "slice" operation to the provided stream. The slice operation * may be may be skip-only, limit-only, or skip-and-limit. @@ -107,12 +112,12 @@ final class SliceOps { * is to be imposed */ public static Stream makeRef(AbstractPipeline upstream, - long skip, long limit) { + long skip, long limit) { if (skip < 0) throw new IllegalArgumentException("Skip must be non-negative: " + skip); - return new ReferencePipeline.StatefulOp(upstream, StreamShape.REFERENCE, - flags(limit)) { + return new ReferencePipeline.StatefulOp(upstream, StreamShape.REFERENCE, + flags(limit)) { Spliterator unorderedSkipLimitSpliterator(Spliterator s, long skip, long limit, long sizeIfKnown) { if (skip <= sizeIfKnown) { @@ -146,7 +151,7 @@ final class SliceOps { // cancellation will be more aggressive cancelling later tasks // if the target slice size has been reached from a given task, // cancellation should also clear local results if any - return new SliceTask<>(this, helper, spliterator, i -> (T[]) new Object[i], skip, limit). + return new SliceTask<>(this, helper, spliterator, castingArray(), skip, limit). invoke().spliterator(); } } @@ -182,7 +187,7 @@ final class SliceOps { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedReference(sink) { + return new Sink.ChainedReference(sink) { long n = skip; long m = limit >= 0 ? limit : Long.MAX_VALUE; @@ -291,7 +296,7 @@ final class SliceOps { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedInt(sink) { + return new Sink.ChainedInt(sink) { long n = skip; long m = limit >= 0 ? limit : Long.MAX_VALUE; @@ -400,7 +405,7 @@ final class SliceOps { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedLong(sink) { + return new Sink.ChainedLong(sink) { long n = skip; long m = limit >= 0 ? limit : Long.MAX_VALUE; @@ -509,7 +514,7 @@ final class SliceOps { @Override Sink opWrapSink(int flags, Sink sink) { - return new Sink.ChainedDouble(sink) { + return new Sink.ChainedDouble(sink) { long n = skip; long m = limit >= 0 ? limit : Long.MAX_VALUE; @@ -560,13 +565,13 @@ final class SliceOps { private volatile boolean completed; - SliceTask(AbstractPipeline op, + SliceTask(AbstractPipeline op, PipelineHelper helper, Spliterator spliterator, IntFunction generator, long offset, long size) { super(helper, spliterator); - this.op = (AbstractPipeline) op; + this.op = op; this.generator = generator; this.targetOffset = offset; this.targetSize = size; diff --git a/jdk/src/share/classes/java/util/stream/SortedOps.java b/jdk/src/share/classes/java/util/stream/SortedOps.java index 047479a645d..9df65e352e2 100644 --- a/jdk/src/share/classes/java/util/stream/SortedOps.java +++ b/jdk/src/share/classes/java/util/stream/SortedOps.java @@ -129,7 +129,7 @@ final class SortedOps { } @Override - public Sink opWrapSink(int flags, Sink sink) { + public Sink opWrapSink(int flags, Sink sink) { Objects.requireNonNull(sink); // If the input is already naturally sorted and this operation @@ -280,12 +280,12 @@ final class SortedOps { /** * {@link ForkJoinTask} for implementing sort on SIZED reference streams. */ - private static final class SizedRefSortingSink extends Sink.ChainedReference { + private static final class SizedRefSortingSink extends Sink.ChainedReference { private final Comparator comparator; private T[] array; private int offset; - SizedRefSortingSink(Sink sink, Comparator comparator) { + SizedRefSortingSink(Sink sink, Comparator comparator) { super(sink); this.comparator = comparator; } @@ -320,11 +320,11 @@ final class SortedOps { /** * {@link Sink} for implementing sort on reference streams. */ - private static final class RefSortingSink extends Sink.ChainedReference { + private static final class RefSortingSink extends Sink.ChainedReference { private final Comparator comparator; private ArrayList list; - RefSortingSink(Sink sink, Comparator comparator) { + RefSortingSink(Sink sink, Comparator comparator) { super(sink); this.comparator = comparator; } @@ -352,11 +352,11 @@ final class SortedOps { /** * {@link Sink} for implementing sort on SIZED int streams. */ - private static final class SizedIntSortingSink extends Sink.ChainedInt { + private static final class SizedIntSortingSink extends Sink.ChainedInt { private int[] array; private int offset; - SizedIntSortingSink(Sink downstream) { + SizedIntSortingSink(Sink downstream) { super(downstream); } @@ -386,10 +386,10 @@ final class SortedOps { /** * {@link Sink} for implementing sort on int streams. */ - private static final class IntSortingSink extends Sink.ChainedInt { + private static final class IntSortingSink extends Sink.ChainedInt { private SpinedBuffer.OfInt b; - IntSortingSink(Sink sink) { + IntSortingSink(Sink sink) { super(sink); } @@ -417,11 +417,11 @@ final class SortedOps { /** * {@link Sink} for implementing sort on SIZED long streams. */ - private static final class SizedLongSortingSink extends Sink.ChainedLong { + private static final class SizedLongSortingSink extends Sink.ChainedLong { private long[] array; private int offset; - SizedLongSortingSink(Sink downstream) { + SizedLongSortingSink(Sink downstream) { super(downstream); } @@ -451,10 +451,10 @@ final class SortedOps { /** * {@link Sink} for implementing sort on long streams. */ - private static final class LongSortingSink extends Sink.ChainedLong { + private static final class LongSortingSink extends Sink.ChainedLong { private SpinedBuffer.OfLong b; - LongSortingSink(Sink sink) { + LongSortingSink(Sink sink) { super(sink); } @@ -482,11 +482,11 @@ final class SortedOps { /** * {@link Sink} for implementing sort on SIZED double streams. */ - private static final class SizedDoubleSortingSink extends Sink.ChainedDouble { + private static final class SizedDoubleSortingSink extends Sink.ChainedDouble { private double[] array; private int offset; - SizedDoubleSortingSink(Sink downstream) { + SizedDoubleSortingSink(Sink downstream) { super(downstream); } @@ -516,10 +516,10 @@ final class SortedOps { /** * {@link Sink} for implementing sort on double streams. */ - private static final class DoubleSortingSink extends Sink.ChainedDouble { + private static final class DoubleSortingSink extends Sink.ChainedDouble { private SpinedBuffer.OfDouble b; - DoubleSortingSink(Sink sink) { + DoubleSortingSink(Sink sink) { super(sink); } From 7ade7987a0a8ccfde017811623d338b4c4b80237 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 16 Aug 2013 13:22:32 +0200 Subject: [PATCH 003/117] 8007074: SIGSEGV at ParMarkBitMap::verify_clear() Replace the broken large pages implementation on Linux. New flag: -XX:+UseTransparentHugePages - Linux specific flag to turn on transparent huge page hinting with madvise(..., MAP_HUGETLB). Changed behavior: -XX:+UseLargePages - tries to use -XX:+UseTransparentHugePages before trying other large pages implementations (on Linux). Changed behavior: -XX:+UseHugeTLBFS - Use upfront allocation of Large Pages instead of using the broken implementation to dynamically committing large pages. Changed behavior: -XX:LargePageSizeInBytes - Turned off the ability to use this flag on Linux and provides warning to user if set to a value different than the OS chosen large page size. Changed behavior: Setting no large page size - Now defaults to use -XX:UseTransparentHugePages if the OS supports it. Previously, -XX:+UseHugeTLBFS was chosen if the OS was configured to use large pages. Reviewed-by: tschatzl, dcubed, brutisso --- hotspot/src/os/bsd/vm/os_bsd.cpp | 9 +- hotspot/src/os/linux/vm/globals_linux.hpp | 3 + hotspot/src/os/linux/vm/os_linux.cpp | 586 ++++++++++++++---- hotspot/src/os/linux/vm/os_linux.hpp | 14 + hotspot/src/os/solaris/vm/os_solaris.cpp | 8 +- hotspot/src/os/windows/vm/os_windows.cpp | 13 +- .../gc_implementation/g1/g1CollectedHeap.cpp | 8 +- .../g1/g1CollectorPolicy.cpp | 3 +- .../src/share/vm/memory/collectorPolicy.cpp | 2 + .../src/share/vm/memory/genCollectedHeap.cpp | 29 +- hotspot/src/share/vm/memory/metaspace.cpp | 2 +- hotspot/src/share/vm/memory/universe.cpp | 32 +- hotspot/src/share/vm/memory/universe.hpp | 2 +- hotspot/src/share/vm/prims/jni.cpp | 6 + hotspot/src/share/vm/runtime/globals.hpp | 3 + hotspot/src/share/vm/runtime/os.hpp | 4 +- hotspot/src/share/vm/runtime/virtualspace.cpp | 205 +++++- hotspot/src/share/vm/runtime/virtualspace.hpp | 1 + hotspot/src/share/vm/services/memTracker.hpp | 9 + .../share/vm/utilities/globalDefinitions.hpp | 16 + 20 files changed, 796 insertions(+), 159 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 1db3739fa84..6b636d379de 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -2325,7 +2325,9 @@ void os::large_page_init() { } -char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) { +char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) { + fatal("This code is not used or maintained."); + // "exec" is passed in but not used. Creating the shared image for // the code cache doesn't have an SHM_X executable permission to check. assert(UseLargePages && UseSHM, "only for SHM large pages"); @@ -4752,3 +4754,8 @@ int os::get_core_path(char* buffer, size_t bufferSize) { return n; } +#ifndef PRODUCT +void TestReserveMemorySpecial_test() { + // No tests available for this platform +} +#endif diff --git a/hotspot/src/os/linux/vm/globals_linux.hpp b/hotspot/src/os/linux/vm/globals_linux.hpp index af4947b1b86..4dfccc3f6ee 100644 --- a/hotspot/src/os/linux/vm/globals_linux.hpp +++ b/hotspot/src/os/linux/vm/globals_linux.hpp @@ -40,6 +40,9 @@ product(bool, UseHugeTLBFS, false, \ "Use MAP_HUGETLB for large pages") \ \ + product(bool, UseTransparentHugePages, false, \ + "Use MADV_HUGEPAGE for large pages") \ + \ product(bool, LoadExecStackDllInVMThread, true, \ "Load DLLs with executable-stack attribute in the VM Thread") \ \ diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index df58be635d1..23d3457046d 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -2720,36 +2720,7 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec, int os::Linux::commit_memory_impl(char* addr, size_t size, size_t alignment_hint, bool exec) { - int err; - if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) { - int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; - uintptr_t res = - (uintptr_t) ::mmap(addr, size, prot, - MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB, - -1, 0); - if (res != (uintptr_t) MAP_FAILED) { - if (UseNUMAInterleaving) { - numa_make_global(addr, size); - } - return 0; - } - - err = errno; // save errno from mmap() call above - - if (!recoverable_mmap_error(err)) { - // However, it is not clear that this loss of our reserved mapping - // happens with large pages on Linux or that we cannot recover - // from the loss. For now, we just issue a warning and we don't - // call vm_exit_out_of_memory(). This issue is being tracked by - // JBS-8007074. - warn_fail_commit_memory(addr, size, alignment_hint, exec, err); -// vm_exit_out_of_memory(size, OOM_MMAP_ERROR, -// "committing reserved memory."); - } - // Fall through and try to use small pages - } - - err = os::Linux::commit_memory_impl(addr, size, exec); + int err = os::Linux::commit_memory_impl(addr, size, exec); if (err == 0) { realign_memory(addr, size, alignment_hint); } @@ -2774,7 +2745,7 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size, } void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) { - if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) { + if (UseTransparentHugePages && alignment_hint > (size_t)vm_page_size()) { // We don't check the return value: madvise(MADV_HUGEPAGE) may not // be supported or the memory may already be backed by huge pages. ::madvise(addr, bytes, MADV_HUGEPAGE); @@ -2787,7 +2758,7 @@ void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { // uncommitted at all. We don't do anything in this case to avoid creating a segment with // small pages on top of the SHM segment. This method always works for small pages, so we // allow that in any case. - if (alignment_hint <= (size_t)os::vm_page_size() || !UseSHM) { + if (alignment_hint <= (size_t)os::vm_page_size() || can_commit_large_page_memory()) { commit_memory(addr, bytes, alignment_hint, !ExecMem); } } @@ -3157,11 +3128,31 @@ bool os::unguard_memory(char* addr, size_t size) { return linux_mprotect(addr, size, PROT_READ|PROT_WRITE); } +bool os::Linux::transparent_huge_pages_sanity_check(bool warn, size_t page_size) { + bool result = false; + void *p = mmap(NULL, page_size * 2, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, + -1, 0); + if (p != MAP_FAILED) { + void *aligned_p = align_ptr_up(p, page_size); + + result = madvise(aligned_p, page_size, MADV_HUGEPAGE) == 0; + + munmap(p, page_size * 2); + } + + if (warn && !result) { + warning("TransparentHugePages is not supported by the operating system."); + } + + return result; +} + bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) { bool result = false; - void *p = mmap (NULL, page_size, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB, - -1, 0); + void *p = mmap(NULL, page_size, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB, + -1, 0); if (p != MAP_FAILED) { // We don't know if this really is a huge page or not. @@ -3182,12 +3173,10 @@ bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) { } fclose(fp); } - munmap (p, page_size); - if (result) - return true; + munmap(p, page_size); } - if (warn) { + if (warn && !result) { warning("HugeTLBFS is not supported by the operating system."); } @@ -3235,82 +3224,114 @@ static void set_coredump_filter(void) { static size_t _large_page_size = 0; -void os::large_page_init() { - if (!UseLargePages) { - UseHugeTLBFS = false; - UseSHM = false; - return; - } +size_t os::Linux::find_large_page_size() { + size_t large_page_size = 0; - if (FLAG_IS_DEFAULT(UseHugeTLBFS) && FLAG_IS_DEFAULT(UseSHM)) { - // If UseLargePages is specified on the command line try both methods, - // if it's default, then try only HugeTLBFS. - if (FLAG_IS_DEFAULT(UseLargePages)) { - UseHugeTLBFS = true; - } else { - UseHugeTLBFS = UseSHM = true; - } - } - - if (LargePageSizeInBytes) { - _large_page_size = LargePageSizeInBytes; - } else { - // large_page_size on Linux is used to round up heap size. x86 uses either - // 2M or 4M page, depending on whether PAE (Physical Address Extensions) - // mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use - // page as large as 256M. - // - // Here we try to figure out page size by parsing /proc/meminfo and looking - // for a line with the following format: - // Hugepagesize: 2048 kB - // - // If we can't determine the value (e.g. /proc is not mounted, or the text - // format has been changed), we'll use the largest page size supported by - // the processor. + // large_page_size on Linux is used to round up heap size. x86 uses either + // 2M or 4M page, depending on whether PAE (Physical Address Extensions) + // mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use + // page as large as 256M. + // + // Here we try to figure out page size by parsing /proc/meminfo and looking + // for a line with the following format: + // Hugepagesize: 2048 kB + // + // If we can't determine the value (e.g. /proc is not mounted, or the text + // format has been changed), we'll use the largest page size supported by + // the processor. #ifndef ZERO - _large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M) - ARM_ONLY(2 * M) PPC_ONLY(4 * M); + large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M) + ARM_ONLY(2 * M) PPC_ONLY(4 * M); #endif // ZERO - FILE *fp = fopen("/proc/meminfo", "r"); - if (fp) { - while (!feof(fp)) { - int x = 0; - char buf[16]; - if (fscanf(fp, "Hugepagesize: %d", &x) == 1) { - if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) { - _large_page_size = x * K; - break; - } - } else { - // skip to next line - for (;;) { - int ch = fgetc(fp); - if (ch == EOF || ch == (int)'\n') break; - } + FILE *fp = fopen("/proc/meminfo", "r"); + if (fp) { + while (!feof(fp)) { + int x = 0; + char buf[16]; + if (fscanf(fp, "Hugepagesize: %d", &x) == 1) { + if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) { + large_page_size = x * K; + break; + } + } else { + // skip to next line + for (;;) { + int ch = fgetc(fp); + if (ch == EOF || ch == (int)'\n') break; } } - fclose(fp); } + fclose(fp); } - // print a warning if any large page related flag is specified on command line - bool warn_on_failure = !FLAG_IS_DEFAULT(UseHugeTLBFS); + if (!FLAG_IS_DEFAULT(LargePageSizeInBytes) && LargePageSizeInBytes != large_page_size) { + warning("Setting LargePageSizeInBytes has no effect on this OS. Large page size is " + SIZE_FORMAT "%s.", byte_size_in_proper_unit(large_page_size), + proper_unit_for_byte_size(large_page_size)); + } + return large_page_size; +} + +size_t os::Linux::setup_large_page_size() { + _large_page_size = Linux::find_large_page_size(); const size_t default_page_size = (size_t)Linux::page_size(); if (_large_page_size > default_page_size) { _page_sizes[0] = _large_page_size; _page_sizes[1] = default_page_size; _page_sizes[2] = 0; } - UseHugeTLBFS = UseHugeTLBFS && - Linux::hugetlbfs_sanity_check(warn_on_failure, _large_page_size); - if (UseHugeTLBFS) + return _large_page_size; +} + +bool os::Linux::setup_large_page_type(size_t page_size) { + if (FLAG_IS_DEFAULT(UseHugeTLBFS) && + FLAG_IS_DEFAULT(UseSHM) && + FLAG_IS_DEFAULT(UseTransparentHugePages)) { + // If UseLargePages is specified on the command line try all methods, + // if it's default, then try only UseTransparentHugePages. + if (FLAG_IS_DEFAULT(UseLargePages)) { + UseTransparentHugePages = true; + } else { + UseHugeTLBFS = UseTransparentHugePages = UseSHM = true; + } + } + + if (UseTransparentHugePages) { + bool warn_on_failure = !FLAG_IS_DEFAULT(UseTransparentHugePages); + if (transparent_huge_pages_sanity_check(warn_on_failure, page_size)) { + UseHugeTLBFS = false; + UseSHM = false; + return true; + } + UseTransparentHugePages = false; + } + + if (UseHugeTLBFS) { + bool warn_on_failure = !FLAG_IS_DEFAULT(UseHugeTLBFS); + if (hugetlbfs_sanity_check(warn_on_failure, page_size)) { + UseSHM = false; + return true; + } + UseHugeTLBFS = false; + } + + return UseSHM; +} + +void os::large_page_init() { + if (!UseLargePages) { + UseHugeTLBFS = false; + UseTransparentHugePages = false; UseSHM = false; + return; + } - UseLargePages = UseHugeTLBFS || UseSHM; + size_t large_page_size = Linux::setup_large_page_size(); + UseLargePages = Linux::setup_large_page_type(large_page_size); set_coredump_filter(); } @@ -3319,16 +3340,22 @@ void os::large_page_init() { #define SHM_HUGETLB 04000 #endif -char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) { +char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec) { // "exec" is passed in but not used. Creating the shared image for // the code cache doesn't have an SHM_X executable permission to check. assert(UseLargePages && UseSHM, "only for SHM large pages"); + assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address"); + + if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) { + return NULL; // Fallback to small pages. + } key_t key = IPC_PRIVATE; char *addr; bool warn_on_failure = UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || + !FLAG_IS_DEFAULT(UseSHM) || !FLAG_IS_DEFAULT(LargePageSizeInBytes) ); char msg[128]; @@ -3376,42 +3403,219 @@ char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) { return NULL; } - if ((addr != NULL) && UseNUMAInterleaving) { - numa_make_global(addr, bytes); + return addr; +} + +static void warn_on_large_pages_failure(char* req_addr, size_t bytes, int error) { + assert(error == ENOMEM, "Only expect to fail if no memory is available"); + + bool warn_on_failure = UseLargePages && + (!FLAG_IS_DEFAULT(UseLargePages) || + !FLAG_IS_DEFAULT(UseHugeTLBFS) || + !FLAG_IS_DEFAULT(LargePageSizeInBytes)); + + if (warn_on_failure) { + char msg[128]; + jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: " + PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error); + warning(msg); + } +} + +char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec) { + assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages"); + assert(is_size_aligned(bytes, os::large_page_size()), "Unaligned size"); + assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address"); + + int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; + char* addr = (char*)::mmap(req_addr, bytes, prot, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_HUGETLB, + -1, 0); + + if (addr == MAP_FAILED) { + warn_on_large_pages_failure(req_addr, bytes, errno); + return NULL; } - // The memory is committed - MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, mtNone, CALLER_PC); + assert(is_ptr_aligned(addr, os::large_page_size()), "Must be"); return addr; } +char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec) { + size_t large_page_size = os::large_page_size(); + + assert(bytes >= large_page_size, "Shouldn't allocate large pages for small sizes"); + + // Allocate small pages. + + char* start; + if (req_addr != NULL) { + assert(is_ptr_aligned(req_addr, alignment), "Must be"); + assert(is_size_aligned(bytes, alignment), "Must be"); + start = os::reserve_memory(bytes, req_addr); + assert(start == NULL || start == req_addr, "Must be"); + } else { + start = os::reserve_memory_aligned(bytes, alignment); + } + + if (start == NULL) { + return NULL; + } + + assert(is_ptr_aligned(start, alignment), "Must be"); + + // os::reserve_memory_special will record this memory area. + // Need to release it here to prevent overlapping reservations. + MemTracker::record_virtual_memory_release((address)start, bytes); + + char* end = start + bytes; + + // Find the regions of the allocated chunk that can be promoted to large pages. + char* lp_start = (char*)align_ptr_up(start, large_page_size); + char* lp_end = (char*)align_ptr_down(end, large_page_size); + + size_t lp_bytes = lp_end - lp_start; + + assert(is_size_aligned(lp_bytes, large_page_size), "Must be"); + + if (lp_bytes == 0) { + // The mapped region doesn't even span the start and the end of a large page. + // Fall back to allocate a non-special area. + ::munmap(start, end - start); + return NULL; + } + + int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; + + + void* result; + + if (start != lp_start) { + result = ::mmap(start, lp_start - start, prot, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, + -1, 0); + if (result == MAP_FAILED) { + ::munmap(lp_start, end - lp_start); + return NULL; + } + } + + result = ::mmap(lp_start, lp_bytes, prot, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED|MAP_HUGETLB, + -1, 0); + if (result == MAP_FAILED) { + warn_on_large_pages_failure(req_addr, bytes, errno); + // If the mmap above fails, the large pages region will be unmapped and we + // have regions before and after with small pages. Release these regions. + // + // | mapped | unmapped | mapped | + // ^ ^ ^ ^ + // start lp_start lp_end end + // + ::munmap(start, lp_start - start); + ::munmap(lp_end, end - lp_end); + return NULL; + } + + if (lp_end != end) { + result = ::mmap(lp_end, end - lp_end, prot, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, + -1, 0); + if (result == MAP_FAILED) { + ::munmap(start, lp_end - start); + return NULL; + } + } + + return start; +} + +char* os::Linux::reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec) { + assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages"); + assert(is_ptr_aligned(req_addr, alignment), "Must be"); + assert(is_power_of_2(alignment), "Must be"); + assert(is_power_of_2(os::large_page_size()), "Must be"); + assert(bytes >= os::large_page_size(), "Shouldn't allocate large pages for small sizes"); + + if (is_size_aligned(bytes, os::large_page_size()) && alignment <= os::large_page_size()) { + return reserve_memory_special_huge_tlbfs_only(bytes, req_addr, exec); + } else { + return reserve_memory_special_huge_tlbfs_mixed(bytes, alignment, req_addr, exec); + } +} + +char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) { + assert(UseLargePages, "only for large pages"); + + char* addr; + if (UseSHM) { + addr = os::Linux::reserve_memory_special_shm(bytes, alignment, req_addr, exec); + } else { + assert(UseHugeTLBFS, "must be"); + addr = os::Linux::reserve_memory_special_huge_tlbfs(bytes, alignment, req_addr, exec); + } + + if (addr != NULL) { + if (UseNUMAInterleaving) { + numa_make_global(addr, bytes); + } + + // The memory is committed + MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, mtNone, CALLER_PC); + } + + return addr; +} + +bool os::Linux::release_memory_special_shm(char* base, size_t bytes) { + // detaching the SHM segment will also delete it, see reserve_memory_special_shm() + return shmdt(base) == 0; +} + +bool os::Linux::release_memory_special_huge_tlbfs(char* base, size_t bytes) { + return pd_release_memory(base, bytes); +} + bool os::release_memory_special(char* base, size_t bytes) { + assert(UseLargePages, "only for large pages"); + MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - // detaching the SHM segment will also delete it, see reserve_memory_special() - int rslt = shmdt(base); - if (rslt == 0) { + + bool res; + if (UseSHM) { + res = os::Linux::release_memory_special_shm(base, bytes); + } else { + assert(UseHugeTLBFS, "must be"); + res = os::Linux::release_memory_special_huge_tlbfs(base, bytes); + } + + if (res) { tkr.record((address)base, bytes); - return true; } else { tkr.discard(); - return false; } + + return res; } size_t os::large_page_size() { return _large_page_size; } -// HugeTLBFS allows application to commit large page memory on demand; -// with SysV SHM the entire memory region must be allocated as shared +// With SysV SHM the entire memory region must be allocated as shared // memory. +// HugeTLBFS allows application to commit large page memory on demand. +// However, when committing memory with HugeTLBFS fails, the region +// that was supposed to be committed will lose the old reservation +// and allow other threads to steal that memory region. Because of this +// behavior we can't commit HugeTLBFS memory. bool os::can_commit_large_page_memory() { - return UseHugeTLBFS; + return UseTransparentHugePages; } bool os::can_execute_large_page_memory() { - return UseHugeTLBFS; + return UseTransparentHugePages || UseHugeTLBFS; } // Reserve memory at an arbitrary address, only if that area is @@ -4563,21 +4767,23 @@ jint os::init_2(void) UseNUMA = false; } } - // With SHM large pages we cannot uncommit a page, so there's not way + // With SHM and HugeTLBFS large pages we cannot uncommit a page, so there's no way // we can make the adaptive lgrp chunk resizing work. If the user specified - // both UseNUMA and UseLargePages (or UseSHM) on the command line - warn and + // both UseNUMA and UseLargePages (or UseSHM/UseHugeTLBFS) on the command line - warn and // disable adaptive resizing. - if (UseNUMA && UseLargePages && UseSHM) { - if (!FLAG_IS_DEFAULT(UseNUMA)) { - if (FLAG_IS_DEFAULT(UseLargePages) && FLAG_IS_DEFAULT(UseSHM)) { + if (UseNUMA && UseLargePages && !can_commit_large_page_memory()) { + if (FLAG_IS_DEFAULT(UseNUMA)) { + UseNUMA = false; + } else { + if (FLAG_IS_DEFAULT(UseLargePages) && + FLAG_IS_DEFAULT(UseSHM) && + FLAG_IS_DEFAULT(UseHugeTLBFS)) { UseLargePages = false; } else { - warning("UseNUMA is not fully compatible with SHM large pages, disabling adaptive resizing"); + warning("UseNUMA is not fully compatible with SHM/HugeTLBFS large pages, disabling adaptive resizing"); UseAdaptiveSizePolicy = false; UseAdaptiveNUMAChunkSizing = false; } - } else { - UseNUMA = false; } } if (!UseNUMA && ForceNUMA) { @@ -5848,3 +6054,149 @@ void MemNotifyThread::start() { } #endif // JAVASE_EMBEDDED + + +/////////////// Unit tests /////////////// + +#ifndef PRODUCT + +#define test_log(...) \ + do {\ + if (VerboseInternalVMTests) { \ + tty->print_cr(__VA_ARGS__); \ + tty->flush(); \ + }\ + } while (false) + +class TestReserveMemorySpecial : AllStatic { + public: + static void small_page_write(void* addr, size_t size) { + size_t page_size = os::vm_page_size(); + + char* end = (char*)addr + size; + for (char* p = (char*)addr; p < end; p += page_size) { + *p = 1; + } + } + + static void test_reserve_memory_special_huge_tlbfs_only(size_t size) { + if (!UseHugeTLBFS) { + return; + } + + test_log("test_reserve_memory_special_huge_tlbfs_only(" SIZE_FORMAT ")", size); + + char* addr = os::Linux::reserve_memory_special_huge_tlbfs_only(size, NULL, false); + + if (addr != NULL) { + small_page_write(addr, size); + + os::Linux::release_memory_special_huge_tlbfs(addr, size); + } + } + + static void test_reserve_memory_special_huge_tlbfs_only() { + if (!UseHugeTLBFS) { + return; + } + + size_t lp = os::large_page_size(); + + for (size_t size = lp; size <= lp * 10; size += lp) { + test_reserve_memory_special_huge_tlbfs_only(size); + } + } + + static void test_reserve_memory_special_huge_tlbfs_mixed(size_t size, size_t alignment) { + if (!UseHugeTLBFS) { + return; + } + + test_log("test_reserve_memory_special_huge_tlbfs_mixed(" SIZE_FORMAT ", " SIZE_FORMAT ")", + size, alignment); + + assert(size >= os::large_page_size(), "Incorrect input to test"); + + char* addr = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, NULL, false); + + if (addr != NULL) { + small_page_write(addr, size); + + os::Linux::release_memory_special_huge_tlbfs(addr, size); + } + } + + static void test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(size_t size) { + size_t lp = os::large_page_size(); + size_t ag = os::vm_allocation_granularity(); + + for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { + test_reserve_memory_special_huge_tlbfs_mixed(size, alignment); + } + } + + static void test_reserve_memory_special_huge_tlbfs_mixed() { + size_t lp = os::large_page_size(); + size_t ag = os::vm_allocation_granularity(); + + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + ag); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + lp / 2); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + ag); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 - ag); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + lp / 2); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10); + test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10 + lp / 2); + } + + static void test_reserve_memory_special_huge_tlbfs() { + if (!UseHugeTLBFS) { + return; + } + + test_reserve_memory_special_huge_tlbfs_only(); + test_reserve_memory_special_huge_tlbfs_mixed(); + } + + static void test_reserve_memory_special_shm(size_t size, size_t alignment) { + if (!UseSHM) { + return; + } + + test_log("test_reserve_memory_special_shm(" SIZE_FORMAT ", " SIZE_FORMAT ")", size, alignment); + + char* addr = os::Linux::reserve_memory_special_shm(size, alignment, NULL, false); + + if (addr != NULL) { + assert(is_ptr_aligned(addr, alignment), "Check"); + assert(is_ptr_aligned(addr, os::large_page_size()), "Check"); + + small_page_write(addr, size); + + os::Linux::release_memory_special_shm(addr, size); + } + } + + static void test_reserve_memory_special_shm() { + size_t lp = os::large_page_size(); + size_t ag = os::vm_allocation_granularity(); + + for (size_t size = ag; size < lp * 3; size += ag) { + for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { + test_reserve_memory_special_shm(size, alignment); + } + } + } + + static void test() { + test_reserve_memory_special_huge_tlbfs(); + test_reserve_memory_special_shm(); + } +}; + +void TestReserveMemorySpecial_test() { + TestReserveMemorySpecial::test(); +} + +#endif diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 8c5032fc23b..5fa24499319 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -32,6 +32,7 @@ typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *); class Linux { friend class os; + friend class TestReserveMemorySpecial; // For signal-chaining #define MAXSIGNUM 32 @@ -92,8 +93,21 @@ class Linux { static void rebuild_cpu_to_node_map(); static GrowableArray* cpu_to_node() { return _cpu_to_node; } + static size_t find_large_page_size(); + static size_t setup_large_page_size(); + + static bool setup_large_page_type(size_t page_size); + static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size); static bool hugetlbfs_sanity_check(bool warn, size_t page_size); + static char* reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec); + static char* reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec); + static char* reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec); + static char* reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec); + + static bool release_memory_special_shm(char* base, size_t bytes); + static bool release_memory_special_huge_tlbfs(char* base, size_t bytes); + static void print_full_memory_info(outputStream* st); static void print_distro_info(outputStream* st); static void print_libversion_info(outputStream* st); diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 0a94cb536ab..c3e6e879077 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -3385,7 +3385,7 @@ bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) { return true; } -char* os::reserve_memory_special(size_t size, char* addr, bool exec) { +char* os::reserve_memory_special(size_t size, size_t alignment, char* addr, bool exec) { fatal("os::reserve_memory_special should not be called on Solaris."); return NULL; } @@ -6601,3 +6601,9 @@ int os::get_core_path(char* buffer, size_t bufferSize) { return strlen(buffer); } + +#ifndef PRODUCT +void TestReserveMemorySpecial_test() { + // No tests available for this platform +} +#endif diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 0674e6f3c83..64a593377c3 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3156,7 +3156,12 @@ bool os::can_execute_large_page_memory() { return true; } -char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) { +char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr, bool exec) { + assert(UseLargePages, "only for large pages"); + + if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) { + return NULL; // Fallback to small pages. + } const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; @@ -5638,3 +5643,9 @@ BOOL os::Advapi32Dll::AdvapiAvailable() { } #endif + +#ifndef PRODUCT +void TestReserveMemorySpecial_test() { + // No tests available for this platform +} +#endif diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 97a9a1fa54d..b163a464247 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -2006,10 +2006,12 @@ jint G1CollectedHeap::initialize() { size_t init_byte_size = collector_policy()->initial_heap_byte_size(); size_t max_byte_size = collector_policy()->max_heap_byte_size(); + size_t heap_alignment = collector_policy()->max_alignment(); // Ensure that the sizes are properly aligned. Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap"); Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap"); + Universe::check_alignment(max_byte_size, heap_alignment, "g1 heap"); _cg1r = new ConcurrentG1Refine(this); @@ -2026,12 +2028,8 @@ jint G1CollectedHeap::initialize() { // If this happens then we could end up using a non-optimal // compressed oops mode. - // Since max_byte_size is aligned to the size of a heap region (checked - // above). - Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap"); - ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size, - HeapRegion::GrainBytes); + heap_alignment); // It is important to do this in a way such that concurrent readers can't // temporarily think something is in the heap. (I've actually seen this diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp index 4c6d2bbf877..75497e7c37f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @@ -313,7 +313,8 @@ G1CollectorPolicy::G1CollectorPolicy() : void G1CollectorPolicy::initialize_flags() { set_min_alignment(HeapRegion::GrainBytes); size_t card_table_alignment = GenRemSet::max_alignment_constraint(rem_set_name()); - set_max_alignment(MAX2(card_table_alignment, min_alignment())); + size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); + set_max_alignment(MAX3(card_table_alignment, min_alignment(), page_size)); if (SurvivorRatio < 1) { vm_exit_during_initialization("Invalid survivor ratio specified"); } diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index cba14a01459..6a1967daeda 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -193,6 +193,8 @@ size_t GenCollectorPolicy::compute_max_alignment() { alignment = lcm(os::large_page_size(), alignment); } + assert(alignment >= min_alignment(), "Must be"); + return alignment; } diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index e0f82c02d86..3a5ab210c83 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -95,13 +95,13 @@ jint GenCollectedHeap::initialize() { guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize"); // The heap must be at least as aligned as generations. - size_t alignment = Generation::GenGrain; + size_t gen_alignment = Generation::GenGrain; _gen_specs = gen_policy()->generations(); // Make sure the sizes are all aligned. for (i = 0; i < _n_gens; i++) { - _gen_specs[i]->align(alignment); + _gen_specs[i]->align(gen_alignment); } // Allocate space for the heap. @@ -109,9 +109,11 @@ jint GenCollectedHeap::initialize() { char* heap_address; size_t total_reserved = 0; int n_covered_regions = 0; - ReservedSpace heap_rs(0); + ReservedSpace heap_rs; - heap_address = allocate(alignment, &total_reserved, + size_t heap_alignment = collector_policy()->max_alignment(); + + heap_address = allocate(heap_alignment, &total_reserved, &n_covered_regions, &heap_rs); if (!heap_rs.is_reserved()) { @@ -168,6 +170,8 @@ char* GenCollectedHeap::allocate(size_t alignment, const size_t pageSize = UseLargePages ? os::large_page_size() : os::vm_page_size(); + assert(alignment % pageSize == 0, "Must be"); + for (int i = 0; i < _n_gens; i++) { total_reserved += _gen_specs[i]->max_size(); if (total_reserved < _gen_specs[i]->max_size()) { @@ -175,24 +179,17 @@ char* GenCollectedHeap::allocate(size_t alignment, } n_covered_regions += _gen_specs[i]->n_covered_regions(); } - assert(total_reserved % pageSize == 0, - err_msg("Gen size; total_reserved=" SIZE_FORMAT ", pageSize=" - SIZE_FORMAT, total_reserved, pageSize)); + assert(total_reserved % alignment == 0, + err_msg("Gen size; total_reserved=" SIZE_FORMAT ", alignment=" + SIZE_FORMAT, total_reserved, alignment)); // Needed until the cardtable is fixed to have the right number // of covered regions. n_covered_regions += 2; - if (UseLargePages) { - assert(total_reserved != 0, "total_reserved cannot be 0"); - total_reserved = round_to(total_reserved, os::large_page_size()); - if (total_reserved < os::large_page_size()) { - vm_exit_during_initialization(overflow_msg); - } - } + *_total_reserved = total_reserved; + *_n_covered_regions = n_covered_regions; - *_total_reserved = total_reserved; - *_n_covered_regions = n_covered_regions; *heap_rs = Universe::reserve_heap(total_reserved, alignment); return heap_rs->base(); } diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index f654a13878c..cd46888c9c2 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -345,7 +345,7 @@ class VirtualSpaceNode : public CHeapObj { }; // byte_size is the size of the associated virtualspace. -VirtualSpaceNode::VirtualSpaceNode(size_t byte_size) : _top(NULL), _next(NULL), _rs(0), _container_count(0) { +VirtualSpaceNode::VirtualSpaceNode(size_t byte_size) : _top(NULL), _next(NULL), _rs(), _container_count(0) { // align up to vm allocation granularity byte_size = align_size_up(byte_size, os::vm_allocation_granularity()); diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index d85d23e015b..143c0c00c45 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -681,17 +681,23 @@ static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1); // 32Gb // OopEncodingHeapMax == NarrowOopHeapMax << LogMinObjAlignmentInBytes; -char* Universe::preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode) { +char* Universe::preferred_heap_base(size_t heap_size, size_t alignment, NARROW_OOP_MODE mode) { + assert(is_size_aligned((size_t)OopEncodingHeapMax, alignment), "Must be"); + assert(is_size_aligned((size_t)NarrowOopHeapMax, alignment), "Must be"); + assert(is_size_aligned(heap_size, alignment), "Must be"); + + uintx heap_base_min_address_aligned = align_size_up(HeapBaseMinAddress, alignment); + size_t base = 0; #ifdef _LP64 if (UseCompressedOops) { assert(mode == UnscaledNarrowOop || mode == ZeroBasedNarrowOop || mode == HeapBasedNarrowOop, "mode is invalid"); - const size_t total_size = heap_size + HeapBaseMinAddress; + const size_t total_size = heap_size + heap_base_min_address_aligned; // Return specified base for the first request. if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) { - base = HeapBaseMinAddress; + base = heap_base_min_address_aligned; // If the total size is small enough to allow UnscaledNarrowOop then // just use UnscaledNarrowOop. @@ -742,6 +748,8 @@ char* Universe::preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode) { } } #endif + + assert(is_ptr_aligned((char*)base, alignment), "Must be"); return (char*)base; // also return NULL (don't care) for 32-bit VM } @@ -867,27 +875,33 @@ ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { size_t total_reserved = align_size_up(heap_size, alignment); assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())), "heap size is too big for compressed oops"); - char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop); - ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr); + bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size()); + assert(!UseLargePages + || UseParallelOldGC + || use_large_pages, "Wrong alignment to use large pages"); + + char* addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::UnscaledNarrowOop); + + ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages, addr); if (UseCompressedOops) { if (addr != NULL && !total_rs.is_reserved()) { // Failed to reserve at specified address - the requested memory // region is taken already, for example, by 'java' launcher. // Try again to reserver heap higher. - addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop); + addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::ZeroBasedNarrowOop); ReservedHeapSpace total_rs0(total_reserved, alignment, - UseLargePages, addr); + use_large_pages, addr); if (addr != NULL && !total_rs0.is_reserved()) { // Failed to reserve at specified address again - give up. - addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop); + addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::HeapBasedNarrowOop); assert(addr == NULL, ""); ReservedHeapSpace total_rs1(total_reserved, alignment, - UseLargePages, addr); + use_large_pages, addr); total_rs = total_rs1; } else { total_rs = total_rs0; diff --git a/hotspot/src/share/vm/memory/universe.hpp b/hotspot/src/share/vm/memory/universe.hpp index 1ebe5f2b57e..a8b541d03a1 100644 --- a/hotspot/src/share/vm/memory/universe.hpp +++ b/hotspot/src/share/vm/memory/universe.hpp @@ -346,7 +346,7 @@ class Universe: AllStatic { }; static NARROW_OOP_MODE narrow_oop_mode(); static const char* narrow_oop_mode_to_string(NARROW_OOP_MODE mode); - static char* preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode); + static char* preferred_heap_base(size_t heap_size, size_t alignment, NARROW_OOP_MODE mode); static char* preferred_metaspace_base(size_t heap_size, NARROW_OOP_MODE mode); static address narrow_oop_base() { return _narrow_oop._base; } static bool is_narrow_oop_base(void* addr) { return (narrow_oop_base() == (address)addr); } diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 188cf4a6e60..acf79f53525 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -5027,9 +5027,15 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { tty->print_cr("Running test: " #unit_test_function_call); \ unit_test_function_call +// Forward declaration +void TestReservedSpace_test(); +void TestReserveMemorySpecial_test(); + void execute_internal_vm_tests() { if (ExecuteInternalVMTests) { tty->print_cr("Running internal VM tests"); + run_unit_test(TestReservedSpace_test()); + run_unit_test(TestReserveMemorySpecial_test()); run_unit_test(GlobalDefinitions::test_globals()); run_unit_test(GCTimerAllTest::all()); run_unit_test(arrayOopDesc::test_max_array_length()); diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9b67389af47..f54939096e9 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1933,6 +1933,9 @@ class CommandLineFlags { notproduct(bool, ExecuteInternalVMTests, false, \ "Enable execution of internal VM tests.") \ \ + notproduct(bool, VerboseInternalVMTests, false, \ + "Turn on logging for internal VM tests.") \ + \ product_pd(bool, UseTLAB, "Use thread-local object allocation") \ \ product_pd(bool, ResizeTLAB, \ diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 03497e1973b..38efad386f1 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -328,8 +328,8 @@ class os: AllStatic { static char* non_memory_address_word(); // reserve, commit and pin the entire memory region - static char* reserve_memory_special(size_t size, char* addr = NULL, - bool executable = false); + static char* reserve_memory_special(size_t size, size_t alignment, + char* addr, bool executable); static bool release_memory_special(char* addr, size_t bytes); static void large_page_init(); static size_t large_page_size(); diff --git a/hotspot/src/share/vm/runtime/virtualspace.cpp b/hotspot/src/share/vm/runtime/virtualspace.cpp index 9096a034cef..9e01fe0292f 100644 --- a/hotspot/src/share/vm/runtime/virtualspace.cpp +++ b/hotspot/src/share/vm/runtime/virtualspace.cpp @@ -42,8 +42,19 @@ // ReservedSpace + +// Dummy constructor +ReservedSpace::ReservedSpace() : _base(NULL), _size(0), _noaccess_prefix(0), + _alignment(0), _special(false), _executable(false) { +} + ReservedSpace::ReservedSpace(size_t size) { - initialize(size, 0, false, NULL, 0, false); + size_t page_size = os::page_size_for_region(size, size, 1); + bool large_pages = page_size != (size_t)os::vm_page_size(); + // Don't force the alignment to be large page aligned, + // since that will waste memory. + size_t alignment = os::vm_allocation_granularity(); + initialize(size, alignment, large_pages, NULL, 0, false); } ReservedSpace::ReservedSpace(size_t size, size_t alignment, @@ -129,16 +140,18 @@ void ReservedSpace::initialize(size_t size, size_t alignment, bool large, if (special) { - base = os::reserve_memory_special(size, requested_address, executable); + base = os::reserve_memory_special(size, alignment, requested_address, executable); if (base != NULL) { if (failed_to_reserve_as_requested(base, requested_address, size, true)) { // OS ignored requested address. Try different address. return; } - // Check alignment constraints + // Check alignment constraints. assert((uintptr_t) base % alignment == 0, - "Large pages returned a non-aligned address"); + err_msg("Large pages returned a non-aligned address, base: " + PTR_FORMAT " alignment: " PTR_FORMAT, + base, (void*)(uintptr_t)alignment)); _special = true; } else { // failed; try to reserve regular memory below @@ -715,4 +728,188 @@ void VirtualSpace::print() { tty->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", low_boundary(), high_boundary()); } + +/////////////// Unit tests /////////////// + +#ifndef PRODUCT + +#define test_log(...) \ + do {\ + if (VerboseInternalVMTests) { \ + tty->print_cr(__VA_ARGS__); \ + tty->flush(); \ + }\ + } while (false) + +class TestReservedSpace : AllStatic { + public: + static void small_page_write(void* addr, size_t size) { + size_t page_size = os::vm_page_size(); + + char* end = (char*)addr + size; + for (char* p = (char*)addr; p < end; p += page_size) { + *p = 1; + } + } + + static void release_memory_for_test(ReservedSpace rs) { + if (rs.special()) { + guarantee(os::release_memory_special(rs.base(), rs.size()), "Shouldn't fail"); + } else { + guarantee(os::release_memory(rs.base(), rs.size()), "Shouldn't fail"); + } + } + + static void test_reserved_space1(size_t size, size_t alignment) { + test_log("test_reserved_space1(%p)", (void*) (uintptr_t) size); + + assert(is_size_aligned(size, alignment), "Incorrect input parameters"); + + ReservedSpace rs(size, // size + alignment, // alignment + UseLargePages, // large + NULL, // requested_address + 0); // noacces_prefix + + test_log(" rs.special() == %d", rs.special()); + + assert(rs.base() != NULL, "Must be"); + assert(rs.size() == size, "Must be"); + + assert(is_ptr_aligned(rs.base(), alignment), "aligned sizes should always give aligned addresses"); + assert(is_size_aligned(rs.size(), alignment), "aligned sizes should always give aligned addresses"); + + if (rs.special()) { + small_page_write(rs.base(), size); + } + + release_memory_for_test(rs); + } + + static void test_reserved_space2(size_t size) { + test_log("test_reserved_space2(%p)", (void*)(uintptr_t)size); + + assert(is_size_aligned(size, os::vm_allocation_granularity()), "Must be at least AG aligned"); + + ReservedSpace rs(size); + + test_log(" rs.special() == %d", rs.special()); + + assert(rs.base() != NULL, "Must be"); + assert(rs.size() == size, "Must be"); + + if (rs.special()) { + small_page_write(rs.base(), size); + } + + release_memory_for_test(rs); + } + + static void test_reserved_space3(size_t size, size_t alignment, bool maybe_large) { + test_log("test_reserved_space3(%p, %p, %d)", + (void*)(uintptr_t)size, (void*)(uintptr_t)alignment, maybe_large); + + assert(is_size_aligned(size, os::vm_allocation_granularity()), "Must be at least AG aligned"); + assert(is_size_aligned(size, alignment), "Must be at least aligned against alignment"); + + bool large = maybe_large && UseLargePages && size >= os::large_page_size(); + + ReservedSpace rs(size, alignment, large, false); + + test_log(" rs.special() == %d", rs.special()); + + assert(rs.base() != NULL, "Must be"); + assert(rs.size() == size, "Must be"); + + if (rs.special()) { + small_page_write(rs.base(), size); + } + + release_memory_for_test(rs); + } + + + static void test_reserved_space1() { + size_t size = 2 * 1024 * 1024; + size_t ag = os::vm_allocation_granularity(); + + test_reserved_space1(size, ag); + test_reserved_space1(size * 2, ag); + test_reserved_space1(size * 10, ag); + } + + static void test_reserved_space2() { + size_t size = 2 * 1024 * 1024; + size_t ag = os::vm_allocation_granularity(); + + test_reserved_space2(size * 1); + test_reserved_space2(size * 2); + test_reserved_space2(size * 10); + test_reserved_space2(ag); + test_reserved_space2(size - ag); + test_reserved_space2(size); + test_reserved_space2(size + ag); + test_reserved_space2(size * 2); + test_reserved_space2(size * 2 - ag); + test_reserved_space2(size * 2 + ag); + test_reserved_space2(size * 3); + test_reserved_space2(size * 3 - ag); + test_reserved_space2(size * 3 + ag); + test_reserved_space2(size * 10); + test_reserved_space2(size * 10 + size / 2); + } + + static void test_reserved_space3() { + size_t ag = os::vm_allocation_granularity(); + + test_reserved_space3(ag, ag , false); + test_reserved_space3(ag * 2, ag , false); + test_reserved_space3(ag * 3, ag , false); + test_reserved_space3(ag * 2, ag * 2, false); + test_reserved_space3(ag * 4, ag * 2, false); + test_reserved_space3(ag * 8, ag * 2, false); + test_reserved_space3(ag * 4, ag * 4, false); + test_reserved_space3(ag * 8, ag * 4, false); + test_reserved_space3(ag * 16, ag * 4, false); + + if (UseLargePages) { + size_t lp = os::large_page_size(); + + // Without large pages + test_reserved_space3(lp, ag * 4, false); + test_reserved_space3(lp * 2, ag * 4, false); + test_reserved_space3(lp * 4, ag * 4, false); + test_reserved_space3(lp, lp , false); + test_reserved_space3(lp * 2, lp , false); + test_reserved_space3(lp * 3, lp , false); + test_reserved_space3(lp * 2, lp * 2, false); + test_reserved_space3(lp * 4, lp * 2, false); + test_reserved_space3(lp * 8, lp * 2, false); + + // With large pages + test_reserved_space3(lp, ag * 4 , true); + test_reserved_space3(lp * 2, ag * 4, true); + test_reserved_space3(lp * 4, ag * 4, true); + test_reserved_space3(lp, lp , true); + test_reserved_space3(lp * 2, lp , true); + test_reserved_space3(lp * 3, lp , true); + test_reserved_space3(lp * 2, lp * 2, true); + test_reserved_space3(lp * 4, lp * 2, true); + test_reserved_space3(lp * 8, lp * 2, true); + } + } + + static void test_reserved_space() { + test_reserved_space1(); + test_reserved_space2(); + test_reserved_space3(); + } +}; + +void TestReservedSpace_test() { + TestReservedSpace::test_reserved_space(); +} + +#endif // PRODUCT + #endif diff --git a/hotspot/src/share/vm/runtime/virtualspace.hpp b/hotspot/src/share/vm/runtime/virtualspace.hpp index 0a959e900a0..bca9b6c14fc 100644 --- a/hotspot/src/share/vm/runtime/virtualspace.hpp +++ b/hotspot/src/share/vm/runtime/virtualspace.hpp @@ -53,6 +53,7 @@ class ReservedSpace VALUE_OBJ_CLASS_SPEC { public: // Constructor + ReservedSpace(); ReservedSpace(size_t size); ReservedSpace(size_t size, size_t alignment, bool large, char* requested_address = NULL, diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 364c6b4f235..1072e5d6a3d 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -87,6 +87,8 @@ class MemTracker : AllStatic { MEMFLAGS flags, address pc = 0, Thread* thread = NULL) { } static inline void record_virtual_memory_commit(address addr, size_t size, address pc = 0, Thread* thread = NULL) { } + static inline void record_virtual_memory_release(address addr, size_t size, + Thread* thread = NULL) { } static inline void record_virtual_memory_type(address base, MEMFLAGS flags, Thread* thread = NULL) { } static inline Tracker get_realloc_tracker() { return _tkr; } @@ -372,6 +374,13 @@ class MemTracker : AllStatic { tkr.record(addr, size, flags, pc); } + static inline void record_virtual_memory_release(address addr, size_t size, + Thread* thread = NULL) { + if (is_on()) { + Tracker tkr(Tracker::Release, thread); + tkr.record(addr, size); + } + } // record memory type on virtual memory base address static inline void record_virtual_memory_type(address base, MEMFLAGS flags, diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 3b4be625a35..bbee85c8b23 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -402,6 +402,14 @@ const jlong CompressedKlassPointersBase = NOT_LP64(0) LP64_ONLY(CONST64(0x800000 #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1)) +inline bool is_size_aligned(size_t size, size_t alignment) { + return align_size_up_(size, alignment) == size; +} + +inline bool is_ptr_aligned(void* ptr, size_t alignment) { + return align_size_up_((intptr_t)ptr, (intptr_t)alignment) == (intptr_t)ptr; +} + inline intptr_t align_size_up(intptr_t size, intptr_t alignment) { return align_size_up_(size, alignment); } @@ -414,6 +422,14 @@ inline intptr_t align_size_down(intptr_t size, intptr_t alignment) { #define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment))) +inline void* align_ptr_up(void* ptr, size_t alignment) { + return (void*)align_size_up((intptr_t)ptr, (intptr_t)alignment); +} + +inline void* align_ptr_down(void* ptr, size_t alignment) { + return (void*)align_size_down((intptr_t)ptr, (intptr_t)alignment); +} + // Align objects by rounding up their size, in HeapWord units. #define align_object_size_(size) align_size_up_(size, MinObjAlignment) From d0aa753d993b3d87e5ae673645a5dbce9a0021fe Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Fri, 16 Aug 2013 06:12:46 -0700 Subject: [PATCH 004/117] 8022817: CMS should not shrink if compaction was not done Reviewed-by: ysr, mgerdin --- .../concurrentMarkSweepGeneration.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index fe53388a05f..04b550c718b 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -3460,7 +3460,9 @@ void ConcurrentMarkSweepGeneration::shrink_by(size_t bytes) { void ConcurrentMarkSweepGeneration::shrink(size_t bytes) { assert_locked_or_safepoint(Heap_lock); size_t size = ReservedSpace::page_align_size_down(bytes); - if (size > 0) { + // Only shrink if a compaction was done so that all the free space + // in the generation is in a contiguous block at the end. + if (size > 0 && did_compact()) { shrink_by(size); } } @@ -8696,9 +8698,10 @@ void SweepClosure::lookahead_and_flush(FreeChunk* fc, size_t chunk_size) { assert(inFreeRange(), "Should only be called if currently in a free range."); HeapWord* const eob = ((HeapWord*)fc) + chunk_size; assert(_sp->used_region().contains(eob - 1), - err_msg("eob = " PTR_FORMAT " out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")" + err_msg("eob = " PTR_FORMAT " eob-1 = " PTR_FORMAT " _limit = " PTR_FORMAT + " out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")" " when examining fc = " PTR_FORMAT "(" SIZE_FORMAT ")", - _limit, _sp->bottom(), _sp->end(), fc, chunk_size)); + eob, eob-1, _limit, _sp->bottom(), _sp->end(), fc, chunk_size)); if (eob >= _limit) { assert(eob == _limit || fc->is_free(), "Only a free chunk should allow us to cross over the limit"); if (CMSTraceSweeper) { From 0e8b1016432bdd072bc7c6e24e50e5de88ff32e0 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 21 Aug 2013 09:59:12 +0100 Subject: [PATCH 005/117] 8023351: Add TEST.groups in preparation to simplify rules in jdk/test/Makefile Reviewed-by: lancea, mduigou --- jdk/test/TEST.ROOT | 3 + jdk/test/TEST.groups | 214 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 jdk/test/TEST.groups diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT index 6bf72964f66..0aba9d3bc72 100644 --- a/jdk/test/TEST.ROOT +++ b/jdk/test/TEST.ROOT @@ -9,3 +9,6 @@ othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio java # Tests that cannot run concurrently exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi + +# Group definitions +groups=TEST.groups [closed/TEST.groups] diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups new file mode 100644 index 00000000000..0674bdc1d91 --- /dev/null +++ b/jdk/test/TEST.groups @@ -0,0 +1,214 @@ +# 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. +# + +jdk_lang = \ + java/lang \ + -java/lang/management \ + -java/lang/instrument \ + sun/invoke \ + sun/misc \ + sun/reflect \ + vm + +jdk_util = \ + java/util \ + sun/util + +jdk_math = \ + java/math + +jdk_io = \ + java/io + +jdk_nio = \ + java/nio \ + sun/nio + +jdk_net = \ + java/net \ + com/sun/net \ + com/oracle/net \ + sun/net + +jdk_time = \ + java/time + +jdk_rmi = \ + java/rmi \ + javax/rmi/ssl \ + sun/rmi + +jdk_security1 = \ + java/security + +jdk_security2 = \ + javax/crypto \ + javax/xml/crypto \ + com/sun/crypto + +jdk_security3 = \ + javax/security \ + com/sun/security \ + com/sun/org/apache/xml/internal/security \ + com/oracle/security \ + sun/security \ + lib/security + +jdk_security = \ + :jdk_security1 \ + :jdk_security2 \ + :jdk_security3 + +jdk_text = \ + java/text \ + sun/text + +jdk_management = \ + java/lang/management \ + com/sun/management \ + sun/management + +jdk_instrument = \ + java/lang/instrument + +jdk_jmx = \ + javax/management \ + com/sun/jmx + +jdk_jdi = \ + com/sun/jdi + +# +# Tool (and tool API) tests are split into core and svc groups +# +core_tools = \ + tools \ + com/sun/tools/extcheck \ + sun/tools/java \ + sun/tools/native2ascii \ + sun/tools/jrunscript + +svc_tools = \ + com/sun/tools/attach \ + com/sun/tracing \ + sun/tools \ + -sun/tools/java \ + -sun/tools/native2ascii \ + -sun/tools/jrunscript \ + sun/jvmstat \ + demo/jvmti + +jdk_tools = \ + :core_tools \ + :svc_tools + +# +# Catch-all for other areas with a small number of tests +# +jdk_other = \ + java/sql \ + javax/sql \ + javax/naming \ + javax/script \ + javax/smartcardio \ + javax/xml \ + -javax/xml/crypto \ + jdk/asm \ + jdk/lambda \ + com/sun/jndi \ + com/sun/corba \ + lib/testlibrary \ + demo/zipfs \ + sample + +# +# SCTP is its own group as it is highly sensitive to kernel/network config +# +jdk_sctp = \ + com/sun/nio/sctp + + +# +# core group to run all core area tests +# +jdk_core = \ + :jdk_lang \ + :jdk_util \ + :jdk_math \ + :jdk_io \ + :jdk_nio \ + :jdk_net \ + :jdk_rmi \ + :jdk_time \ + :jdk_security \ + :jdk_text \ + :core_tools \ + :jdk_other + +# +# svc group to run all serviceability area tests +# +jdk_svc = \ + :jdk_management \ + :jdk_instrument \ + :jdk_jmx \ + :jdk_jdi \ + :svc_tools + +############################# + +# +# Client area groups +# + +jdk_awt = \ + java/awt \ + com/sun/awt \ + com/apple/eawt \ + sun/awt + +jdk_2d = \ + javax/print \ + sun/pisces \ + sun/java2d + +jdk_beans = \ + java/beans + +jdk_swing = \ + javax/accessibility \ + javax/swing \ + com/sun/java/swing + +jdk_sound = \ + javax/sound + +jdk_imageio = \ + javax/imageio + +jdk_desktop = \ + :jdk_awt \ + :jdk_2d \ + :jdk_beans \ + :jdk_swing \ + :jdk_sound \ + :jdk_imageio From bf1e11707b5305407f23099bd5bf07beed50a742 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Mon, 19 Aug 2013 12:57:17 +0200 Subject: [PATCH 006/117] 6358357: Division by zero in Threads tab when shrinking jconsole window Reviewed-by: mchung, leifs, jbachorik --- jdk/src/share/classes/sun/tools/jconsole/Plotter.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/tools/jconsole/Plotter.java b/jdk/src/share/classes/sun/tools/jconsole/Plotter.java index 793b0ea263d..acfd005dd0b 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/Plotter.java +++ b/jdk/src/share/classes/sun/tools/jconsole/Plotter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -337,6 +337,13 @@ public class Plotter extends JComponent public void paintComponent(Graphics g) { super.paintComponent(g); + int width = getWidth()-rightMargin-leftMargin-10; + int height = getHeight()-topMargin-bottomMargin; + if (width <= 0 || height <= 0) { + // not enough room to paint anything + return; + } + Color oldColor = g.getColor(); Font oldFont = g.getFont(); Color fg = getForeground(); From 99f960f2ef451260691e4a0ccbf57f28bdc28395 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Mon, 19 Aug 2013 16:21:49 +0200 Subject: [PATCH 007/117] 6417721: Thread list should not allow multiple selection Reviewed-by: alanb, jbachorik, sjiang --- jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java b/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java index 354f351f750..3932ffa145e 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java +++ b/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java @@ -595,6 +595,7 @@ class ThreadTab extends Tab implements ActionListener, DocumentListener, ListSel setBorder(thinEmptyBorder); + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); addListSelectionListener(ThreadTab.this); setCellRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, From 1d3c8aa7088a6c323b34f78644e48d56843e625f Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Mon, 19 Aug 2013 16:41:21 +0200 Subject: [PATCH 008/117] 6800801: NPE in JConsole when using Nimbus L&F Reviewed-by: alanb, sjiang --- .../share/classes/sun/tools/jconsole/ConnectDialog.java | 9 +++++++-- jdk/src/share/classes/sun/tools/jconsole/VMPanel.java | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java b/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java index ea3f8366766..3198fd6cd6a 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java +++ b/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -268,8 +268,13 @@ public class ConnectDialog extends InternalDialog public void revalidate() { // Adjust some colors + Color disabledForeground = UIManager.getColor("Label.disabledForeground"); + if (disabledForeground == null) { + // fall back for Nimbus that doesn't support 'Label.disabledForeground' + disabledForeground = UIManager.getColor("Label.disabledText"); + } hintTextColor = - ensureContrast(UIManager.getColor("Label.disabledForeground"), + ensureContrast(disabledForeground, UIManager.getColor("Panel.background")); disabledTableCellColor = ensureContrast(new Color(0x808080), diff --git a/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java b/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java index b7a0f5b410b..1561b9cc5bb 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java +++ b/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java @@ -153,9 +153,11 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { // in order to reserve space for the connect toggle. public void setUI(TabbedPaneUI ui) { Insets insets = (Insets) UIManager.getLookAndFeelDefaults().get("TabbedPane.tabAreaInsets"); - insets = (Insets) insets.clone(); - insets.right += connectedIcon24.getIconWidth() + 8; - UIManager.put("TabbedPane.tabAreaInsets", insets); + if (insets != null) { + insets = (Insets) insets.clone(); + insets.right += connectedIcon24.getIconWidth() + 8; + UIManager.put("TabbedPane.tabAreaInsets", insets); + } super.setUI(ui); } From 910c4e1d3467206e2bf8696124018fd20adc64a7 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Mon, 19 Aug 2013 13:11:03 +0200 Subject: [PATCH 009/117] 7042707: Un-needed mnemonic in JConsole resource file Reviewed-by: mfang, jbachorik --- jdk/src/share/classes/sun/tools/jconsole/Messages.java | 3 +-- .../classes/sun/tools/jconsole/resources/messages.properties | 1 - .../sun/tools/jconsole/resources/messages_ja.properties | 1 - .../sun/tools/jconsole/resources/messages_zh_CN.properties | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/jdk/src/share/classes/sun/tools/jconsole/Messages.java b/jdk/src/share/classes/sun/tools/jconsole/Messages.java index 0e5fd76bd20..eee57adcc25 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/Messages.java +++ b/jdk/src/share/classes/sun/tools/jconsole/Messages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -146,7 +146,6 @@ final public class Messages { public static String HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME; public static String HELP_ABOUT_DIALOG_MASTHEAD_TITLE; public static String HELP_ABOUT_DIALOG_TITLE; - public static String HELP_ABOUT_DIALOG_USER_GUIDE_LINK; public static String HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL; public static String HELP_MENU_ABOUT_TITLE; public static String HELP_MENU_USER_GUIDE_TITLE; diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties b/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties index ef0b4f136e4..70ff2f16c6e 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties +++ b/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties @@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM version:
{0} HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=Masthead Graphic HELP_ABOUT_DIALOG_MASTHEAD_TITLE=About JConsole HELP_ABOUT_DIALOG_TITLE=JConsole: About -HELP_ABOUT_DIALOG_USER_GUIDE_LINK=JConsole &User Guide:
{0} HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_MENU_ABOUT_TITLE=&About JConsole HELP_MENU_USER_GUIDE_TITLE=Online &User Guide diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/messages_ja.properties b/jdk/src/share/classes/sun/tools/jconsole/resources/messages_ja.properties index 9cc5df8fad8..c66ace77035 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/resources/messages_ja.properties +++ b/jdk/src/share/classes/sun/tools/jconsole/resources/messages_ja.properties @@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM\u30D0\u30FC\u30B8\u30E7\u30F3:
{0} HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u30DE\u30B9\u30C8\u30D8\u30C3\u30C9\u56F3\u5F62 HELP_ABOUT_DIALOG_MASTHEAD_TITLE=JConsole\u306B\u3064\u3044\u3066 HELP_ABOUT_DIALOG_TITLE=JConsole: \u8A73\u7D30 -HELP_ABOUT_DIALOG_USER_GUIDE_LINK=JConsole\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U):
{0} HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_MENU_ABOUT_TITLE=JConsole\u306B\u3064\u3044\u3066(&A) HELP_MENU_USER_GUIDE_TITLE=\u30AA\u30F3\u30E9\u30A4\u30F3\u30FB\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U) diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/messages_zh_CN.properties b/jdk/src/share/classes/sun/tools/jconsole/resources/messages_zh_CN.properties index d654392edf2..3f782adc620 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/resources/messages_zh_CN.properties +++ b/jdk/src/share/classes/sun/tools/jconsole/resources/messages_zh_CN.properties @@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM \u7248\u672C:
{0} HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u62A5\u5934\u56FE HELP_ABOUT_DIALOG_MASTHEAD_TITLE=\u5173\u4E8E JConsole HELP_ABOUT_DIALOG_TITLE=JConsole: \u5173\u4E8E -HELP_ABOUT_DIALOG_USER_GUIDE_LINK=JConsole \u7528\u6237\u6307\u5357(&U):
{0} HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_MENU_ABOUT_TITLE=\u5173\u4E8E JConsole(&A) HELP_MENU_USER_GUIDE_TITLE=\u8054\u673A\u7528\u6237\u6307\u5357(&U) From 7568ce74817aebe1d62d0bb86e9b560d0674a68c Mon Sep 17 00:00:00 2001 From: David Holmes Date: Wed, 21 Aug 2013 05:56:46 -0400 Subject: [PATCH 010/117] 8023460: OPENJDK build fails due to missing jfr.jar Reviewed-by: alanb --- jdk/makefiles/Profiles.gmk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/makefiles/Profiles.gmk b/jdk/makefiles/Profiles.gmk index 47fadcc9df9..9e79b2b27ac 100644 --- a/jdk/makefiles/Profiles.gmk +++ b/jdk/makefiles/Profiles.gmk @@ -65,10 +65,6 @@ PROFILE_2_JARS := \ $(if $(PROFILE_2_JRE_JAR_FILES), $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_2_JRE_JAR_FILES))) \ $(PROFILE_1_JARS) -ifneq ($(ENABLE_JFR), true) - PROFILE_3_JRE_JAR_FILES := $(filter-out jfr.jar, $(PROFILE_3_JRE_JAR_FILES)) -endif - PROFILE_3_JARS := \ $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_3_JRE_JAR_FILES)) \ $(PROFILE_2_JARS) @@ -77,6 +73,10 @@ ifdef OPENJDK FULL_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(FULL_JRE_JAR_FILES)) endif +ifneq ($(ENABLE_JFR), true) + FULL_JRE_JAR_FILES := $(filter-out jfr.jar, $(FULL_JRE_JAR_FILES)) +endif + FULL_JRE_JARS := \ $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(FULL_JRE_JAR_FILES)) \ $(PROFILE_3_JARS) From 01ba926ba1c9bb8bf32f017a74d1c2549b866bce Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Wed, 21 Aug 2013 17:19:46 +0200 Subject: [PATCH 011/117] 8023485: Remove com/sun/jdi/DoubleAgentTest.java and com/sun/jdi/FieldWatchpoints.java from ProblemList.txt Reviewed-by: chegar, mgronlun --- jdk/test/ProblemList.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 00a354a7b0d..ab2eac5ecbd 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -336,12 +336,6 @@ com/sun/jdi/SuspendThreadTest.java generic-all # Filed 6653793 com/sun/jdi/RedefineCrossEvent.java generic-all -# Filed 6987312 -com/sun/jdi/DoubleAgentTest.java generic-all - -# Filed 7020857 -com/sun/jdi/FieldWatchpoints.java generic-all - # Filed 6402201 com/sun/jdi/ProcessAttachTest.sh generic-all From 8a3c65febe4da5102c544676429e26868e6110ee Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Wed, 21 Aug 2013 12:03:19 -0700 Subject: [PATCH 012/117] 8023306: Add replace() implementations to TreeMap Reviewed-by: psandoz, alanb, chegar, bpb --- jdk/src/share/classes/java/util/TreeMap.java | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/jdk/src/share/classes/java/util/TreeMap.java b/jdk/src/share/classes/java/util/TreeMap.java index 52d9df25a0b..9a4681d771a 100644 --- a/jdk/src/share/classes/java/util/TreeMap.java +++ b/jdk/src/share/classes/java/util/TreeMap.java @@ -972,6 +972,27 @@ public class TreeMap return tailMap(fromKey, true); } + @Override + public boolean replace(K key, V oldValue, V newValue) { + Entry p = getEntry(key); + if (p!=null && Objects.equals(oldValue, p.value)) { + p.value = newValue; + return true; + } + return false; + } + + @Override + public V replace(K key, V value) { + Entry p = getEntry(key); + if (p!=null) { + V oldValue = p.value; + p.value = value; + return oldValue; + } + return null; + } + @Override public void forEach(BiConsumer action) { Objects.requireNonNull(action); From 629de57fe861fa4cfc986f48570c17790381e0b5 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Wed, 21 Aug 2013 12:03:28 -0700 Subject: [PATCH 013/117] 8023395: Remove sun.misc.Sort and sun.misc.Compare Reviewed-by: alanb, smarks, darcy, mr --- jdk/src/share/classes/sun/misc/Compare.java | 46 ------------- jdk/src/share/classes/sun/misc/Sort.java | 74 --------------------- 2 files changed, 120 deletions(-) delete mode 100644 jdk/src/share/classes/sun/misc/Compare.java delete mode 100644 jdk/src/share/classes/sun/misc/Sort.java diff --git a/jdk/src/share/classes/sun/misc/Compare.java b/jdk/src/share/classes/sun/misc/Compare.java deleted file mode 100644 index 400fc1713ca..00000000000 --- a/jdk/src/share/classes/sun/misc/Compare.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1996, 1997, 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. - */ - -/** - * Compare: an interface to enable users to define the result of - * a comparison of two objects. - * - * @author Sunita Mani - */ - -package sun.misc; - -public interface Compare { - - /** - * doCompare - * - * @param obj1 first object to compare. - * @param obj2 second object to compare. - * @return -1 if obj1 < obj2, 0 if obj1 == obj2, 1 if obj1 > obj2. - */ - public int doCompare(Object obj1, Object obj2); - -} diff --git a/jdk/src/share/classes/sun/misc/Sort.java b/jdk/src/share/classes/sun/misc/Sort.java deleted file mode 100644 index adf8e78ff2c..00000000000 --- a/jdk/src/share/classes/sun/misc/Sort.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1996, 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. - */ - -/** - * Sort: a class that uses the quicksort algorithm to sort an - * array of objects. - * - * @author Sunita Mani - */ - -package sun.misc; - -public class Sort { - - private static void swap(Object arr[], int i, int j) { - Object tmp; - - tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; - } - - /** - * quicksort the array of objects. - * - * @param arr[] - an array of objects - * @param left - the start index - from where to begin sorting - * @param right - the last index. - * @param comp - an object that implemnts the Compare interface to resolve thecomparison. - */ - public static void quicksort(Object arr[], int left, int right, Compare comp) { - int i, last; - - if (left >= right) { /* do nothing if array contains fewer than two */ - return; /* two elements */ - } - swap(arr, left, (left+right) / 2); - last = left; - for (i = left+1; i <= right; i++) { - if (comp.doCompare(arr[i], arr[left]) < 0) { - swap(arr, ++last, i); - } - } - swap(arr, left, last); - quicksort(arr, left, last-1, comp); - quicksort(arr, last+1, right, comp); - } - - public static void quicksort(Object arr[], Compare comp) { - quicksort(arr, 0, arr.length-1, comp); - } -} From c9443a8346bb73891c3cdbc7e174daebf4fa1b79 Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Tue, 20 Aug 2013 14:23:32 -0700 Subject: [PATCH 014/117] 8016846: Pattern.splitAsStream tests required Reviewed-by: alanb, psandoz --- jdk/test/java/util/regex/PatternTest.java | 147 ++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 jdk/test/java/util/regex/PatternTest.java diff --git a/jdk/test/java/util/regex/PatternTest.java b/jdk/test/java/util/regex/PatternTest.java new file mode 100644 index 00000000000..aab17319ae4 --- /dev/null +++ b/jdk/test/java/util/regex/PatternTest.java @@ -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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @summary Unit tests for wrapping classes should delegate to default methods + * @library ../stream/bootlib + * @build java.util.stream.OpTestCase + * @run testng/othervm PatternTest + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; +import java.util.regex.Pattern; +import java.util.stream.LambdaTestHelpers; +import java.util.stream.OpTestCase; +import java.util.stream.Stream; +import java.util.stream.TestData; + +@Test +public class PatternTest extends OpTestCase { + + @DataProvider(name = "Stream") + public static Object[][] makeStreamTestData() { + List data = new ArrayList<>(); + + String description = ""; + String input = "awgqwefg1fefw4vssv1vvv1"; + Pattern pattern = Pattern.compile("4"); + List expected = new ArrayList<>(); + expected.add("awgqwefg1fefw"); + expected.add("vssv1vvv1"); + + // Must match the type signature of the consumer of this data, testStrings + // String, String, Pattern, List + data.add(new Object[]{description, input, pattern, expected}); + + input = "afbfq\u00a3abgwgb\u00a3awngnwggw\u00a3a\u00a3ahjrnhneerh"; + pattern = Pattern.compile("\u00a3a"); + expected = new ArrayList<>(); + expected.add("afbfq"); + expected.add("bgwgb"); + expected.add("wngnwggw"); + expected.add(""); + expected.add("hjrnhneerh"); + + data.add(new Object[]{description, input, pattern, expected}); + + + input = "awgqwefg1fefw4vssv1vvv1"; + pattern = Pattern.compile("1"); + expected = new ArrayList<>(); + expected.add("awgqwefg"); + expected.add("fefw4vssv"); + expected.add("vvv"); + + data.add(new Object[]{description, input, pattern, expected}); + + + input = "a\u4ebafg1fefw\u4eba4\u9f9cvssv\u9f9c1v\u672c\u672cvv"; + pattern = Pattern.compile("1"); + expected = new ArrayList<>(); + expected.add("a\u4ebafg"); + expected.add("fefw\u4eba4\u9f9cvssv\u9f9c"); + expected.add("v\u672c\u672cvv"); + + data.add(new Object[]{description, input, pattern, expected}); + + + input = "1\u56da23\u56da456\u56da7890"; + pattern = Pattern.compile("\u56da"); + expected = new ArrayList<>(); + expected.add("1"); + expected.add("23"); + expected.add("456"); + expected.add("7890"); + + data.add(new Object[]{description, input, pattern, expected}); + + + input = "1\u56da23\u9f9c\u672c\u672c\u56da456\u56da\u9f9c\u672c7890"; + pattern = Pattern.compile("\u56da"); + expected = new ArrayList<>(); + expected.add("1"); + expected.add("23\u9f9c\u672c\u672c"); + expected.add("456"); + expected.add("\u9f9c\u672c7890"); + + data.add(new Object[]{description, input, pattern, expected}); + + + input = ""; + pattern = Pattern.compile("\u56da"); + expected = new ArrayList<>(); + + data.add(new Object[]{description, input, pattern, expected}); + + + description = "Multiple separators"; + input = "This is,testing: with\tdifferent separators."; + pattern = Pattern.compile("[ \t,:.]"); + expected = new ArrayList<>(); + expected.add("This"); + expected.add("is"); + expected.add("testing"); + expected.add(""); + expected.add("with"); + expected.add("different"); + expected.add("separators"); + + data.add(new Object[] {description, input, pattern, expected}); + return data.toArray(new Object[0][]); + } + + @Test(dataProvider = "Stream") + public void testStrings(String description, String input, Pattern pattern, List expected) { + Supplier> ss = () -> pattern.splitAsStream(input); + withData(TestData.Factory.ofSupplier(description, ss)) + .stream(LambdaTestHelpers.identity()) + .expectedResult(expected) + .exercise(); + } +} From cac8b88f4892dd356e2612a51c8045810ed1fc06 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Wed, 21 Aug 2013 19:44:35 -0700 Subject: [PATCH 015/117] 8022228: Intermittent test failures in sun/security/ssl/javax/net/ssl/NewAPIs Reviewed-by: weijun --- .../ssl/NewAPIs/SessionCacheSizeTests.java | 124 +++++++++++++----- .../net/ssl/NewAPIs/SessionTimeOutTests.java | 119 ++++++++++++----- .../ssl/templates/SSLSocketTemplate.java | 2 +- 3 files changed, 176 insertions(+), 69 deletions(-) diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java index d5fdadd9b1e..d4e00855dc6 100644 --- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java +++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, 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 @@ -21,14 +21,16 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /* * @test * @bug 4366807 * @summary Need new APIs to get/set session timeout and session cache size. * @run main/othervm SessionCacheSizeTests - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. */ import java.io.*; @@ -113,7 +115,9 @@ public class SessionCacheSizeTests { /* * Signal Client, we're ready for his connect. */ - serverReady = true; + if (createdPorts == serverPorts.length) { + serverReady = true; + } int read = 0; int nConnections = 0; /* @@ -310,7 +314,6 @@ public class SessionCacheSizeTests { * Fork off the other side, then do your work. */ SessionCacheSizeTests() throws Exception { - /* * create the SSLServerSocket and SSLSocket factories */ @@ -323,46 +326,87 @@ public class SessionCacheSizeTests { int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length); int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length); - if (separateServerThread) { - for (int i = 0; i < serverPorts.length; i++) { - - // distribute remaining connections among the available ports - if (i < remainingConns) - startServer(serverPorts[i], (serverConns + 1), true); - else - startServer(serverPorts[i], serverConns, true); - } - startClient(false); - } else { - startClient(true); - for (int i = 0; i < serverPorts.length; i++) { - if (i < remainingConns) - startServer(serverPorts[i], (serverConns + 1), false); - else - startServer(serverPorts[i], serverConns, false); + Exception startException = null; + try { + if (separateServerThread) { + for (int i = 0; i < serverPorts.length; i++) { + // distribute remaining connections among the + // available ports + if (i < remainingConns) + startServer(serverPorts[i], (serverConns + 1), true); + else + startServer(serverPorts[i], serverConns, true); + } + startClient(false); + } else { + startClient(true); + for (int i = 0; i < serverPorts.length; i++) { + if (i < remainingConns) + startServer(serverPorts[i], (serverConns + 1), false); + else + startServer(serverPorts[i], serverConns, false); + } } + } catch (Exception e) { + startException = e; } /* * Wait for other side to close down. */ if (separateServerThread) { - serverThread.join(); + if (serverThread != null) { + serverThread.join(); + } } else { - clientThread.join(); + if (clientThread != null) { + clientThread.join(); + } } /* * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. */ - if (serverException != null) - throw serverException; - if (clientException != null) - throw clientException; + Exception local; + Exception remote; + + if (separateServerThread) { + remote = serverException; + local = clientException; + } else { + remote = clientException; + local = serverException; + } + + Exception exception = null; + + /* + * Check various exception conditions. + */ + if ((local != null) && (remote != null)) { + // If both failed, return the curthread's exception. + local.initCause(remote); + exception = local; + } else if (local != null) { + exception = local; + } else if (remote != null) { + exception = remote; + } else if (startException != null) { + exception = startException; + } + + /* + * If there was an exception *AND* a startException, + * output it. + */ + if (exception != null) { + if (exception != startException && startException != null) { + exception.addSuppressed(startException); + } + throw exception; + } + + // Fall-through: no exception to throw! } void startServer(final int port, final int nConns, @@ -387,7 +431,13 @@ public class SessionCacheSizeTests { }; serverThread.start(); } else { - doServerSide(port, nConns); + try { + doServerSide(port, nConns); + } catch (Exception e) { + serverException = e; + } finally { + serverReady = true; + } } } @@ -409,7 +459,11 @@ public class SessionCacheSizeTests { }; clientThread.start(); } else { - doClientSide(); + try { + doClientSide(); + } catch (Exception e) { + clientException = e; + } } } } diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java index 3d0946724f5..9264cb08723 100644 --- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java +++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, 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 @@ -21,14 +21,14 @@ * questions. */ +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + /* * @test * @bug 4366807 * @summary Need new APIs to get/set session timeout and session cache size. * @run main/othervm SessionTimeOutTests - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. */ import java.io.*; @@ -263,7 +263,7 @@ public class SessionTimeOutTests { for (int i = 0; i < nConnections; i++) { sslSockets[i].close(); } - System.out.println("----------------------------------------" + System.out.println("----------------------------------------" + "-----------------------"); System.out.println("Session timeout test passed"); } @@ -348,45 +348,88 @@ public class SessionTimeOutTests { int serverConns = MAX_ACTIVE_CONNECTIONS / (serverPorts.length); int remainingConns = MAX_ACTIVE_CONNECTIONS % (serverPorts.length); - if (separateServerThread) { - for (int i = 0; i < serverPorts.length; i++) { - // distribute remaining connections among the available ports - if (i < remainingConns) - startServer(serverPorts[i], (serverConns + 1), true); - else - startServer(serverPorts[i], serverConns, true); - } - startClient(false); - } else { - startClient(true); - for (int i = 0; i < serverPorts.length; i++) { - if (i < remainingConns) - startServer(serverPorts[i], (serverConns + 1), false); - else - startServer(serverPorts[i], serverConns, false); + Exception startException = null; + try { + if (separateServerThread) { + for (int i = 0; i < serverPorts.length; i++) { + // distribute remaining connections among the + // vailable ports + if (i < remainingConns) + startServer(serverPorts[i], (serverConns + 1), true); + else + startServer(serverPorts[i], serverConns, true); + } + startClient(false); + } else { + startClient(true); + for (int i = 0; i < serverPorts.length; i++) { + if (i < remainingConns) + startServer(serverPorts[i], (serverConns + 1), false); + else + startServer(serverPorts[i], serverConns, false); + } } + } catch (Exception e) { + startException = e; } /* * Wait for other side to close down. */ if (separateServerThread) { - serverThread.join(); + if (serverThread != null) { + serverThread.join(); + } } else { - clientThread.join(); + if (clientThread != null) { + clientThread.join(); + } } /* * When we get here, the test is pretty much over. - * - * If the main thread excepted, that propagates back - * immediately. If the other thread threw an exception, we - * should report back. + * Which side threw the error? */ - if (serverException != null) - throw serverException; - if (clientException != null) - throw clientException; + Exception local; + Exception remote; + + if (separateServerThread) { + remote = serverException; + local = clientException; + } else { + remote = clientException; + local = serverException; + } + + Exception exception = null; + + /* + * Check various exception conditions. + */ + if ((local != null) && (remote != null)) { + // If both failed, return the curthread's exception. + local.initCause(remote); + exception = local; + } else if (local != null) { + exception = local; + } else if (remote != null) { + exception = remote; + } else if (startException != null) { + exception = startException; + } + + /* + * If there was an exception *AND* a startException, + * output it. + */ + if (exception != null) { + if (exception != startException && startException != null) { + exception.addSuppressed(startException); + } + throw exception; + } + + // Fall-through: no exception to throw! } void startServer(final int port, final int nConns, @@ -411,7 +454,13 @@ public class SessionTimeOutTests { }; serverThread.start(); } else { - doServerSide(port, nConns); + try { + doServerSide(port, nConns); + } catch (Exception e) { + serverException = e; + } finally { + serverReady = 0; + } } } @@ -433,7 +482,11 @@ public class SessionTimeOutTests { }; clientThread.start(); } else { - doClientSide(); + try { + doClientSide(); + } catch (Exception e) { + clientException = e; + } } } } diff --git a/jdk/test/sun/security/ssl/templates/SSLSocketTemplate.java b/jdk/test/sun/security/ssl/templates/SSLSocketTemplate.java index e8bfe91db06..af9f40f77c5 100644 --- a/jdk/test/sun/security/ssl/templates/SSLSocketTemplate.java +++ b/jdk/test/sun/security/ssl/templates/SSLSocketTemplate.java @@ -243,7 +243,7 @@ public class SSLSocketTemplate { * output it. */ if (exception != null) { - if (exception != startException) { + if (exception != startException && startException != null) { exception.addSuppressed(startException); } throw exception; From 138561d596308e0126916afcd65427d218fcfe3f Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Thu, 22 Aug 2013 08:28:53 +0200 Subject: [PATCH 016/117] 8023101: java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java fails Reviewed-by: ysr --- .../management/MemoryMXBean/ResetPeakMemoryUsage.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java index 9e37d6670f4..1cc530e6541 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java +++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java @@ -33,10 +33,10 @@ * @author Mandy Chung * * @build ResetPeakMemoryUsage MemoryUtil - * @run main/othervm -XX:+UseSerialGC -XX:MarkSweepAlwaysCompactCount=1 -Xmn8m ResetPeakMemoryUsage - * @run main/othervm -XX:+UseConcMarkSweepGC -Xmn8m ResetPeakMemoryUsage - * @run main/othervm -XX:+UseParallelGC -Xmn8m ResetPeakMemoryUsage - * @run main/othervm -XX:+UseG1GC -Xmn8m -XX:G1HeapRegionSize=1m ResetPeakMemoryUsage + * @run main/othervm -XX:+PrintGCDetails -XX:+UseSerialGC -Xms256m -XX:MarkSweepAlwaysCompactCount=1 -Xmn8m ResetPeakMemoryUsage + * @run main/othervm -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -Xms256m -Xmn8m ResetPeakMemoryUsage + * @run main/othervm -XX:+PrintGCDetails -XX:+UseParallelGC -Xms256m -Xmn8m ResetPeakMemoryUsage + * @run main/othervm -XX:+PrintGCDetails -XX:+UseG1GC -Xms256m -Xmn8m -XX:G1HeapRegionSize=1m ResetPeakMemoryUsage */ import java.lang.management.*; From b3961cb6be42c942bc00dd1332a99c15ef43a4c5 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Thu, 22 Aug 2013 09:40:36 -0700 Subject: [PATCH 017/117] 8023587: Fix lone remaining doclint issue in java.util.regex Reviewed-by: jjg --- jdk/src/share/classes/java/util/regex/Pattern.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/regex/Pattern.java b/jdk/src/share/classes/java/util/regex/Pattern.java index d7b800e3258..4eedd34c72a 100644 --- a/jdk/src/share/classes/java/util/regex/Pattern.java +++ b/jdk/src/share/classes/java/util/regex/Pattern.java @@ -219,7 +219,7 @@ import java.util.stream.StreamSupport; * *   * Classes for Unicode scripts, blocks, categories and binary properties - * * {@code \p{IsLatin}} + * {@code \p{IsLatin}} * A Latin script character (
script) * {@code \p{InGreek}} * A character in the Greek block (block) From 31584b6b19d1565c35d0ce4fe4fb2adc3b92f533 Mon Sep 17 00:00:00 2001 From: Dan Xu Date: Thu, 22 Aug 2013 11:43:18 -0700 Subject: [PATCH 018/117] 8023430: Replace File.mkdirs with Files.createDirectories to get MaxPathLength.java failure details Reviewed-by: alanb --- jdk/test/ProblemList.txt | 2 +- jdk/test/java/io/File/MaxPathLength.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index ab2eac5ecbd..1f594fe3d3b 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -208,7 +208,7 @@ sun/net/www/http/HttpClient/ProxyTest.java generic-all # jdk_io # 7160013 -java/io/File/MaxPathLength.java windows-all +#java/io/File/MaxPathLength.java windows-all ############################################################################ diff --git a/jdk/test/java/io/File/MaxPathLength.java b/jdk/test/java/io/File/MaxPathLength.java index 4111550bbd2..7ec379cf1d1 100644 --- a/jdk/test/java/io/File/MaxPathLength.java +++ b/jdk/test/java/io/File/MaxPathLength.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, 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 @@ -27,6 +27,7 @@ */ import java.io.*; +import java.nio.file.Files; public class MaxPathLength { private static String sep = File.separator; @@ -87,10 +88,8 @@ public class MaxPathLength { System.err.println("Warning: Test directory structure exists already!"); return; } - boolean couldMakeTestDirectory = dirFile.mkdirs(); - if (!couldMakeTestDirectory) { - throw new RuntimeException ("Could not create test directory structure"); - } + Files.createDirectories(dirFile.toPath()); + try { if (tryAbsolute) dirFile = new File(dirFile.getCanonicalPath()); From 75a8f58cd15ecb61864255a403935cfe5e4305c8 Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Tue, 20 Aug 2013 14:13:59 +0200 Subject: [PATCH 019/117] 8022721: AnnotationTypeDeadlockTest.java throws java.lang.IllegalStateException: unexpected condition Reviewed-by: alanb, jfranck --- .../AnnotationTypeDeadlockTest.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java b/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java index 65d171adf43..f60c33525a8 100644 --- a/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java +++ b/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java @@ -28,6 +28,9 @@ */ import java.lang.annotation.Retention; +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadInfo; +import java.lang.management.ThreadMXBean; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; @@ -66,17 +69,6 @@ public class AnnotationTypeDeadlockTest { } } - static void dumpState(Task task) { - System.err.println( - "Task[" + task.getName() + "].state: " + - task.getState() + " ..." - ); - for (StackTraceElement ste : task.getStackTrace()) { - System.err.println("\tat " + ste); - } - System.err.println(); - } - public static void main(String[] args) throws Exception { CountDownLatch prepareLatch = new CountDownLatch(2); AtomicInteger goLatch = new AtomicInteger(1); @@ -88,18 +80,22 @@ public class AnnotationTypeDeadlockTest { prepareLatch.await(); // let them go goLatch.set(0); - // attempt to join them - taskA.join(5000L); - taskB.join(5000L); - - if (taskA.isAlive() || taskB.isAlive()) { - dumpState(taskA); - dumpState(taskB); - throw new IllegalStateException( - taskA.getState() == Thread.State.BLOCKED && - taskB.getState() == Thread.State.BLOCKED - ? "deadlock detected" - : "unexpected condition"); + // obtain ThreadMXBean + ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); + // wait for threads to finish or dead-lock + while (taskA.isAlive() || taskB.isAlive()) { + // attempt to join threads + taskA.join(500L); + taskB.join(500L); + // detect dead-lock + long[] deadlockedIds = threadBean.findMonitorDeadlockedThreads(); + if (deadlockedIds != null && deadlockedIds.length > 0) { + StringBuilder sb = new StringBuilder("deadlock detected:\n\n"); + for (ThreadInfo ti : threadBean.getThreadInfo(deadlockedIds, Integer.MAX_VALUE)) { + sb.append(ti); + } + throw new IllegalStateException(sb.toString()); + } } } } From b2e2be304684bc50b36ea7e53bf7844521cf91cd Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 20 Aug 2013 17:44:35 -0700 Subject: [PATCH 020/117] 8023433: Improve 'make help' Reviewed-by: tbell --- NewMakefile.gmk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewMakefile.gmk b/NewMakefile.gmk index 101ebe06278..4ddbc89c841 100644 --- a/NewMakefile.gmk +++ b/NewMakefile.gmk @@ -98,6 +98,7 @@ help: $(info . # corba and jdk) $(info . make all # Compile everything, all repos and images) $(info . make images # Create complete j2sdk and j2re images) + $(info . make docs # Create javadocs) $(info . make overlay-images # Create limited images for sparc 64 bit platforms) $(info . make profiles # Create complete j2re compact profile images) $(info . make bootcycle-images # Build images twice, second time with newly build JDK) @@ -109,7 +110,7 @@ help: $(info . make test # Run tests, default is all tests (see TEST below)) $(info ) $(info Targets for specific components) - $(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, images or overlay-images)) + $(info (Component is any of langtools, corba, jaxp, jaxws, hotspot, jdk, nashorn, images, overlay-images, docs or test)) $(info . make # Build and everything it depends on. ) $(info . make -only # Build only, without dependencies. This) $(info . # is faster but can result in incorrect build results!) From 1e740c466f8264e4538c1a1134db49486cdfba01 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Wed, 21 Aug 2013 13:18:52 +0200 Subject: [PATCH 021/117] 8022808: Kitchensink hangs on macos Use pthread_mach_thread_np() instead of mach_thread_self() to avoid leaking resources Reviewed-by: dholmes, rbackman --- hotspot/src/os/bsd/vm/os_bsd.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 55043ad243a..cc6d13e2c1d 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -642,13 +642,14 @@ objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NU #endif #ifdef __APPLE__ -static uint64_t locate_unique_thread_id() { +static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) { // Additional thread_id used to correlate threads in SA thread_identifier_info_data_t m_ident_info; mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; - thread_info(::mach_thread_self(), THREAD_IDENTIFIER_INFO, + thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO, (thread_info_t) &m_ident_info, &count); + return m_ident_info.thread_id; } #endif @@ -679,9 +680,14 @@ static void *java_start(Thread *thread) { } #ifdef __APPLE__ - // thread_id is mach thread on macos - osthread->set_thread_id(::mach_thread_self()); - osthread->set_unique_thread_id(locate_unique_thread_id()); + // thread_id is mach thread on macos, which pthreads graciously caches and provides for us + mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self()); + guarantee(thread_id != 0, "thread id missing from pthreads"); + osthread->set_thread_id(thread_id); + + uint64_t unique_thread_id = locate_unique_thread_id(thread_id); + guarantee(unique_thread_id != 0, "unique thread id was not found"); + osthread->set_unique_thread_id(unique_thread_id); #else // thread_id is pthread_id on BSD osthread->set_thread_id(::pthread_self()); @@ -843,8 +849,14 @@ bool os::create_attached_thread(JavaThread* thread) { // Store pthread info into the OSThread #ifdef __APPLE__ - osthread->set_thread_id(::mach_thread_self()); - osthread->set_unique_thread_id(locate_unique_thread_id()); + // thread_id is mach thread on macos, which pthreads graciously caches and provides for us + mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self()); + guarantee(thread_id != 0, "just checking"); + osthread->set_thread_id(thread_id); + + uint64_t unique_thread_id = locate_unique_thread_id(thread_id); + guarantee(unique_thread_id != 0, "just checking"); + osthread->set_unique_thread_id(unique_thread_id); #else osthread->set_thread_id(::pthread_self()); #endif @@ -1115,7 +1127,7 @@ size_t os::lasterror(char *buf, size_t len) { intx os::current_thread_id() { #ifdef __APPLE__ - return (intx)::mach_thread_self(); + return (intx)::pthread_mach_thread_np(::pthread_self()); #else return (intx)::pthread_self(); #endif From 6db516232b4e0ffba6327106dc3b3987f397001b Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Wed, 21 Aug 2013 13:39:09 +0200 Subject: [PATCH 022/117] 8023373: allow super invocation for adapters Reviewed-by: lagergren, sundar --- .../linker/JavaAdapterBytecodeGenerator.java | 92 ++++++++++++++----- nashorn/test/script/basic/JDK-8023373.js | 84 +++++++++++++++++ .../test/script/basic/JDK-8023373.js.EXPECTED | 10 ++ 3 files changed, 161 insertions(+), 25 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8023373.js create mode 100644 nashorn/test/script/basic/JDK-8023373.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java index efbf7cf623e..62e529bb89f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java @@ -173,6 +173,9 @@ final class JavaAdapterBytecodeGenerator { private static final String CLASS_INIT = ""; private static final String STATIC_GLOBAL_FIELD_NAME = "staticGlobal"; + // Method name prefix for invoking super-methods + private static final String SUPER_PREFIX = "super$"; + /** * Collection of methods we never override: Object.clone(), Object.finalize(). */ @@ -240,6 +243,7 @@ final class JavaAdapterBytecodeGenerator { } generateConstructors(); generateMethods(); + generateSuperMethods(); // } cw.visitEnd(); } @@ -507,6 +511,10 @@ final class JavaAdapterBytecodeGenerator { private static void endInitMethod(final InstructionAdapter mv) { mv.visitInsn(RETURN); + endMethod(mv); + } + + private static void endMethod(final InstructionAdapter mv) { mv.visitMaxs(0, 0); mv.visitEnd(); } @@ -603,13 +611,8 @@ final class JavaAdapterBytecodeGenerator { */ private void generateMethod(final MethodInfo mi) { final Method method = mi.method; - final int mod = method.getModifiers(); - final int access = ACC_PUBLIC | (method.isVarArgs() ? ACC_VARARGS : 0); final Class[] exceptions = method.getExceptionTypes(); - final String[] exceptionNames = new String[exceptions.length]; - for (int i = 0; i < exceptions.length; ++i) { - exceptionNames[i] = Type.getInternalName(exceptions[i]); - } + final String[] exceptionNames = getExceptionNames(exceptions); final MethodType type = mi.type; final String methodDesc = type.toMethodDescriptorString(); final String name = mi.getName(); @@ -617,14 +620,8 @@ final class JavaAdapterBytecodeGenerator { final Type asmType = Type.getMethodType(methodDesc); final Type[] asmArgTypes = asmType.getArgumentTypes(); - // Determine the first index for a local variable - int nextLocalVar = 1; // this - for(final Type t: asmArgTypes) { - nextLocalVar += t.getSize(); - } - - final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(access, name, methodDesc, null, - exceptionNames)); + final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(getAccessModifiers(method), name, + methodDesc, null, exceptionNames)); mv.visitCode(); final Label instanceHandleDefined = new Label(); @@ -646,7 +643,7 @@ final class JavaAdapterBytecodeGenerator { } // No handle is available, fall back to default behavior - if(Modifier.isAbstract(mod)) { + if(Modifier.isAbstract(method.getModifiers())) { // If the super method is abstract, throw an exception mv.anew(UNSUPPORTED_OPERATION_TYPE); mv.dup(); @@ -654,14 +651,7 @@ final class JavaAdapterBytecodeGenerator { mv.athrow(); } else { // If the super method is not abstract, delegate to it. - mv.visitVarInsn(ALOAD, 0); - int nextParam = 1; - for(final Type t: asmArgTypes) { - mv.load(nextParam, t); - nextParam += t.getSize(); - } - mv.invokespecial(superClassName, name, methodDesc); - mv.areturn(asmReturnType); + emitSuperCall(mv, name, methodDesc); } final Label setupGlobal = new Label(); @@ -685,6 +675,12 @@ final class JavaAdapterBytecodeGenerator { // stack: [creatingGlobal, someHandle] mv.visitLabel(setupGlobal); + // Determine the first index for a local variable + int nextLocalVar = 1; // "this" is at 0 + for(final Type t: asmArgTypes) { + nextLocalVar += t.getSize(); + } + // Set our local variable indices final int currentGlobalVar = nextLocalVar++; final int globalsDifferVar = nextLocalVar++; @@ -775,8 +771,7 @@ final class JavaAdapterBytecodeGenerator { } mv.visitTryCatchBlock(tryBlockStart, tryBlockEnd, throwableHandler, THROWABLE_TYPE_NAME); } - mv.visitMaxs(0, 0); - mv.visitEnd(); + endMethod(mv); } /** @@ -817,6 +812,53 @@ final class JavaAdapterBytecodeGenerator { return false; } + private void generateSuperMethods() { + for(final MethodInfo mi: methodInfos) { + if(!Modifier.isAbstract(mi.method.getModifiers())) { + generateSuperMethod(mi); + } + } + } + + private void generateSuperMethod(MethodInfo mi) { + final Method method = mi.method; + + final String methodDesc = mi.type.toMethodDescriptorString(); + final String name = mi.getName(); + + final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(getAccessModifiers(method), + SUPER_PREFIX + name, methodDesc, null, getExceptionNames(method.getExceptionTypes()))); + mv.visitCode(); + + emitSuperCall(mv, name, methodDesc); + + endMethod(mv); + } + + private void emitSuperCall(final InstructionAdapter mv, final String name, final String methodDesc) { + mv.visitVarInsn(ALOAD, 0); + int nextParam = 1; + final Type methodType = Type.getMethodType(methodDesc); + for(final Type t: methodType.getArgumentTypes()) { + mv.load(nextParam, t); + nextParam += t.getSize(); + } + mv.invokespecial(superClassName, name, methodDesc); + mv.areturn(methodType.getReturnType()); + } + + private static String[] getExceptionNames(final Class[] exceptions) { + final String[] exceptionNames = new String[exceptions.length]; + for (int i = 0; i < exceptions.length; ++i) { + exceptionNames[i] = Type.getInternalName(exceptions[i]); + } + return exceptionNames; + } + + private static int getAccessModifiers(final Method method) { + return ACC_PUBLIC | (method.isVarArgs() ? ACC_VARARGS : 0); + } + /** * Gathers methods that can be implemented or overridden from the specified type into this factory's * {@link #methodInfos} set. It will add all non-final, non-static methods that are either public or protected from diff --git a/nashorn/test/script/basic/JDK-8023373.js b/nashorn/test/script/basic/JDK-8023373.js new file mode 100644 index 00000000000..1a01982020f --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023373.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023373: allow super invocation for adapters + * + * @test + * @run + */ + +var CharArray = Java.type("char[]") +var jString = Java.type("java.lang.String") +var Character = Java.type("java.lang.Character") + +function capitalize(s) { + if(s instanceof CharArray) { + return new jString(s).toUpperCase() + } + if(s instanceof jString) { + return s.toUpperCase() + } + return Character.toUpperCase(s) // must be int +} + +var sw = new (Java.type("java.io.StringWriter")) + +var FilterWriterAdapter = Java.extend(Java.type("java.io.FilterWriter")) + +var cw = new FilterWriterAdapter(sw) { + write: function(s, off, len) { + s = capitalize(s) + // Must handle overloads by arity + if(off === undefined) { + cw.super$write(s, 0, s.length()) + } else if (typeof s === "string") { + cw.super$write(s, off, len) + } + } +} + +cw.write("abcd") +cw.write("e".charAt(0)) +cw.write("fgh".toCharArray()) +cw.write("**ijk**", 2, 3) +cw.write("***lmno**".toCharArray(), 3, 4) +cw.flush() +print(sw) + +// Can invoke super for Object methods +print("cw has super hashCode(): " + (typeof cw.super$hashCode === "function")) +print("cw has super equals(): " + (typeof cw.super$equals === "function")) +// Can't invoke super for final methods +print("cw has no super getClass(): " + (typeof cw.super$getClass === "undefined")) +print("cw has no super wait(): " + (typeof cw.super$wait === "undefined")) + +var r = new (Java.type("java.lang.Runnable"))(function() {}) +// Can't invoke super for abstract methods +print("r has no super run(): " + (typeof r.super$run === "undefined")) +// Interfaces can also invoke super Object methods +print("r has super hashCode(): " + (typeof r.super$hashCode === "function")) +print("r has super equals(): " + (typeof r.super$equals === "function")) +// But still can't invoke final methods +print("r has no super getClass(): " + (typeof r.super$getClass === "undefined")) +print("r has no super wait(): " + (typeof r.super$wait === "undefined")) diff --git a/nashorn/test/script/basic/JDK-8023373.js.EXPECTED b/nashorn/test/script/basic/JDK-8023373.js.EXPECTED new file mode 100644 index 00000000000..765eff267c4 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023373.js.EXPECTED @@ -0,0 +1,10 @@ +ABCDEFGHIJKLMNO +cw has super hashCode(): true +cw has super equals(): true +cw has no super getClass(): true +cw has no super wait(): true +r has no super run(): true +r has super hashCode(): true +r has super equals(): true +r has no super getClass(): true +r has no super wait(): true From 00099d7de244cc41b6bef1852e2f81c001fce596 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Wed, 21 Aug 2013 13:39:40 +0200 Subject: [PATCH 023/117] 8022903: Enhance for-in and for-each for Lists and Maps Reviewed-by: lagergren, sundar --- .../internal/runtime/ScriptRuntime.java | 82 +++++++++++++------ nashorn/test/script/basic/JDK-8022903.js | 55 +++++++++++++ .../test/script/basic/JDK-8022903.js.EXPECTED | 12 +++ 3 files changed, 122 insertions(+), 27 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8022903.js create mode 100644 nashorn/test/script/basic/JDK-8022903.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java index 53c4d4fee78..05ccc9f2876 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java @@ -37,7 +37,9 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.Array; import java.util.Collections; import java.util.Iterator; +import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; import jdk.internal.dynalink.beans.StaticClass; @@ -221,49 +223,71 @@ public final class ScriptRuntime { } /** - * Used to determine property iterator used in for in. - * @param obj Object to iterate on. - * @return Iterator. + * Returns an iterator over property identifiers used in the {@code for...in} statement. Note that the ECMAScript + * 5.1 specification, chapter 12.6.4. uses the terminology "property names", which seems to imply that the property + * identifiers are expected to be strings, but this is not actually spelled out anywhere, and Nashorn will in some + * cases deviate from this. Namely, we guarantee to always return an iterator over {@link String} values for any + * built-in JavaScript object. We will however return an iterator over {@link Integer} objects for native Java + * arrays and {@link List} objects, as well as arbitrary objects representing keys of a {@link Map}. Therefore, the + * expression {@code typeof i} within a {@code for(i in obj)} statement can return something other than + * {@code string} when iterating over native Java arrays, {@code List}, and {@code Map} objects. + * @param obj object to iterate on. + * @return iterator over the object's property names. */ - public static Iterator toPropertyIterator(final Object obj) { + public static Iterator toPropertyIterator(final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).propertyIterator(); } if (obj != null && obj.getClass().isArray()) { - final int length = Array.getLength(obj); - - return new Iterator() { - private int index = 0; - - @Override - public boolean hasNext() { - return index < length; - } - - @Override - public String next() { - return "" + index++; //TODO numeric property iterator? - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; + return new RangeIterator(Array.getLength(obj)); } if (obj instanceof ScriptObjectMirror) { return ((ScriptObjectMirror)obj).keySet().iterator(); } + if (obj instanceof List) { + return new RangeIterator(((List)obj).size()); + } + + if (obj instanceof Map) { + return ((Map)obj).keySet().iterator(); + } + return Collections.emptyIterator(); } + private static final class RangeIterator implements Iterator { + private final int length; + private int index; + + RangeIterator(int length) { + this.length = length; + } + + @Override + public boolean hasNext() { + return index < length; + } + + @Override + public Integer next() { + return index++; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + } + /** - * Used to determine property value iterator used in for each in. - * @param obj Object to iterate on. - * @return Iterator. + * Returns an iterator over property values used in the {@code for each...in} statement. Aside from built-in JS + * objects, it also operates on Java arrays, any {@link Iterable}, as well as on {@link Map} objects, iterating over + * map values. + * @param obj object to iterate on. + * @return iterator over the object's property values. */ public static Iterator toValueIterator(final Object obj) { if (obj instanceof ScriptObject) { @@ -301,6 +325,10 @@ public final class ScriptRuntime { return ((ScriptObjectMirror)obj).values().iterator(); } + if (obj instanceof Map) { + return ((Map)obj).values().iterator(); + } + if (obj instanceof Iterable) { return ((Iterable)obj).iterator(); } diff --git a/nashorn/test/script/basic/JDK-8022903.js b/nashorn/test/script/basic/JDK-8022903.js new file mode 100644 index 00000000000..1733c51a4fa --- /dev/null +++ b/nashorn/test/script/basic/JDK-8022903.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8022903: Enhance for-in and for-each for Lists and Maps + * + * @test + * @run + */ + +var colors = new java.util.ArrayList() +colors.add("red") +colors.add("purple") +colors.add("pink") + +for(var index in colors) { + print("colors[" + index + "]=" + colors[index]) +} + +for each(var color in colors) { + print(color) +} + +var capitals = new java.util.LinkedHashMap() +capitals.Sweden = "Stockholm" +capitals.Hungary = "Budapet" +capitals.Croatia = "Zagreb" + +for(var key in capitals) { + print("capital of " + key + " is " + capitals[key]) +} + +for each(var capital in capitals) { + print(capital) +} diff --git a/nashorn/test/script/basic/JDK-8022903.js.EXPECTED b/nashorn/test/script/basic/JDK-8022903.js.EXPECTED new file mode 100644 index 00000000000..8d64baeb0c7 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8022903.js.EXPECTED @@ -0,0 +1,12 @@ +colors[0]=red +colors[1]=purple +colors[2]=pink +red +purple +pink +capital of Sweden is Stockholm +capital of Hungary is Budapet +capital of Croatia is Zagreb +Stockholm +Budapet +Zagreb From 2bb4ab07cab8d4cc7756bfb80a70aace7c0b91fd Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 21 Aug 2013 17:28:53 +0530 Subject: [PATCH 024/117] 8023368: Instance __proto__ property should exist and be writable Reviewed-by: attila, hannesw --- .../api/scripting/ScriptObjectMirror.java | 13 ++++ .../internal/objects/NativeObject.java | 24 +++++- .../internal/runtime/PropertyListener.java | 9 +++ .../runtime/PropertyListenerManager.java | 20 +++++ .../nashorn/internal/runtime/PropertyMap.java | 23 +++++- .../internal/runtime/ScriptEnvironment.java | 4 - .../internal/runtime/ScriptObject.java | 15 ++++ .../runtime/resources/Messages.properties | 2 + .../runtime/resources/Options.properties | 9 --- .../runtime/resources/mozilla_compat.js | 2 +- nashorn/test/script/basic/JDK-8023368.js | 73 +++++++++++++++++++ .../test/script/basic/JDK-8023368.js.EXPECTED | 18 +++++ nashorn/test/script/basic/JDK-8023368_2.js | 73 +++++++++++++++++++ .../script/basic/JDK-8023368_2.js.EXPECTED | 18 +++++ nashorn/test/script/basic/circular_proto.js | 46 ++++++++++++ .../script/basic/circular_proto.js.EXPECTED | 1 + .../test/script/basic/mirror_proto_assign.js | 52 +++++++++++++ .../basic/mirror_proto_assign.js.EXPECTED | 2 + .../basic/nonextensible_proto_assign.js | 44 +++++++++++ .../nonextensible_proto_assign.js.EXPECTED | 1 + 20 files changed, 433 insertions(+), 16 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8023368.js create mode 100644 nashorn/test/script/basic/JDK-8023368.js.EXPECTED create mode 100644 nashorn/test/script/basic/JDK-8023368_2.js create mode 100644 nashorn/test/script/basic/JDK-8023368_2.js.EXPECTED create mode 100644 nashorn/test/script/basic/circular_proto.js create mode 100644 nashorn/test/script/basic/circular_proto.js.EXPECTED create mode 100644 nashorn/test/script/basic/mirror_proto_assign.js create mode 100644 nashorn/test/script/basic/mirror_proto_assign.js.EXPECTED create mode 100644 nashorn/test/script/basic/nonextensible_proto_assign.js create mode 100644 nashorn/test/script/basic/nonextensible_proto_assign.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index fd2ef88a199..dbdb9b67bd5 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -373,6 +373,19 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { }); } + /** + * Set the __proto__ of this object. + * @param proto new proto for this object + */ + public void setProto(final Object proto) { + inGlobal(new Callable() { + @Override public Void call() { + sobj.setProtoCheck(unwrap(proto, global)); + return null; + } + }); + } + /** * ECMA 8.12.1 [[GetOwnProperty]] (P) * diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java index 537ae1ffcc5..932f328bff6 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java @@ -124,6 +124,28 @@ public final class NativeObject { } } + /** + * Nashorn extension: Object.setPrototypeOf ( O, proto ) + * Also found in ES6 draft specification. + * + * @param self self reference + * @param obj object to set prototype for + * @param proto prototype object to be used + * @return object whose prototype is set + */ + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) + public static Object setPrototypeOf(final Object self, final Object obj, final Object proto) { + if (obj instanceof ScriptObject) { + ((ScriptObject)obj).setProtoCheck(proto); + return obj; + } else if (obj instanceof ScriptObjectMirror) { + ((ScriptObjectMirror)obj).setProto(proto); + return obj; + } + + throw notAnObject(obj); + } + /** * ECMA 15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) * @@ -184,7 +206,7 @@ public final class NativeObject { // FIXME: should we create a proper object with correct number of // properties? final ScriptObject newObj = Global.newEmptyInstance(); - newObj.setProtoCheck(proto); + newObj.setProto((ScriptObject)proto); if (props != UNDEFINED) { NativeObject.defineProperties(self, newObj, props); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListener.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListener.java index 867ac73d1b4..307d58b4f7d 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListener.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListener.java @@ -54,4 +54,13 @@ public interface PropertyListener { * */ public void propertyModified(ScriptObject object, Property oldProp, Property newProp); + + /** + * Given object's __proto__ has changed. + * + * @param object object whose __proto__ has changed. + * @param oldProto old __proto__ + * @param newProto new __proto__ + */ + public void protoChanged(ScriptObject object, ScriptObject oldProto, ScriptObject newProto); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListenerManager.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListenerManager.java index dc1426d827c..27ec2c97438 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListenerManager.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListenerManager.java @@ -140,6 +140,21 @@ public class PropertyListenerManager implements PropertyListener { } } + /** + * This method can be called to notify __proto__ modification to this object's listeners. + * + * @param object The ScriptObject whose __proto__ was changed. + * @param oldProto old __proto__ + * @param newProto new __proto__ + */ + protected synchronized final void notifyProtoChanged(final ScriptObject object, final ScriptObject oldProto, final ScriptObject newProto) { + if (listeners != null) { + for (PropertyListener listener : listeners.keySet()) { + listener.protoChanged(object, oldProto, newProto); + } + } + } + // PropertyListener methods @Override @@ -156,4 +171,9 @@ public class PropertyListenerManager implements PropertyListener { public final void propertyModified(final ScriptObject object, final Property oldProp, final Property newProp) { notifyPropertyModified(object, oldProp, newProp); } + + @Override + public final void protoChanged(final ScriptObject object, final ScriptObject oldProto, final ScriptObject newProto) { + notifyProtoChanged(object, oldProto, newProto); + } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java index 64f4b449079..e24364d6f03 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java @@ -230,7 +230,7 @@ public final class PropertyMap implements Iterable, PropertyListener { } /** - * Indicate that a prototype property hash changed. + * Indicate that a prototype property has changed. * * @param property {@link Property} to invalidate. */ @@ -250,6 +250,18 @@ public final class PropertyMap implements Iterable, PropertyListener { } } + /** + * Indicate that proto itself has changed in hierachy somewhere. + */ + private void invalidateAllProtoGetSwitchPoints() { + assert !isShared() : "proto invalidation on a shared PropertyMap"; + + if (protoGetSwitches != null) { + final Collection sws = protoGetSwitches.values(); + SwitchPoint.invalidateAll(sws.toArray(new SwitchPoint[sws.size()])); + } + } + /** * Add a property to the map, re-binding its getters and setters, * if available, to a given receiver. This is typically the global scope. See @@ -878,6 +890,15 @@ public final class PropertyMap implements Iterable, PropertyListener { invalidateProtoGetSwitchPoint(oldProp); } + @Override + public void protoChanged(final ScriptObject object, final ScriptObject oldProto, final ScriptObject newProto) { + // We may walk and invalidate SwitchPoints for properties inherited + // from 'object' or it's old proto chain. But, it may not be worth it. + // For example, a new proto may have a user defined getter/setter for + // a data property down the chain. So, invalidating all is better. + invalidateAllProtoGetSwitchPoints(); + } + /* * Debugging and statistics. */ diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java index a2f1f4a0880..8ab6af48ab1 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java @@ -128,9 +128,6 @@ public final class ScriptEnvironment { /** Do not support typed arrays. */ public final boolean _no_typed_arrays; - /** Package to which generated class files are added */ - public final String _package; - /** Only parse the source code, do not compile */ public final boolean _parse_only; @@ -216,7 +213,6 @@ public final class ScriptEnvironment { _no_java = options.getBoolean("no.java"); _no_syntax_extensions = options.getBoolean("no.syntax.extensions"); _no_typed_arrays = options.getBoolean("no.typed.arrays"); - _package = options.getString("package"); _parse_only = options.getBoolean("parse.only"); _print_ast = options.getBoolean("print.ast"); _print_lower_ast = options.getBoolean("print.lower.ast"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 1087005b992..481a708bcb7 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -1129,6 +1129,9 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr proto = newProto; if (isPrototype()) { + // tell listeners that my __proto__ has been changed + notifyProtoChanged(this, oldProto, newProto); + if (oldProto != null) { oldProto.removePropertyListener(this); } @@ -1144,7 +1147,19 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr * @param newProto Prototype to set. */ public final void setProtoCheck(final Object newProto) { + if (!isExtensible()) { + throw typeError("__proto__.set.non.extensible", ScriptRuntime.safeToString(this)); + } + if (newProto == null || newProto instanceof ScriptObject) { + // check for circularity + ScriptObject proto = (ScriptObject)newProto; + while (proto != null) { + if (proto == this) { + throw typeError("circular.__proto__.set", ScriptRuntime.safeToString(this)); + } + proto = proto.getProto(); + } setProto((ScriptObject)newProto); } else { final ScriptObject global = Context.getGlobalTrusted(); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties index dadde63756f..68f68c0a25b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties @@ -94,6 +94,8 @@ type.error.cant.delete.property=Cannot delete property "{0}" of {1} type.error.cant.redefine.property=Cannot redefine property "{0}" of {1} type.error.property.not.writable="{0}" is not a writable property of {1} type.error.object.non.extensible=Cannot add new property "{0}" to non-extensible {1} +type.error.__proto__.set.non.extensible=Cannot set __proto__ of non-extensible {0} +type.error.circular.__proto__.set=Cannot create__proto__ cycle for {0} # miscellaneous type.error.regex.cant.supply.flags=Cannot supply flags when constructing one RegExp from another diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties index 452ae88c928..e3510fa1004 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties @@ -216,15 +216,6 @@ nashorn.option.no.typed.arrays = { \ default=false \ } -nashorn.option.package = { \ - name="--package", \ - is_undocumented=true, \ - desc="Package to which generated .class files are added.", \ - params="", \ - type=String, \ - default="" \ -} - nashorn.option.parse.only = { \ name="--parse-only", \ is_undocumented=true, \ diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js b/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js index 8a9fcc7de0c..60bdc7b1ab0 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js @@ -144,7 +144,7 @@ Object.defineProperty(Object.prototype, "__proto__", { return Object.getPrototypeOf(this); }, set: function(x) { - throw new TypeError("__proto__ set not supported"); + Object.setPrototypeOf(this, x); } }); diff --git a/nashorn/test/script/basic/JDK-8023368.js b/nashorn/test/script/basic/JDK-8023368.js new file mode 100644 index 00000000000..9f32805caa8 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023368.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023368: Instance __proto__ property should exist and be writable. + * + * @test + * @run + */ + +load("nashorn:mozilla_compat.js"); + +// function to force same callsites +function check(obj) { + print(obj.func()); + print(obj.x); + print(obj.toString()); +} + +function Func() { +} + +Func.prototype.func = function() { + return "Func.prototype.func"; +} + +Func.prototype.x = "hello"; + +var obj = new Func(); +var obj2 = Object.create(obj); + +// check direct and indirect __proto__ change +check(obj); +check(obj2); +obj.__proto__ = { + func: function() { + return "obj.__proto__.func @ " + __LINE__; + }, + x: 344 +}; + +check(obj); +check(obj2); + +// check indirect (1 and 2 levels) __proto__ function change +obj.__proto__.__proto__ = { + toString: function() { + return "new object.toString"; + } +}; + +check(obj); +check(obj2); diff --git a/nashorn/test/script/basic/JDK-8023368.js.EXPECTED b/nashorn/test/script/basic/JDK-8023368.js.EXPECTED new file mode 100644 index 00000000000..4ca8d077d38 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023368.js.EXPECTED @@ -0,0 +1,18 @@ +Func.prototype.func +hello +[object Object] +Func.prototype.func +hello +[object Object] +obj.__proto__.func @ 57 +344 +[object Object] +obj.__proto__.func @ 57 +344 +[object Object] +obj.__proto__.func @ 57 +344 +new object.toString +obj.__proto__.func @ 57 +344 +new object.toString diff --git a/nashorn/test/script/basic/JDK-8023368_2.js b/nashorn/test/script/basic/JDK-8023368_2.js new file mode 100644 index 00000000000..4999de1d89e --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023368_2.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023368: Instance __proto__ property should exist and be writable. + * + * @test + * @run + */ + +// check Object.setPrototypeOf extension rather than using __proto__ + +// function to force same callsites +function check(obj) { + print(obj.func()); + print(obj.x); + print(obj.toString()); +} + +function Func() { +} + +Func.prototype.func = function() { + return "Func.prototype.func"; +} + +Func.prototype.x = "hello"; + +var obj = new Func(); +var obj2 = Object.create(obj); + +// check direct and indirect __proto__ change +check(obj); +check(obj2); +Object.setPrototypeOf(obj, { + func: function() { + return "obj.__proto__.func @ " + __LINE__; + }, + x: 344 +}); + +check(obj); +check(obj2); + +// check indirect (1 and 2 levels) __proto__ function change +Object.setPrototypeOf(Object.getPrototypeOf(obj), { + toString: function() { + return "new object.toString"; + } +}); + +check(obj); +check(obj2); diff --git a/nashorn/test/script/basic/JDK-8023368_2.js.EXPECTED b/nashorn/test/script/basic/JDK-8023368_2.js.EXPECTED new file mode 100644 index 00000000000..4ca8d077d38 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023368_2.js.EXPECTED @@ -0,0 +1,18 @@ +Func.prototype.func +hello +[object Object] +Func.prototype.func +hello +[object Object] +obj.__proto__.func @ 57 +344 +[object Object] +obj.__proto__.func @ 57 +344 +[object Object] +obj.__proto__.func @ 57 +344 +new object.toString +obj.__proto__.func @ 57 +344 +new object.toString diff --git a/nashorn/test/script/basic/circular_proto.js b/nashorn/test/script/basic/circular_proto.js new file mode 100644 index 00000000000..5ae8f9cd03b --- /dev/null +++ b/nashorn/test/script/basic/circular_proto.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023368: Instance __proto__ property should exist and be writable. + * + * @test + * @run + */ + +// check that we cannot create __proto__ cycle +load("nashorn:mozilla_compat.js"); + +var obj = {}; +var obj2 = Object.create(obj); + +// attempt to create __proto__ cycle +try { + obj.__proto__ = obj2; + fail("Should have thrown TypeError"); +} catch (e) { + if (! (e instanceof TypeError)) { + fail("Expected TypeError, got " + e); + } + print(e); +} diff --git a/nashorn/test/script/basic/circular_proto.js.EXPECTED b/nashorn/test/script/basic/circular_proto.js.EXPECTED new file mode 100644 index 00000000000..66b541b6dfc --- /dev/null +++ b/nashorn/test/script/basic/circular_proto.js.EXPECTED @@ -0,0 +1 @@ +TypeError: Cannot create__proto__ cycle for [object Object] diff --git a/nashorn/test/script/basic/mirror_proto_assign.js b/nashorn/test/script/basic/mirror_proto_assign.js new file mode 100644 index 00000000000..d748cbc40ca --- /dev/null +++ b/nashorn/test/script/basic/mirror_proto_assign.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023368: Instance __proto__ property should exist and be writable. + * + * @test + * @run + */ + +// check that Object.setPrototypeOf works for mirror objects as well. + +var global = loadWithNewGlobal({ + name: "test", + script: "var obj = {}; this" +}); + +var proto = global.eval("({ foo: 323 })"); + +Object.setPrototypeOf(global.obj, proto); + +function func(obj) { + // check proto inherited value + print("obj.foo = " + obj.foo); +} + +func(global.obj); + +var newProto = global.eval("({ foo: 'hello' })"); +Object.setPrototypeOf(global.obj, newProto); + +func(global.obj); diff --git a/nashorn/test/script/basic/mirror_proto_assign.js.EXPECTED b/nashorn/test/script/basic/mirror_proto_assign.js.EXPECTED new file mode 100644 index 00000000000..168d50e06f8 --- /dev/null +++ b/nashorn/test/script/basic/mirror_proto_assign.js.EXPECTED @@ -0,0 +1,2 @@ +obj.foo = 323 +obj.foo = hello diff --git a/nashorn/test/script/basic/nonextensible_proto_assign.js b/nashorn/test/script/basic/nonextensible_proto_assign.js new file mode 100644 index 00000000000..0240420d332 --- /dev/null +++ b/nashorn/test/script/basic/nonextensible_proto_assign.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023368: Instance __proto__ property should exist and be writable. + * + * @test + * @run + */ + +load("nashorn:mozilla_compat.js") + +// check that we cannot assign to __proto__ of a non-extensible object +try { + var obj = {} + Object.preventExtensions(obj); + obj.__proto__ = { }; + fail("Should have thrown TypeError"); +} catch (e) { + if (! (e instanceof TypeError)) { + fail("Expected TypeError, got " + e); + } + print(e); +} diff --git a/nashorn/test/script/basic/nonextensible_proto_assign.js.EXPECTED b/nashorn/test/script/basic/nonextensible_proto_assign.js.EXPECTED new file mode 100644 index 00000000000..d9a6c2e9a0f --- /dev/null +++ b/nashorn/test/script/basic/nonextensible_proto_assign.js.EXPECTED @@ -0,0 +1 @@ +TypeError: Cannot set __proto__ of non-extensible [object Object] From edd19c0f397d2a86a19899074dc3ff0bea88d602 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Thu, 22 Aug 2013 15:54:50 -0700 Subject: [PATCH 025/117] 8022445: fix RMISocketFactory example to avoid using localhost Reviewed-by: chegar, alanb --- .../share/classes/java/rmi/server/RMISocketFactory.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java b/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java index e7b7581820b..ec9ade2f54c 100644 --- a/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java +++ b/jdk/src/share/classes/java/rmi/server/RMISocketFactory.java @@ -50,13 +50,13 @@ import java.net.*; * @implNote *

You can use the {@code RMISocketFactory} class to create a server socket that * is bound to a specific address, restricting the origin of requests. For example, - * the following code implements a socket factory that binds server sockets to the + * the following code implements a socket factory that binds server sockets to an IPv4 * loopback address. This restricts RMI to processing requests only from the local host. * *

{@code
  *     class LoopbackSocketFactory extends RMISocketFactory {
  *         public ServerSocket createServerSocket(int port) throws IOException {
- *             return new ServerSocket(port, 5, InetAddress.getLoopbackAddress());
+ *             return new ServerSocket(port, 5, InetAddress.getByName("127.0.0.1"));
  *         }
  *
  *         public Socket createSocket(String host, int port) throws IOException {
@@ -72,8 +72,8 @@ import java.net.*;
  * }
* * Set the {@code java.rmi.server.hostname} system property - * to a host name (typically {@code localhost}) that resolves to the loopback - * interface to ensure that the generated stubs use the right network interface. + * to {@code 127.0.0.1} to ensure that the generated stubs connect to the right + * network interface. * * @author Ann Wollrath * @author Peter Jones From 422a4d5bc7ed2ed9c8324a94c78d95f061d2459e Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Wed, 21 Aug 2013 17:15:44 +0200 Subject: [PATCH 026/117] 6417649: -interval=0 is accepted and jconsole doesn't update window content at all Reviewed-by: alanb, jbachorik --- jdk/src/share/classes/sun/tools/jconsole/JConsole.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jdk/src/share/classes/sun/tools/jconsole/JConsole.java b/jdk/src/share/classes/sun/tools/jconsole/JConsole.java index 46d9504dc15..cdb78f94ec9 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/JConsole.java +++ b/jdk/src/share/classes/sun/tools/jconsole/JConsole.java @@ -858,6 +858,10 @@ public class JConsole extends JFrame try { updateInterval = Integer.parseInt(arg.substring(10)) * 1000; + if (updateInterval <= 0) { + usage(); + return; + } } catch (NumberFormatException ex) { usage(); return; From 3cd2e9e0995fe4a2f36ba8fb69f01c51c8155e6f Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Wed, 21 Aug 2013 17:17:45 +0200 Subject: [PATCH 027/117] 6359971: Threads tab: Simple text to explain that one can click on a thread to get stack trace Reviewed-by: alanb, jbachorik --- jdk/src/share/classes/sun/tools/jconsole/Messages.java | 1 + jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java | 1 + .../classes/sun/tools/jconsole/resources/messages.properties | 1 + 3 files changed, 3 insertions(+) diff --git a/jdk/src/share/classes/sun/tools/jconsole/Messages.java b/jdk/src/share/classes/sun/tools/jconsole/Messages.java index eee57adcc25..0a3a63e85ca 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/Messages.java +++ b/jdk/src/share/classes/sun/tools/jconsole/Messages.java @@ -271,6 +271,7 @@ final public class Messages { public static String THREADS; public static String THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME; public static String THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME; + public static String THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE; public static String THRESHOLD; public static String TILE; public static String TIME_RANGE_COLON; diff --git a/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java b/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java index 3932ffa145e..6cf710a2dff 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java +++ b/jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java @@ -596,6 +596,7 @@ class ThreadTab extends Tab implements ActionListener, DocumentListener, ListSel setBorder(thinEmptyBorder); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + textArea.setText(Messages.THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE); addListSelectionListener(ThreadTab.this); setCellRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties b/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties index 70ff2f16c6e..832621731b9 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties +++ b/jdk/src/share/classes/sun/tools/jconsole/resources/messages.properties @@ -229,6 +229,7 @@ SUMMARY_TAB_VM_VERSION={0} version {1} THREADS=Threads THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME=Thread Information THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME=Chart for number of threads. +THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE=[No thread selected] THRESHOLD=Threshold TILE=&Tile TIME_RANGE_COLON=&Time Range: From 4c3c3b6caacc75eec2a3bfd4b66262a9b6c2e578 Mon Sep 17 00:00:00 2001 From: Bengt Rutisson Date: Wed, 21 Aug 2013 22:35:56 +0200 Subject: [PATCH 028/117] 8022872: G1: Use correct GC cause for young GC triggered by humongous allocations Reviewed-by: tonyp, tschatzl --- .../share/vm/gc_implementation/g1/g1CollectedHeap.cpp | 11 +++++++---- .../share/vm/gc_implementation/g1/g1CollectedHeap.hpp | 7 ++++--- .../vm/gc_implementation/g1/vm_operations_g1.cpp | 3 --- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 97a9a1fa54d..055474297a6 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -981,7 +981,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, if (should_try_gc) { bool succeeded; - result = do_collection_pause(word_size, gc_count_before, &succeeded); + result = do_collection_pause(word_size, gc_count_before, &succeeded, + GCCause::_g1_inc_collection_pause); if (result != NULL) { assert(succeeded, "only way to get back a non-NULL result"); return result; @@ -1106,7 +1107,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, // enough space for the allocation to succeed after the pause. bool succeeded; - result = do_collection_pause(word_size, gc_count_before, &succeeded); + result = do_collection_pause(word_size, gc_count_before, &succeeded, + GCCause::_g1_humongous_allocation); if (result != NULL) { assert(succeeded, "only way to get back a non-NULL result"); return result; @@ -3700,14 +3702,15 @@ void G1CollectedHeap::gc_epilogue(bool full /* Ignored */) { HeapWord* G1CollectedHeap::do_collection_pause(size_t word_size, unsigned int gc_count_before, - bool* succeeded) { + bool* succeeded, + GCCause::Cause gc_cause) { assert_heap_not_locked_and_not_at_safepoint(); g1_policy()->record_stop_world_start(); VM_G1IncCollectionPause op(gc_count_before, word_size, false, /* should_initiate_conc_mark */ g1_policy()->max_pause_time_ms(), - GCCause::_g1_inc_collection_pause); + gc_cause); VMThread::execute(&op); HeapWord* result = op.result(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index cfcbb3f7c94..aecaa5e97ac 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -776,9 +776,10 @@ protected: // it has to be read while holding the Heap_lock. Currently, both // methods that call do_collection_pause() release the Heap_lock // before the call, so it's easy to read gc_count_before just before. - HeapWord* do_collection_pause(size_t word_size, - unsigned int gc_count_before, - bool* succeeded); + HeapWord* do_collection_pause(size_t word_size, + unsigned int gc_count_before, + bool* succeeded, + GCCause::Cause gc_cause); // The guts of the incremental collection pause, executed by the vm // thread. It returns false if it is unable to do the collection due diff --git a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp index 3be06e6ae10..9f298da3873 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp @@ -70,9 +70,6 @@ VM_G1IncCollectionPause::VM_G1IncCollectionPause( guarantee(target_pause_time_ms > 0.0, err_msg("target_pause_time_ms = %1.6lf should be positive", target_pause_time_ms)); - guarantee(word_size == 0 || gc_cause == GCCause::_g1_inc_collection_pause, - "we can only request an allocation if the GC cause is for " - "an incremental GC pause"); _gc_cause = gc_cause; } From 1dc32a077ec0608953f56dd6468606a5cade28ac Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Wed, 21 Aug 2013 16:13:50 -0700 Subject: [PATCH 029/117] 8023515: import type-annotations updates Reviewed-by: jjg --- .../com/sun/source/tree/MethodTree.java | 8 + .../sun/source/tree/TypeParameterTree.java | 14 ++ .../com/sun/tools/javac/code/Printer.java | 12 +- .../sun/tools/javac/code/TypeAnnotations.java | 25 ++- .../sun/tools/javac/comp/LambdaToMethod.java | 2 +- .../com/sun/tools/javac/comp/MemberEnter.java | 2 +- .../JavacProcessingEnvironment.java | 2 +- .../tools/javac/resources/compiler.properties | 2 +- .../com/sun/tools/javac/tree/Pretty.java | 58 +++--- .../classfile/CombinationsTargetTest2.java | 84 +++++++-- .../failures/DummyProcessor.java | 43 +++++ .../typeAnnotations/failures/T8020715.java | 49 +++++ .../referenceinfos/Constructors.java | 20 +++ .../javac/tree/TypeAnnotationsPretty.java | 170 ++++++++++++++++++ 14 files changed, 429 insertions(+), 62 deletions(-) create mode 100644 langtools/test/tools/javac/annotations/typeAnnotations/failures/DummyProcessor.java create mode 100644 langtools/test/tools/javac/annotations/typeAnnotations/failures/T8020715.java create mode 100644 langtools/test/tools/javac/tree/TypeAnnotationsPretty.java diff --git a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java index 8d9820ba5fe..987c3742767 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java @@ -53,7 +53,15 @@ public interface MethodTree extends Tree { Tree getReturnType(); List getTypeParameters(); List getParameters(); + + /** + * Return an explicit receiver parameter ("this" parameter). + * + * @return an explicit receiver parameter ("this" parameter) + * @since 1.8 + */ VariableTree getReceiverParameter(); + List getThrows(); BlockTree getBody(); Tree getDefaultValue(); // for annotation types diff --git a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java index 293a38b35a5..6dd469a7601 100644 --- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java @@ -36,6 +36,8 @@ import javax.lang.model.element.Name; * name * * name extends bounds + * + * annotations name * * * @jls section 4.4 @@ -48,5 +50,17 @@ import javax.lang.model.element.Name; public interface TypeParameterTree extends Tree { Name getName(); List getBounds(); + + /** + * Return annotations on the type parameter declaration. + * + * Annotations need Target meta-annotations of + * {@link java.lang.annotation.ElementType#TYPE_PARAMETER} or + * {@link java.lang.annotation.ElementType#TYPE_USE} + * to appear in this position. + * + * @return annotations on the type parameter declaration + * @since 1.8 + */ List getAnnotations(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java index be0b5038018..aa05cc29204 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java @@ -27,8 +27,6 @@ package com.sun.tools.javac.code; import java.util.Locale; -import javax.lang.model.type.TypeKind; - import com.sun.tools.javac.api.Messages; import com.sun.tools.javac.code.Type.AnnotatedType; import com.sun.tools.javac.code.Type.ArrayType; @@ -191,7 +189,7 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi void printBaseElementType(Type t, StringBuilder sb, Locale locale) { Type arrel = t; - while (arrel.getKind() == TypeKind.ARRAY) { + while (arrel.hasTag(TypeTag.ARRAY)) { arrel = arrel.unannotatedType(); arrel = ((ArrayType) arrel).elemtype; } @@ -200,7 +198,7 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi void printBrackets(Type t, StringBuilder sb, Locale locale) { Type arrel = t; - while (arrel.getKind() == TypeKind.ARRAY) { + while (arrel.hasTag(TypeTag.ARRAY)) { if (arrel.isAnnotated()) { sb.append(' '); sb.append(arrel.getAnnotationMirrors()); @@ -264,12 +262,12 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi public String visitAnnotatedType(AnnotatedType t, Locale locale) { if (t.typeAnnotations != null && t.typeAnnotations.nonEmpty()) { - if (t.underlyingType.getKind() == TypeKind.ARRAY) { + if (t.underlyingType.hasTag(TypeTag.ARRAY)) { StringBuilder res = new StringBuilder(); printBaseElementType(t, res, locale); printBrackets(t, res, locale); return res.toString(); - } else if (t.underlyingType.getKind() == TypeKind.DECLARED && + } else if (t.underlyingType.hasTag(TypeTag.CLASS) && t.underlyingType.getEnclosingType() != Type.noType) { return visit(t.underlyingType.getEnclosingType(), locale) + ". " + @@ -348,7 +346,7 @@ public abstract class Printer implements Type.Visitor, Symbol.Vi args = args.tail; buf.append(','); } - if (args.head.unannotatedType().getKind() == TypeKind.ARRAY) { + if (args.head.unannotatedType().hasTag(TypeTag.ARRAY)) { buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale)); if (args.head.getAnnotationMirrors().nonEmpty()) { buf.append(' '); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 260715dff64..642de5d4c4a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -29,6 +29,8 @@ import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.type.TypeKind; +import javax.tools.JavaFileObject; + import com.sun.tools.javac.code.Attribute; import com.sun.tools.javac.code.Attribute.TypeCompound; import com.sun.tools.javac.code.Flags; @@ -52,12 +54,16 @@ import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.comp.Annotate.Annotator; +import com.sun.tools.javac.comp.AttrContext; +import com.sun.tools.javac.comp.Env; import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.JCTree.JCBlock; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.tree.JCTree.JCLambda; import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCMethodInvocation; import com.sun.tools.javac.tree.JCTree.JCNewClass; import com.sun.tools.javac.tree.JCTree.JCTypeApply; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; @@ -90,11 +96,17 @@ public class TypeAnnotations { * later processing. */ public static void organizeTypeAnnotationsSignatures(final Symtab syms, final Names names, - final Log log, final JCClassDecl tree, Annotate annotate) { + final Log log, final Env env, final JCClassDecl tree, final Annotate annotate) { annotate.afterRepeated( new Annotator() { @Override public void enterAnnotation() { - new TypeAnnotationPositions(syms, names, log, true).scan(tree); + JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); + + try { + new TypeAnnotationPositions(syms, names, log, true).scan(tree); + } finally { + log.useSource(oldSource); + } } } ); } @@ -906,7 +918,14 @@ public class TypeAnnotations { if (!invocation.typeargs.contains(tree)) { Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation); } - p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT; + MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect()); + if (exsym == null) { + Assert.error("could not determine symbol for {" + invocation + "}"); + } else if (exsym.isConstructor()) { + p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; + } else { + p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT; + } p.pos = invocation.pos; p.type_index = invocation.typeargs.indexOf(tree); return; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 577d7cc30a6..7633f96d1df 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -249,7 +249,7 @@ public class LambdaToMethod extends TreeTranslator { MethodType lambdaType = (MethodType) sym.type; { - MethodSymbol owner = (MethodSymbol) localContext.owner; + Symbol owner = localContext.owner; ListBuffer ownerTypeAnnos = new ListBuffer(); ListBuffer lambdaTypeAnnos = new ListBuffer(); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index 4f23e8d8a1e..cdd3db2bcdd 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -1089,7 +1089,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } } if (allowTypeAnnos) { - TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, tree, annotate); + TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, env, tree, annotate); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index 4e966f9b716..7aca9f55726 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -89,7 +89,7 @@ import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; * deletion without notice. */ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closeable { - Options options; + private final Options options; private final boolean printProcessorInfo; private final boolean printRounds; diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 572478f19e1..5d1a22b84a1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2248,7 +2248,7 @@ compiler.err.cant.annotate.static.class=\ # TODO 308: make a better error message # 0: unused compiler.err.cant.annotate.nested.type=\ - nested type cannot be annotated + scoping construct for static nested type cannot be annotated # 0: type, 1: type compiler.err.incorrect.receiver.name=\ diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java index e7c1e12b1cf..653d9e54eff 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java @@ -944,10 +944,17 @@ public class Pretty extends JCTree.Visitor { try { if (tree.elemtype != null) { print("new "); - printTypeAnnotations(tree.annotations); JCTree elem = tree.elemtype; printBaseElementType(elem); - boolean isElemAnnoType = elem instanceof JCAnnotatedType; + + if (!tree.annotations.isEmpty()) { + print(' '); + printTypeAnnotations(tree.annotations); + } + if (tree.elems != null) { + print("[]"); + } + int i = 0; List> da = tree.dimAnnotations; for (List l = tree.dims; l.nonEmpty(); l = l.tail) { @@ -960,17 +967,7 @@ public class Pretty extends JCTree.Visitor { printExpr(l.head); print("]"); } - if (tree.elems != null) { - if (isElemAnnoType) { - print(' '); - printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations); - } - print("[]"); - } - if (isElemAnnoType) - elem = ((JCAnnotatedType)elem).underlyingType; - if (elem instanceof JCArrayTypeTree) - printBrackets((JCArrayTypeTree) elem); + printBrackets(elem); } if (tree.elems != null) { print("{"); @@ -1260,20 +1257,24 @@ public class Pretty extends JCTree.Visitor { } // prints the brackets of a nested array in reverse order - private void printBrackets(JCArrayTypeTree tree) throws IOException { - JCTree elem; + // tree is either JCArrayTypeTree or JCAnnotatedTypeTree + private void printBrackets(JCTree tree) throws IOException { + JCTree elem = tree; while (true) { - elem = tree.elemtype; if (elem.hasTag(ANNOTATED_TYPE)) { JCAnnotatedType atype = (JCAnnotatedType) elem; elem = atype.underlyingType; - if (!elem.hasTag(TYPEARRAY)) break; - print(' '); - printTypeAnnotations(atype.annotations); + if (elem.hasTag(TYPEARRAY)) { + print(' '); + printTypeAnnotations(atype.annotations); + } + } + if (elem.hasTag(TYPEARRAY)) { + print("[]"); + elem = ((JCArrayTypeTree)elem).elemtype; + } else { + break; } - print("[]"); - if (!elem.hasTag(TYPEARRAY)) break; - tree = (JCArrayTypeTree) elem; } } @@ -1378,22 +1379,15 @@ public class Pretty extends JCTree.Visitor { public void visitAnnotatedType(JCAnnotatedType tree) { try { - if (tree.underlyingType.getKind() == JCTree.Kind.MEMBER_SELECT) { + if (tree.underlyingType.hasTag(SELECT)) { JCFieldAccess access = (JCFieldAccess) tree.underlyingType; printExpr(access.selected, TreeInfo.postfixPrec); print("."); printTypeAnnotations(tree.annotations); print(access.name); - } else if (tree.underlyingType.getKind() == JCTree.Kind.ARRAY_TYPE) { - JCArrayTypeTree array = (JCArrayTypeTree) tree.underlyingType; + } else if (tree.underlyingType.hasTag(TYPEARRAY)) { printBaseElementType(tree); - print(' '); - printTypeAnnotations(tree.annotations); - print("[]"); - JCExpression elem = array.elemtype; - if (elem.hasTag(TYPEARRAY)) { - printBrackets((JCArrayTypeTree) elem); - } + printBrackets(tree); } else { printTypeAnnotations(tree.annotations); printExpr(tree.underlyingType); diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java index b660855a5b0..644b68471a2 100644 --- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java +++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java @@ -35,13 +35,16 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper { // Test count helps identify test case in event of failure. int testcount = 0; - // Base test case template descriptions + // Base test case template descriptions;true==annotations in code attribute. enum srce { src1("(repeating) type annotations on on field in method body",true), src2("(repeating) type annotations on type parameters, bounds and type arguments", true), src3("(repeating) type annotations on type parameters of class, method return value in method", true), src4("(repeating) type annotations on field in anonymous class", false), - src5("(repeating) type annotations on field in anonymous class", false); + src5("(repeating) type annotations on field in anonymous class", false), + src6("(repeating) type annotations on void method declaration", false), + src7("(repeating) type annotations in use of instanceof", true), + src8("(repeating) type annotations in use of instanceof in method", true); String description; Boolean local; @@ -84,6 +87,12 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper { test( 0, 8, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src1); test( 2, 0, 2, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src5); test( 0, 2, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src5); + test( 0, 0, 2, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src6); + test( 0, 0, 0, 2, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src6); + test( 2, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src7); + test( 0, 2, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src7); + test( 4, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src8); + test( 0, 4, 0, 0, As, BDs, ABMix, "RUNTIME", et, ++testrun, srce.src8); break; case "FIELD": test( 8, 0, 0, 0, As, BDs, ABMix, "CLASS", et, ++testrun, srce.src1); @@ -121,18 +130,6 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper { ", ABmix=" + ABmix + ", retention: " + rtn + ", anno2: " + et2 + ", src=" + source + "\n " + source.description; - if( -// 8005681 - src1,2,3 - skip cases with repeated annotations on new, array, cast. - (( source.equals(srce.src1) || source.equals(srce.src2) || - source.equals(srce.src3)) && (ABmix || (Arepeats && BDrepeats))) - // 8008928 - src4,5 - this change cause crash with t-a on anon class) - || (source.equals(srce.src4) || source.equals(srce.src5)) - ) { - System.out.println(testDef + - "\n 8005681-skip repeated annotations on new,array,cast"); - return; - } - println(testDef); // Create test source and File. String sourceString = sourceString(tname, rtn, et2, Arepeats, @@ -178,9 +175,7 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper { println("Pass"); } - // // Source for test cases - // String sourceString(String testname, String retentn, String annot2, Boolean Arepeats, Boolean BDrepeats, Boolean ABmix, srce src) { @@ -359,6 +354,63 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper { hasInnerClass=true; innerClassname="$1"; break; + case src6: // (repeating)annotations on void method declaration + /* + * class Test95{ + * @A @A @B @B public void test() { }; + * } + */ + source = new String( source + + "// " + src.description + "\n" + + "class "+ testname + "{\n" + + " _As_ _Bs_ public void test() { }\n" + + "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) + + "\n\n"; + hasInnerClass=false; + break; + case src7: // (repeating) type annotations in use of instanceof + /* + * class Test10{ + * String data = "test"; + * boolean dataIsString = ( data instanceof @A @B @A @B String); + * } + */ + source = new String( source + + "// " + src.description + "\n" + + "class "+ testname + "{\n" + + " String data = \"test\";\n" + + " boolean dataIsString = ( data instanceof _As_ _Bs_ String);\n" + + "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) + + "\n\n"; + hasInnerClass=false; + break; + case src8: // (repeating) type annotations in use of instanceof + /* + * class Test20{ + * String data = "test"; + * Boolean isString() { + * if( data instanceof @A @B @A @B String ) + * return true; + * else + * return( data instanceof @A @B @A @B String ); + * } + * } + */ + source = new String( source + + "// " + src.description + "\n" + + "class "+ testname + "{\n" + + " String data = \"test\";\n" + + " Boolean isString() { \n" + + " if( data instanceof _As_ _Bs_ String )\n" + + " return true;\n" + + " else\n" + + " return( data instanceof _As_ _Bs_ String );\n" + + " }\n" + + "}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) + + "\n\n"; + hasInnerClass=false; + break; + } return imports + source; } diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/DummyProcessor.java b/langtools/test/tools/javac/annotations/typeAnnotations/failures/DummyProcessor.java new file mode 100644 index 00000000000..26bd4d288b3 --- /dev/null +++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/DummyProcessor.java @@ -0,0 +1,43 @@ +/* + * 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 javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; + +import java.util.Set; + +/* A simple annotation processor. */ +@SupportedAnnotationTypes("*") +public class DummyProcessor extends AbstractProcessor { + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public final boolean process(Set annotations, + RoundEnvironment roundEnv) { + return false; + } +} diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8020715.java b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8020715.java new file mode 100644 index 00000000000..89670f3edf4 --- /dev/null +++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8020715.java @@ -0,0 +1,49 @@ +/* + * 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 + * @summary Regression: compiling program with lambda crashed compiler + * @bug 8020715 + * @compile T8020715.java + */ +class T8020715 { + // This crashed. + private static void makeTask1() { + class LocalClass { + private Runnable r = () -> {}; + } + } + + // This crashed, too. + private void makeTask2() { + class LocalClass { + private Runnable r = () -> {}; + } + } + + // This is fine. + private class InnerClass { + private Runnable r = () -> {}; + } +} diff --git a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java index 38e46159cea..a8d1311eb47 100644 --- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java +++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java @@ -85,4 +85,24 @@ public class Constructors { " } } }"; } + @TADescriptions({ + @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, + typeIndex = 0, offset = 4), + @TADescription(annotation = "TB", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, + typeIndex = 0, offset = 0) + }) + public String generic1() { + return "class Test { Test(int i) { new <@TA T>Test(); }" + + " Test() { <@TB String>this(0); } }"; + } + + @TADescriptions({ + @TADescription(annotation = "TA", type = CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, + typeIndex = 0, offset = 0) + }) + public String generic2() { + return "class Super { Super(int i) { } } " + + "class Test extends Super { Test() { <@TA String>super(0); } }"; + } + } diff --git a/langtools/test/tools/javac/tree/TypeAnnotationsPretty.java b/langtools/test/tools/javac/tree/TypeAnnotationsPretty.java new file mode 100644 index 00000000000..0ca021c9b3d --- /dev/null +++ b/langtools/test/tools/javac/tree/TypeAnnotationsPretty.java @@ -0,0 +1,170 @@ +/* + * 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 1234567 + * @summary test Pretty print of type annotations + * @author wmdietl + */ + +import com.sun.source.tree.ClassTree; +import com.sun.source.tree.CompilationUnitTree; +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.tree.JCTree; + +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import java.util.LinkedList; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class TypeAnnotationsPretty { + private final JavaCompiler tool; + + TypeAnnotationsPretty() { + tool = ToolProvider.getSystemJavaCompiler(); + } + + private List matches = new LinkedList(); + private List mismatches = new LinkedList(); + + public static void main(String... args) throws Exception { + TypeAnnotationsPretty tap = new TypeAnnotationsPretty(); + + tap.runField("@TA()\nObject cls = null"); + tap.runField("@TA()\nObject cls = new @TA() Object()"); + + tap.runField("@TA()\nList<@TB() Object> cls = null"); + tap.runField("@TA()\nList<@TB() Object> cls = new @TA() LinkedList<@TB() Object>()"); + + tap.runField("Class[] cls = null"); + tap.runField("@TA()\nClass[] cls = null"); + tap.runField("Class @TA() [] cls = null"); + tap.runField("@TA()\nClass @TB() [] cls = null"); + + tap.runField("Class[] cls = new Class[]{Object.class}"); + tap.runField("@TA()\nClass[] cls = new @TA() Class[]{Object.class}"); + tap.runField("Class @TB() [] cls = new Class @TB() []{Object.class}"); + tap.runField("@TA()\nClass @TB() [] cls = new @TA() Class @TB() []{Object.class}"); + tap.runField("@TA()\nClass @TB() [] @TC() [] cls = new @TA() Class @TB() [10] @TC() []"); + tap.runField("Class @TB() [] @TC() [] cls = new Class @TB() [10] @TC() []"); + tap.runField("@TA()\nClass @TB() [] @TC() [] @TD() [] cls = new @TA() Class @TB() [10] @TC() [] @TD() []"); + + tap.runMethod("\n@TA()\nObject test(@TB()\nList<@TC() String> p) {\n" + + " return null;\n" + + "}"); + + + if (!tap.matches.isEmpty()) { + for (String m : tap.matches) + System.out.println(m); + } + if (!tap.mismatches.isEmpty()) { + for (String mm : tap.mismatches) + System.err.println(mm + "\n"); + throw new RuntimeException("Tests failed!"); + } + } + + private static final String prefix = + "import java.lang.annotation.*;" + + "import java.util.*;" + + "public class Test {"; + + private static final String postfix = + "@Target(ElementType.TYPE_USE)" + + "@interface TA {}" + + "@Target(ElementType.TYPE_USE)" + + "@interface TB {}" + + "@Target(ElementType.TYPE_USE)" + + "@interface TC {}" + + "@Target(ElementType.TYPE_USE)" + + "@interface TD {}"; + + + private void runField(String code) throws IOException { + String src = prefix + + code + "; }" + + postfix; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(src))); + + + for (CompilationUnitTree cut : ct.parse()) { + JCTree.JCVariableDecl var = + (JCTree.JCVariableDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); + + if (!code.equals(var.toString())) { + mismatches.add("Expected: " + code + + "\nObtained: " + var.toString()); + } else { + matches.add("Passed: " + code); + } + } + } + + private void runMethod(String code) throws IOException { + String src = prefix + + code + "}" + + postfix; + + JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null, + null, Arrays.asList(new MyFileObject(src))); + + + for (CompilationUnitTree cut : ct.parse()) { + JCTree.JCMethodDecl var = + (JCTree.JCMethodDecl) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0); + + if (!code.equals(var.toString())) { + mismatches.add("Expected: " + code + + "\nObtained: " + var.toString()); + } else { + matches.add("Passed: " + code); + } + } + } +} + + +class MyFileObject extends SimpleJavaFileObject { + + private String text; + + public MyFileObject(String text) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.text = text; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return text; + } +} From 8073e1a535e6234a0e4b5f4650c403999242c8fe Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Wed, 21 Aug 2013 20:23:36 -0400 Subject: [PATCH 030/117] 7118412: Shadowing of type-variables vs. member types 4987840: What is the scope of an annotation? Fixed issue with shadowing of type names. Reviewed-by: jjg, abuckley, mcimadamore --- .../com/sun/tools/javac/comp/Resolve.java | 99 +++++++++++++++---- 1 file changed, 81 insertions(+), 18 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index e2784003285..0439e0d6132 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1859,7 +1859,10 @@ public class Resolve { } } - /** Find qualified member type. + + /** + * Find a type declared in a scope (not inherited). Return null + * if none is found. * @param env The current environment. * @param site The original type from where the selection takes * place. @@ -1868,12 +1871,10 @@ public class Resolve { * always a superclass or implemented interface of * site's class. */ - Symbol findMemberType(Env env, - Type site, - Name name, - TypeSymbol c) { - Symbol bestSoFar = typeNotFound; - Symbol sym; + Symbol findImmediateMemberType(Env env, + Type site, + Name name, + TypeSymbol c) { Scope.Entry e = c.members().lookup(name); while (e.scope != null) { if (e.sym.kind == TYP) { @@ -1883,6 +1884,24 @@ public class Resolve { } e = e.next(); } + return typeNotFound; + } + + /** Find a member type inherited from a superclass or interface. + * @param env The current environment. + * @param site The original type from where the selection takes + * place. + * @param name The type's name. + * @param c The class to search for the member type. This is + * always a superclass or implemented interface of + * site's class. + */ + Symbol findInheritedMemberType(Env env, + Type site, + Name name, + TypeSymbol c) { + Symbol bestSoFar = typeNotFound; + Symbol sym; Type st = types.supertype(c.type); if (st != null && st.hasTag(CLASS)) { sym = findMemberType(env, site, name, st.tsym); @@ -1901,6 +1920,28 @@ public class Resolve { return bestSoFar; } + /** Find qualified member type. + * @param env The current environment. + * @param site The original type from where the selection takes + * place. + * @param name The type's name. + * @param c The class to search for the member type. This is + * always a superclass or implemented interface of + * site's class. + */ + Symbol findMemberType(Env env, + Type site, + Name name, + TypeSymbol c) { + Symbol sym = findImmediateMemberType(env, site, name, c); + + if (sym != typeNotFound) + return sym; + + return findInheritedMemberType(env, site, name, c); + + } + /** Find a global type in given scope and load corresponding class. * @param env The current environment. * @param scope The scope in which to look for the type. @@ -1919,6 +1960,21 @@ public class Resolve { return bestSoFar; } + Symbol findTypeVar(Env env, Name name, boolean staticOnly) { + for (Scope.Entry e = env.info.scope.lookup(name); + e.scope != null; + e = e.next()) { + if (e.sym.kind == TYP) { + if (staticOnly && + e.sym.type.hasTag(TYPEVAR) && + e.sym.owner.kind == TYP) + return new StaticError(e.sym); + return e.sym; + } + } + return typeNotFound; + } + /** Find an unqualified type symbol. * @param env The current environment. * @param name The type's name. @@ -1929,19 +1985,26 @@ public class Resolve { boolean staticOnly = false; for (Env env1 = env; env1.outer != null; env1 = env1.outer) { if (isStatic(env1)) staticOnly = true; - for (Scope.Entry e = env1.info.scope.lookup(name); - e.scope != null; - e = e.next()) { - if (e.sym.kind == TYP) { - if (staticOnly && - e.sym.type.hasTag(TYPEVAR) && - e.sym.owner.kind == TYP) return new StaticError(e.sym); - return e.sym; - } + // First, look for a type variable and the first member type + final Symbol tyvar = findTypeVar(env1, name, staticOnly); + sym = findImmediateMemberType(env1, env1.enclClass.sym.type, + name, env1.enclClass.sym); + + // Return the type variable if we have it, and have no + // immediate member, OR the type variable is for a method. + if (tyvar != typeNotFound) { + if (sym == typeNotFound || + (tyvar.kind == TYP && tyvar.exists() && + tyvar.owner.kind == MTH)) + return tyvar; } - sym = findMemberType(env1, env1.enclClass.sym.type, name, - env1.enclClass.sym); + // If the environment is a class def, finish up, + // otherwise, do the entire findMemberType + if (sym == typeNotFound) + sym = findInheritedMemberType(env1, env1.enclClass.sym.type, + name, env1.enclClass.sym); + if (staticOnly && sym.kind == TYP && sym.type.hasTag(CLASS) && sym.type.getEnclosingType().hasTag(CLASS) && From 64412dad178d5fac931394cb2b7778cbed840ef6 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 21 Aug 2013 17:26:22 -0700 Subject: [PATCH 031/117] 8022287: javac.sym.Profiles uses a static Map when it should not Reviewed-by: ksrini --- .../com/sun/tools/javac/sym/Profiles.java | 2 +- .../tools/javac/profiles/ProfileTest.java | 114 ++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/profiles/ProfileTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java b/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java index 8cae1dd3696..1ebea23192d 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java +++ b/langtools/src/share/classes/com/sun/tools/javac/sym/Profiles.java @@ -148,7 +148,7 @@ public abstract class Profiles { } } - final static Map packages = new TreeMap(); + final Map packages = new TreeMap(); final int maxProfile = 4; // Three compact profiles plus full JRE diff --git a/langtools/test/tools/javac/profiles/ProfileTest.java b/langtools/test/tools/javac/profiles/ProfileTest.java new file mode 100644 index 00000000000..7e081a5b81e --- /dev/null +++ b/langtools/test/tools/javac/profiles/ProfileTest.java @@ -0,0 +1,114 @@ +/* + * 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 8022287 + * @summary javac.sym.Profiles uses a static Map when it should not + */ + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; + +import com.sun.tools.javac.sym.Profiles; + +public class ProfileTest { + public static void main(String... args) throws Exception { + new ProfileTest().run(); + } + + public void run() throws Exception { + test("A"); + test("B"); + + if (errors > 0) + throw new Exception(errors + " occurred"); + } + + void test(String base) throws IOException { + System.err.println("test " + base); + File profileDesc = createFiles(base); + checkProfile(profileDesc, base); + } + + void checkProfile(File profileDesc, String base) throws IOException { + Profiles p = Profiles.read(profileDesc); + for (int i = 0; i < p.getProfileCount(); i++) { + System.err.println(p.getPackages(i)); + for (String pkg: p.getPackages(i)) { + if (!pkg.endsWith(base)) + error("unexpected package " + pkg + " for profile " + i); + } + } + } + + File createFiles(String base) throws IOException { + File baseDir = new File(base); + baseDir.mkdirs(); + for (int p = 1; p <= 4; p++) { + String pkg = "pkg" + p + base; + File pkgDir = new File(baseDir, pkg); + pkgDir.mkdirs(); + File clssFile = new File(pkgDir, pkg + "Class.java"); + try (PrintWriter out = new PrintWriter(new FileWriter(clssFile))) { + out.println("package " + pkgDir.getName() + ";"); + out.println("class " + clssFile.getName().replace(".java", "")); + } + } + + File profileDesc = new File(baseDir, "profiles" + base + ".txt"); + try (PrintWriter out = new PrintWriter(new FileWriter(profileDesc))) { + for (int p = 1; p <= 4; p++) { + String pkg = "pkg" + p + base; + createPackage(baseDir, pkg, "Pkg" + p + base + "Class"); + out.println("PROFILE_" + p + "_RTJAR_INCLUDE_PACKAGES := " + pkg); + out.println("PROFILE_" + p + "_RTJAR_INCLUDE_TYPES :="); + out.println("PROFILE_" + p + "_RTJAR_EXCLUDE_TYPES :="); + out.println("PROFILE_" + p + "_INCLUDE_METAINF_SERVICES := "); + } + } + + return profileDesc; + } + + void createPackage(File baseDir, String pkg, String... classNames) throws IOException { + File pkgDir = new File(baseDir, pkg); + pkgDir.mkdirs(); + for (String className: classNames) { + File clssFile = new File(pkgDir, className + ".java"); + try (PrintWriter out = new PrintWriter(new FileWriter(clssFile))) { + out.println("package " + pkg + ";"); + out.println("public class " + className + " { }"); + } + } + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; +} From febfa82cfb3e4b434f7aa426b73d2efc3a3ffbc8 Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Wed, 21 Aug 2013 20:41:42 -0400 Subject: [PATCH 032/117] 8023520: Add missing test for JDK-7118412 The test for JDK-7118412 was dropped from the changeset in a merging accident. Reviewed-by: jjg --- .../tools/javac/7118412/ShadowingTest.java | 287 ++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 langtools/test/tools/javac/7118412/ShadowingTest.java diff --git a/langtools/test/tools/javac/7118412/ShadowingTest.java b/langtools/test/tools/javac/7118412/ShadowingTest.java new file mode 100644 index 00000000000..4bbcfc636c6 --- /dev/null +++ b/langtools/test/tools/javac/7118412/ShadowingTest.java @@ -0,0 +1,287 @@ +/* + * 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 7118412 + * @summary Shadowing of type-variables vs. member types + */ +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +public class ShadowingTest { + + // We generate a method "test" that tries to call T.. This controls whether + // "test" is static or not. + private enum MethodContext { + STATIC("static "), + INSTANCE(""); + + public final String methodcontext; + + MethodContext(final String methodcontext) { + this.methodcontext = methodcontext; + } + } + + // These control whether or not a type parameter, method type + // parameter, or inner class get declared (and in the case of + // inner classes, whether it's static or not. + + private enum MethodTypeParameterDecl { + NO(""), + YES(" "); + + public final String tyvar; + + MethodTypeParameterDecl(final String tyvar) { + this.tyvar = tyvar; + } + } + + private enum InsideDef { + NONE(""), + STATIC("static class T { public void inner() {} }\n"), + INSTANCE("class T { public void inner() {} }\n"); + + public final String instancedef; + + InsideDef(final String instancedef) { + this.instancedef = instancedef; + } + } + + private enum TypeParameterDecl { + NO(""), + YES(""); + + public final String tyvar; + + TypeParameterDecl(final String tyvar) { + this.tyvar = tyvar; + } + } + + // Represents what method we try to call. This is a way of + // checking which T we're seeing. + private enum MethodCall { + // Method type variables extend Number, so we have intValue + METHOD_TYPEVAR("intValue"), + // The inner class declaration has a method called "inner" + INNER_CLASS("inner"), + // The class type variables extend Collection, so we call iterator + TYPEVAR("iterator"), + // The outer class declaration has a method called "outer" + OUTER_CLASS("outer"); + + public final String methodcall; + + MethodCall(final String methodcall) { + this.methodcall = methodcall; + } + + } + + public boolean succeeds(final MethodCall call, + final MethodTypeParameterDecl mtyvar, + final MethodContext ctx, + final InsideDef inside, + final TypeParameterDecl tyvar) { + switch(call) { + // We want to resolve to the method type variable + case METHOD_TYPEVAR: switch(mtyvar) { + // If the method type variable exists, then T will + // resolve to it, and we'll have intValue. + case YES: return true; + // Otherwise, this cannot succeed. + default: return false; + } + // We want to resolve to the inner class + case INNER_CLASS: switch(mtyvar) { + // The method type parameter will shadow the inner + // class, so there can't be one. + case NO: switch(ctx) { + // If we're not static, then either one should succeed. + case INSTANCE: switch(inside) { + case INSTANCE: + case STATIC: + return true; + default: return false; + } + case STATIC: switch(inside) { + // If we are static, and the inner class is + // static, then we also succeed, because we + // can't see the type variable. + case STATIC: return true; + case INSTANCE: switch(tyvar) { + // If we're calling from a non-static + // context, there can't be a class type + // variable, because that will shadow the + // static inner class definition. + case NO: return true; + default: return false; + } + // If the inner class isn't declared, we can't + // see it. + default: return false; + } + // Can't get here. + default: return false; + } + default: return false; + } + // We want to resolve to the class type parameter + case TYPEVAR: switch(mtyvar) { + // We can't have a method type parameter, as that would + // shadow the class type parameter + case NO: switch(ctx) { + case INSTANCE: switch(inside) { + // We have to be in an instance context. If + // we're static, we can't see the type + // variable. + case NONE: switch(tyvar) { + // Obviously, the type parameter has to be declared. + case YES: return true; + default: return false; + } + default: return false; + } + default: return false; + } + default: return false; + } + // We want to resolve to the outer class + case OUTER_CLASS: switch(mtyvar) { + case NO: switch(inside) { + case NONE: switch(tyvar) { + // Basically, nothing else can be declared, or + // else we can't see it. Even if our context + // is static, the compiler will complain if + // non-static T's exist, because they will + // shadow the outer class. + case NO: return true; + default: return false; + } + default: return false; + } + default: return false; + } + } + return false; + } + + private static final File classesdir = new File("7118412"); + + private int errors = 0; + + private int dirnum = 0; + + private void doTest(final MethodTypeParameterDecl mtyvar, + final TypeParameterDecl tyvar, + final InsideDef insidedef, final MethodContext ctx, + final MethodCall call) + throws IOException { + final String content = "import java.util.Collection;\n" + + "class Test" + tyvar.tyvar + " {\n" + + " " + insidedef.instancedef + + " " + ctx.methodcontext + mtyvar.tyvar + "void test(T t) { t." + + call.methodcall + "(); }\n" + + "}\n" + + "class T { void outer() {} }\n"; + final File dir = new File(classesdir, "" + dirnum); + final File Test_java = writeFile(dir, "Test.java", content); + dirnum++; + if(succeeds(call, mtyvar, ctx, insidedef, tyvar)) { + if(!assert_compile_succeed(Test_java)) + System.err.println("Failed file:\n" + content); + } + else { + if(!assert_compile_fail(Test_java)) + System.err.println("Failed file:\n" + content); + } + } + + private void run() throws Exception { + classesdir.mkdir(); + for(MethodTypeParameterDecl mtyvar : MethodTypeParameterDecl.values()) + for(TypeParameterDecl tyvar : TypeParameterDecl.values()) + for(InsideDef insidedef : InsideDef.values()) + for(MethodContext ctx : MethodContext.values()) + for(MethodCall methodcall : MethodCall.values()) + doTest(mtyvar, tyvar, insidedef, ctx, methodcall); + if (errors != 0) + throw new Exception("ShadowingTest test failed with " + + errors + " errors."); + } + + private boolean assert_compile_fail(final File file) { + final String filename = file.getPath(); + final String[] args = { filename }; + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + final int rc = com.sun.tools.javac.Main.compile(args, pw); + pw.close(); + if (rc == 0) { + System.err.println("Compilation of " + file.getName() + + " didn't fail as expected."); + errors++; + return false; + } else return true; + } + + private boolean assert_compile_succeed(final File file) { + final String filename = file.getPath(); + final String[] args = { filename }; + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + final int rc = com.sun.tools.javac.Main.compile(args, pw); + pw.close(); + if (rc != 0) { + System.err.println("Compilation of " + file.getName() + + " didn't succeed as expected. Output:"); + System.err.println(sw.toString()); + errors++; + return false; + } else return true; + } + + private File writeFile(final File dir, + final String path, + final String body) throws IOException { + final File f = new File(dir, path); + f.getParentFile().mkdirs(); + final FileWriter out = new FileWriter(f); + out.write(body); + out.close(); + return f; + } + + public static void main(String... args) throws Exception { + new ShadowingTest().run(); + } + +} From ff7c51cd184ccf7c61561554eaaab800bf461fb9 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 22 Aug 2013 13:32:22 -0700 Subject: [PATCH 033/117] 6470700: Math.random() / Math.initRNG() uses "double checked locking" Replace class Random variable with a static final holder class Reviewed-by: alanb, mduigou, chegar --- jdk/src/share/classes/java/lang/Math.java | 11 +++-------- jdk/src/share/classes/java/lang/StrictMath.java | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Math.java b/jdk/src/share/classes/java/lang/Math.java index 23bc934688d..ae83e4265ad 100644 --- a/jdk/src/share/classes/java/lang/Math.java +++ b/jdk/src/share/classes/java/lang/Math.java @@ -698,11 +698,8 @@ public final class Math { return 0; } - private static Random randomNumberGenerator; - - private static synchronized Random initRNG() { - Random rnd = randomNumberGenerator; - return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd; + private static final class RandomNumberGeneratorHolder { + static final Random randomNumberGenerator = new Random(); } /** @@ -729,9 +726,7 @@ public final class Math { * @see Random#nextDouble() */ public static double random() { - Random rnd = randomNumberGenerator; - if (rnd == null) rnd = initRNG(); - return rnd.nextDouble(); + return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble(); } /** diff --git a/jdk/src/share/classes/java/lang/StrictMath.java b/jdk/src/share/classes/java/lang/StrictMath.java index eb202d53202..52336484e75 100644 --- a/jdk/src/share/classes/java/lang/StrictMath.java +++ b/jdk/src/share/classes/java/lang/StrictMath.java @@ -678,11 +678,8 @@ public final class StrictMath { return Math.round(a); } - private static Random randomNumberGenerator; - - private static synchronized Random initRNG() { - Random rnd = randomNumberGenerator; - return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd; + private static final class RandomNumberGeneratorHolder { + static final Random randomNumberGenerator = new Random(); } /** @@ -709,9 +706,7 @@ public final class StrictMath { * @see Random#nextDouble() */ public static double random() { - Random rnd = randomNumberGenerator; - if (rnd == null) rnd = initRNG(); - return rnd.nextDouble(); + return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble(); } /** From 6d2de008d77509d89344fddb3dc1dea74888278d Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 23 Aug 2013 20:59:34 +0200 Subject: [PATCH 034/117] 8005899: Logger.getLogger(name, null) should not allow to reset a non-null resource bundle Reviewed-by: mchung, lancea --- .../classes/java/util/logging/Logger.java | 16 +-- .../logging/Logger/getLogger/TestLogger.java | 98 +++++++++++++++++++ .../getLogger/testlogger/MyResource.java | 52 ++++++++++ 3 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 jdk/test/java/util/logging/Logger/getLogger/TestLogger.java create mode 100644 jdk/test/java/util/logging/Logger/getLogger/testlogger/MyResource.java diff --git a/jdk/src/share/classes/java/util/logging/Logger.java b/jdk/src/share/classes/java/util/logging/Logger.java index 1c959ecd6a1..a7f0cc2cd4a 100644 --- a/jdk/src/share/classes/java/util/logging/Logger.java +++ b/jdk/src/share/classes/java/util/logging/Logger.java @@ -457,13 +457,15 @@ public class Logger { * of the subsystem, such as java.net * or javax.swing * @param resourceBundleName name of ResourceBundle to be used for localizing - * messages for this logger. May be null if none of - * the messages require localization. + * messages for this logger. May be {@code null} + * if none of the messages require localization. * @return a suitable Logger * @throws MissingResourceException if the resourceBundleName is non-null and * no corresponding resource can be found. * @throws IllegalArgumentException if the Logger already exists and uses - * a different resource bundle name. + * a different resource bundle name; or if + * {@code resourceBundleName} is {@code null} but the named + * logger has a resource bundle set. * @throws NullPointerException if the name is null. */ @@ -1731,10 +1733,6 @@ public class Logger { // Synchronized to prevent races in setting the fields. private synchronized void setupResourceInfo(String name, Class callersClass) { - if (name == null) { - return; - } - if (resourceBundleName != null) { // this Logger already has a ResourceBundle @@ -1748,6 +1746,10 @@ public class Logger { resourceBundleName + " != " + name); } + if (name == null) { + return; + } + setCallersClassLoaderRef(callersClass); if (findResourceBundle(name, true) == null) { // We've failed to find an expected ResourceBundle. diff --git a/jdk/test/java/util/logging/Logger/getLogger/TestLogger.java b/jdk/test/java/util/logging/Logger/getLogger/TestLogger.java new file mode 100644 index 00000000000..cf6abc449dd --- /dev/null +++ b/jdk/test/java/util/logging/Logger/getLogger/TestLogger.java @@ -0,0 +1,98 @@ +/* + * 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.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * @test + * @bug 8005899 + * @build TestLogger testlogger.MyResource + * @run main/othervm TestLogger + * @run main/othervm -Dsecurity=on TestLogger + **/ +public class TestLogger { + + public static final String RESOURCE_BUNDLE = "testlogger.MyResource"; + public static final String ORG_LOGGER = "org"; + public static final String FOO_LOGGER = ORG_LOGGER + ".foo.Foo"; + public static final String BAR_LOGGER = ORG_LOGGER + ".bar.Bar"; + public static final String GEE_LOGGER = ORG_LOGGER + ".gee.Gee"; + public static final String GEE_GEE_LOGGER = GEE_LOGGER+".Gee"; + + public static void main(String[] args) { + final String security = System.getProperty("security", "off"); + System.out.println("Security is " + security); + if ("on".equals(security)) { + System.setSecurityManager(new SecurityManager()); + } + + newLogger(FOO_LOGGER, RESOURCE_BUNDLE); + newLogger(FOO_LOGGER); + newLogger(BAR_LOGGER); + newLogger(BAR_LOGGER, RESOURCE_BUNDLE); + newLogger(GEE_LOGGER, null); + newLogger(GEE_LOGGER, RESOURCE_BUNDLE); + newLogger(ORG_LOGGER); + newLogger(GEE_GEE_LOGGER); + + for (String log : new String[] { FOO_LOGGER, BAR_LOGGER, GEE_LOGGER }) { + if (!RESOURCE_BUNDLE.equals(Logger.getLogger(log).getResourceBundleName())) { + throw new RuntimeException("Shouldn't allow to reset the resource bundle for " + log); + } + try { + Logger logger = Logger.getLogger(log, null); + if (!RESOURCE_BUNDLE.equals(logger.getResourceBundleName())) { + throw new RuntimeException("Shouldn't allow to reset the resource bundle for " + log); + } + throw new RuntimeException("Expected IllegalArgumentException not thrown for " + log); + } catch (IllegalArgumentException e) { + System.out.println("Got expected exception for " + log +": " + e); + } + } + for (String log : new String[] { ORG_LOGGER, GEE_GEE_LOGGER }) { + if (Logger.getLogger(log).getResourceBundleName() != null) { + throw new RuntimeException("Resource bundle is not null for log: " + + Logger.getLogger(log).getResourceBundleName()); + } + try { + Logger logger = Logger.getLogger(log, null); + if (logger.getResourceBundleName() != null) { + throw new RuntimeException("Resource bundle is not null for log: " + + logger.getResourceBundleName()); + } + System.out.println("Success calling Logger.getLogger(\""+log+"\", null)"); + } catch (IllegalArgumentException e) { + throw new RuntimeException("Unexpected exception for " + log +": " + e, e); + } + } + } + + private static List strongRefs = new ArrayList<>(); + private static void newLogger(String name) { + strongRefs.add(Logger.getLogger(name)); + } + private static void newLogger(String name, String resourceBundleName) { + strongRefs.add(Logger.getLogger(name, resourceBundleName)); + } +} diff --git a/jdk/test/java/util/logging/Logger/getLogger/testlogger/MyResource.java b/jdk/test/java/util/logging/Logger/getLogger/testlogger/MyResource.java new file mode 100644 index 00000000000..84b0cd258cb --- /dev/null +++ b/jdk/test/java/util/logging/Logger/getLogger/testlogger/MyResource.java @@ -0,0 +1,52 @@ +/* + * 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. + */ +package testlogger; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; + +/** + * A dummy resource bundle for testing purposes. + * @author danielfuchs + */ +public class MyResource extends ResourceBundle { + Map bundle = new HashMap<>(); + + @Override + protected Object handleGetObject(String key) { + bundle.put(key,"Localized: " + key); + return bundle.get(key); + } + + @Override + public Enumeration getKeys() { + final Hashtable h = new Hashtable<>(bundle); + return h.keys(); + } + +} From 6c5c2d745abc81a91a7c169edb91538de513881e Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 23 Aug 2013 14:15:54 -0700 Subject: [PATCH 035/117] 6378503: In java.math.BigDecimal, division by one returns zero 6446965: Using BigDecimal.divideToIntegralValue with extreme scales can lead to an incorrect result Fix overflow of ints and ensure appropriate values passed to checkScaleNonZero() Reviewed-by: darcy, martin --- .../share/classes/java/math/BigDecimal.java | 32 +++++++++++-------- .../share/classes/java/math/BigInteger.java | 2 +- .../BigDecimal/IntegralDivisionTests.java | 5 ++- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/jdk/src/share/classes/java/math/BigDecimal.java b/jdk/src/share/classes/java/math/BigDecimal.java index 1a7ca811226..0abfb7522b5 100644 --- a/jdk/src/share/classes/java/math/BigDecimal.java +++ b/jdk/src/share/classes/java/math/BigDecimal.java @@ -2659,28 +2659,32 @@ public class BigDecimal extends Number implements Comparable { if (ys == 0) return 1; - int sdiff = this.scale - val.scale; + long sdiff = (long)this.scale - val.scale; if (sdiff != 0) { // Avoid matching scales if the (adjusted) exponents differ - int xae = this.precision() - this.scale; // [-1] - int yae = val.precision() - val.scale; // [-1] + long xae = (long)this.precision() - this.scale; // [-1] + long yae = (long)val.precision() - val.scale; // [-1] if (xae < yae) return -1; if (xae > yae) return 1; BigInteger rb = null; if (sdiff < 0) { - if ( (xs == INFLATED || - (xs = longMultiplyPowerTen(xs, -sdiff)) == INFLATED) && + // The cases sdiff <= Integer.MIN_VALUE intentionally fall through. + if ( sdiff > Integer.MIN_VALUE && + (xs == INFLATED || + (xs = longMultiplyPowerTen(xs, (int)-sdiff)) == INFLATED) && ys == INFLATED) { - rb = bigMultiplyPowerTen(-sdiff); + rb = bigMultiplyPowerTen((int)-sdiff); return rb.compareMagnitude(val.intVal); } } else { // sdiff > 0 - if ( (ys == INFLATED || - (ys = longMultiplyPowerTen(ys, sdiff)) == INFLATED) && + // The cases sdiff > Integer.MAX_VALUE intentionally fall through. + if ( sdiff <= Integer.MAX_VALUE && + (ys == INFLATED || + (ys = longMultiplyPowerTen(ys, (int)sdiff)) == INFLATED) && xs == INFLATED) { - rb = val.bigMultiplyPowerTen(sdiff); + rb = val.bigMultiplyPowerTen((int)sdiff); return this.intVal.compareMagnitude(rb); } } @@ -4545,7 +4549,7 @@ public class BigDecimal extends Number implements Comparable { if(cmp > 0) { // satisfy constraint (b) yscale -= 1; // [that is, divisor *= 10] int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); - if (checkScaleNonZero((long) mcp + yscale) > xscale) { + if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) { // assert newScale >= xscale int raise = checkScaleNonZero((long) mcp + yscale - xscale); long scaledXs; @@ -4626,7 +4630,7 @@ public class BigDecimal extends Number implements Comparable { // return BigDecimal object whose scale will be set to 'scl'. int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); BigDecimal quotient; - if (checkScaleNonZero((long) mcp + yscale) > xscale) { + if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) { int raise = checkScaleNonZero((long) mcp + yscale - xscale); long scaledXs; if ((scaledXs = longMultiplyPowerTen(xs, raise)) == INFLATED) { @@ -4673,7 +4677,7 @@ public class BigDecimal extends Number implements Comparable { // return BigDecimal object whose scale will be set to 'scl'. BigDecimal quotient; int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); - if (checkScaleNonZero((long) mcp + yscale) > xscale) { + if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) { int raise = checkScaleNonZero((long) mcp + yscale - xscale); BigInteger rb = bigMultiplyPowerTen(xs,raise); quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale)); @@ -4714,7 +4718,7 @@ public class BigDecimal extends Number implements Comparable { // return BigDecimal object whose scale will be set to 'scl'. BigDecimal quotient; int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); - if (checkScaleNonZero((long) mcp + yscale) > xscale) { + if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) { int raise = checkScaleNonZero((long) mcp + yscale - xscale); BigInteger rb = bigMultiplyPowerTen(xs,raise); quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale)); @@ -4745,7 +4749,7 @@ public class BigDecimal extends Number implements Comparable { // return BigDecimal object whose scale will be set to 'scl'. BigDecimal quotient; int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); - if (checkScaleNonZero((long) mcp + yscale) > xscale) { + if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) { int raise = checkScaleNonZero((long) mcp + yscale - xscale); BigInteger rb = bigMultiplyPowerTen(xs,raise); quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale)); diff --git a/jdk/src/share/classes/java/math/BigInteger.java b/jdk/src/share/classes/java/math/BigInteger.java index e8cedf8a564..6beaed71bb3 100644 --- a/jdk/src/share/classes/java/math/BigInteger.java +++ b/jdk/src/share/classes/java/math/BigInteger.java @@ -2109,7 +2109,7 @@ public class BigInteger extends Number implements Comparable { // This is a quick way to approximate the size of the result, // similar to doing log2[n] * exponent. This will give an upper bound // of how big the result can be, and which algorithm to use. - int scaleFactor = remainingBits * exponent; + long scaleFactor = (long)remainingBits * exponent; // Use slightly different algorithms for small and large operands. // See if the result will safely fit into a long. (Largest 2^63-1) diff --git a/jdk/test/java/math/BigDecimal/IntegralDivisionTests.java b/jdk/test/java/math/BigDecimal/IntegralDivisionTests.java index 1e28e1d7543..ab6b624c98b 100644 --- a/jdk/test/java/math/BigDecimal/IntegralDivisionTests.java +++ b/jdk/test/java/math/BigDecimal/IntegralDivisionTests.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 4904082 4917089 6337226 + * @bug 4904082 4917089 6337226 6378503 * @summary Tests that integral division and related methods return the proper result and scale. * @author Joseph D. Darcy */ @@ -47,6 +47,9 @@ public class IntegralDivisionTests { {new BigDecimal("400e1"), new BigDecimal("5"), new BigDecimal("80e1")}, {new BigDecimal("400e1"), new BigDecimal("4.999999999"), new BigDecimal("8e2")}, {new BigDecimal("40e2"), new BigDecimal("5"), new BigDecimal("8e2")}, + {BigDecimal.valueOf(1, Integer.MIN_VALUE), + BigDecimal.valueOf(1, -(Integer.MAX_VALUE & 0x7fffff00)), + BigDecimal.valueOf(1, -256)}, }; for(BigDecimal [] testCase: moreTestCases) { From 423284cd203ee03a0d97dc2b63e68567f51b874d Mon Sep 17 00:00:00 2001 From: Yiming Wang Date: Mon, 26 Aug 2013 10:01:27 +0100 Subject: [PATCH 036/117] 8023139: java/nio/file/WatchService/SensitivityModifier.java failing intermittently (win8) Reviewed-by: alanb --- .../WatchService/SensitivityModifier.java | 104 +++++++++--------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/jdk/test/java/nio/file/WatchService/SensitivityModifier.java b/jdk/test/java/nio/file/WatchService/SensitivityModifier.java index 6f9a14cfd60..08722048b63 100644 --- a/jdk/test/java/nio/file/WatchService/SensitivityModifier.java +++ b/jdk/test/java/nio/file/WatchService/SensitivityModifier.java @@ -54,60 +54,66 @@ public class SensitivityModifier { @SuppressWarnings("unchecked") static void doTest(Path top) throws Exception { FileSystem fs = top.getFileSystem(); - WatchService watcher = fs.newWatchService(); + try (WatchService watcher = fs.newWatchService()) { - // create directories and files - int nDirs = 5 + rand.nextInt(20); - int nFiles = 50 + rand.nextInt(50); - Path[] dirs = new Path[nDirs]; - Path[] files = new Path[nFiles]; - for (int i=0; i event = key.pollEvents().iterator().next(); - if (event.kind() != ENTRY_MODIFY) - throw new RuntimeException("Unexpected event: " + event); - Path name = ((WatchEvent)event).context(); - if (!name.equals(file.getFileName())) - throw new RuntimeException("Unexpected context: " + name); - System.out.println("Event OK"); - // drain events (to avoid interference) - do { - key.pollEvents(); - key.reset(); - key = watcher.poll(1, TimeUnit.SECONDS); - } while (key != null); - - // re-register the directories to force changing their sensitivity - // level + // register the directories (random sensitivity) register(dirs, watcher); - } - // done - watcher.close(); + // sleep a bit here to ensure that modification to the first file + // can be detected by polling implementations (ie: last modified time + // may not change otherwise). + try { Thread.sleep(1000); } catch (InterruptedException e) { } + + // modify files and check that events are received + for (int i=0; i<10; i++) { + Path file = files[rand.nextInt(nFiles)]; + System.out.println("Modify: " + file); + try (OutputStream out = Files.newOutputStream(file)) { + out.write(new byte[100]); + } + + System.out.println("Waiting for event(s)..."); + boolean eventReceived = false; + WatchKey key = watcher.take(); + do { + for (WatchEvent event: key.pollEvents()) { + if (event.kind() != ENTRY_MODIFY) + throw new RuntimeException("Unexpected event: " + event); + Path name = ((WatchEvent)event).context(); + if (name.equals(file.getFileName())) { + eventReceived = true; + break; + } + } + key.reset(); + key = watcher.poll(1, TimeUnit.SECONDS); + } while (key != null && !eventReceived); + + // we should have received at least one ENTRY_MODIFY event + if (eventReceived) { + System.out.println("Event OK"); + } else { + throw new RuntimeException("No ENTRY_MODIFY event received for " + file); + } + + // re-register the directories to force changing their sensitivity + // level + register(dirs, watcher); + } + } } public static void main(String[] args) throws Exception { From 910d9b815cd7061261c72570c4d7eeddb0e2d3dc Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Sun, 25 Aug 2013 23:20:59 +0400 Subject: [PATCH 037/117] 7129312: BufferedInputStream calculates negative array size with large streams and mark Reviewed-by: alanb --- .../classes/java/io/BufferedInputStream.java | 19 ++- .../LargeCopyWithMark.java | 117 ++++++++++++++++++ 2 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java diff --git a/jdk/src/share/classes/java/io/BufferedInputStream.java b/jdk/src/share/classes/java/io/BufferedInputStream.java index a161a988109..fede2feeb7f 100644 --- a/jdk/src/share/classes/java/io/BufferedInputStream.java +++ b/jdk/src/share/classes/java/io/BufferedInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -50,7 +50,15 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; public class BufferedInputStream extends FilterInputStream { - private static int defaultBufferSize = 8192; + private static int DEFAULT_BUFFER_SIZE = 8192; + + /** + * The maximum size of array to allocate. + * Some VMs reserve some header words in an array. + * Attempts to allocate larger arrays may result in + * OutOfMemoryError: Requested array size exceeds VM limit + */ + private static int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; /** * The internal buffer array where the data is stored. When necessary, @@ -172,7 +180,7 @@ class BufferedInputStream extends FilterInputStream { * @param in the underlying input stream. */ public BufferedInputStream(InputStream in) { - this(in, defaultBufferSize); + this(in, DEFAULT_BUFFER_SIZE); } /** @@ -215,8 +223,11 @@ class BufferedInputStream extends FilterInputStream { } else if (buffer.length >= marklimit) { markpos = -1; /* buffer got too big, invalidate mark */ pos = 0; /* drop buffer contents */ + } else if (buffer.length >= MAX_BUFFER_SIZE) { + throw new OutOfMemoryError("Required array size too large"); } else { /* grow buffer */ - int nsz = pos * 2; + int nsz = (pos <= MAX_BUFFER_SIZE - pos) ? + pos * 2 : MAX_BUFFER_SIZE; if (nsz > marklimit) nsz = marklimit; byte nbuf[] = new byte[nsz]; diff --git a/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java b/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java new file mode 100644 index 00000000000..2555a1faa5f --- /dev/null +++ b/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java @@ -0,0 +1,117 @@ +/* + * 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 7129312 + * @summary BufferedInputStream calculates negative array size with large + * streams and mark + * @library /lib/testlibrary + * @run main/othervm LargeCopyWithMark + */ + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import static jdk.testlibrary.ProcessTools.*; + + +public class LargeCopyWithMark { + + public static void main(String[] args) throws Exception { + if (! System.getProperty("os.arch").contains("64")) { + System.out.println("Test runs on 64 bit platforms"); + return; + } + ProcessBuilder pb = createJavaProcessBuilder("-Xmx4G", + "-ea:LargeCopyWithMark$Child", + "LargeCopyWithMark$Child"); + int res = pb.inheritIO().start().waitFor(); + if (res != 0) { + throw new AssertionError("Test failed: exit code = " + res); + } + } + + public static class Child { + static final int BUFF_SIZE = 8192; + static final int BIS_BUFF_SIZE = Integer.MAX_VALUE / 2 + 100; + static final long BYTES_TO_COPY = 2L * Integer.MAX_VALUE; + + static { + assert BIS_BUFF_SIZE * 2 < 0 : "doubling must overflow"; + } + + public static void main(String[] args) throws Exception { + byte[] buff = new byte[BUFF_SIZE]; + + try (InputStream myis = new MyInputStream(BYTES_TO_COPY); + InputStream bis = new BufferedInputStream(myis, BIS_BUFF_SIZE); + OutputStream myos = new MyOutputStream()) { + + // will require a buffer bigger than BIS_BUFF_SIZE + bis.mark(BIS_BUFF_SIZE + 100); + + for (;;) { + int count = bis.read(buff, 0, BUFF_SIZE); + if (count == -1) + break; + myos.write(buff, 0, count); + } + } catch (java.lang.NegativeArraySizeException e) { + e.printStackTrace(); + System.exit(11); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} + +class MyInputStream extends InputStream { + private long bytesLeft; + public MyInputStream(long bytesLeft) { + this.bytesLeft = bytesLeft; + } + @Override public int read() throws IOException { + return 0; + } + @Override public int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } + @Override public int read(byte[] b, int off, int len) throws IOException { + if (bytesLeft <= 0) + return -1; + long result = Math.min(bytesLeft, (long)len); + bytesLeft -= result; + return (int)result; + } + @Override public int available() throws IOException { + return (bytesLeft > 0) ? 1 : 0; + } +} + +class MyOutputStream extends OutputStream { + @Override public void write(int b) throws IOException {} + @Override public void write(byte[] b) throws IOException {} + @Override public void write(byte[] b, int off, int len) throws IOException {} +} From d4b28471ff7518d2800568b0739249ab4037e22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Borggr=C3=A9n-Franck?= Date: Mon, 26 Aug 2013 13:38:14 +0200 Subject: [PATCH 038/117] 8022343: j.l.Class.getAnnotatedSuperclass() doesn't return null in some cases Reviewed-by: darcy, vromero, psandoz --- jdk/src/share/classes/java/lang/Class.java | 12 +++- .../annotation/TypeAnnotationReflection.java | 4 +- .../GetAnnotatedSuperclass.java | 56 +++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedSuperclass.java diff --git a/jdk/src/share/classes/java/lang/Class.java b/jdk/src/share/classes/java/lang/Class.java index 9df0805167b..a3c962e0838 100644 --- a/jdk/src/share/classes/java/lang/Class.java +++ b/jdk/src/share/classes/java/lang/Class.java @@ -3338,8 +3338,16 @@ public final class Class implements java.io.Serializable, * @since 1.8 */ public AnnotatedType getAnnotatedSuperclass() { - return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this); -} + if (this == Object.class || + isInterface() || + isArray() || + isPrimitive() || + this == Void.TYPE) { + return null; + } + + return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this); + } /** * Returns an array of AnnotatedType objects that represent the use of types to diff --git a/jdk/test/java/lang/annotation/TypeAnnotationReflection.java b/jdk/test/java/lang/annotation/TypeAnnotationReflection.java index 6b4d167ef80..2c7da746a7f 100644 --- a/jdk/test/java/lang/annotation/TypeAnnotationReflection.java +++ b/jdk/test/java/lang/annotation/TypeAnnotationReflection.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8004698 8007073 + * @bug 8004698 8007073 8022343 * @summary Unit test for type annotations */ @@ -58,7 +58,7 @@ public class TypeAnnotationReflection { } private static void testSuper() throws Exception { - check(Object.class.getAnnotatedSuperclass().getAnnotations().length == 0); + check(Object.class.getAnnotatedSuperclass() == null); check(Class.class.getAnnotatedSuperclass().getAnnotations().length == 0); AnnotatedType a; diff --git a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedSuperclass.java b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedSuperclass.java new file mode 100644 index 00000000000..d112203a90f --- /dev/null +++ b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedSuperclass.java @@ -0,0 +1,56 @@ +/* + * 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 8022343 + * @summary make sure Class.getAnnotatedSuperclass() returns null when specified to do so + */ + +public class GetAnnotatedSuperclass { + private static final Class[] testData = { + Object.class, + If.class, + Object[].class, + void.class, + int.class, + }; + + public static void main(String[] args) throws Exception { + int failed = 0; + for (Class toTest : testData) { + Object res = toTest.getAnnotatedSuperclass(); + + if (res != null) { + failed++; + System.out.println(toTest + ".getAnnotatedSuperclass() returns: " + + res + ", should be null"); + } + } + + if (failed != 0) + throw new RuntimeException("Test failed, check log for details"); + } + + interface If {} +} From 56dbd896c3173d6e0df7af1e92565e590b005869 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Mon, 26 Aug 2013 17:50:34 +0400 Subject: [PATCH 039/117] 8023234: StampedLock serializes readers on writer unlock Sync-up the fix from jsr166 CVS, signal more readers on writer unlock Reviewed-by: martin, shade --- .../util/concurrent/locks/StampedLock.java | 364 ++++++++++-------- .../ReadersUnlockAfterWriteUnlock.java | 88 +++++ 2 files changed, 286 insertions(+), 166 deletions(-) create mode 100644 jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java diff --git a/jdk/src/share/classes/java/util/concurrent/locks/StampedLock.java b/jdk/src/share/classes/java/util/concurrent/locks/StampedLock.java index 1506e5a4e46..5fe20b6a578 100644 --- a/jdk/src/share/classes/java/util/concurrent/locks/StampedLock.java +++ b/jdk/src/share/classes/java/util/concurrent/locks/StampedLock.java @@ -226,7 +226,11 @@ public class StampedLock implements java.io.Serializable { * incoming reader arrives while read lock is held but there is a * queued writer, this incoming reader is queued. (This rule is * responsible for some of the complexity of method acquireRead, - * but without it, the lock becomes highly unfair.) + * but without it, the lock becomes highly unfair.) Method release + * does not (and sometimes cannot) itself wake up cowaiters. This + * is done by the primary thread, but helped by any other threads + * with nothing better to do in methods acquireRead and + * acquireWrite. * * These rules apply to threads actually queued. All tryLock forms * opportunistically try to acquire locks regardless of preference @@ -267,11 +271,14 @@ public class StampedLock implements java.io.Serializable { /** Number of processors, for spin control */ private static final int NCPU = Runtime.getRuntime().availableProcessors(); - /** Maximum number of retries before blocking on acquisition */ + /** Maximum number of retries before enqueuing on acquisition */ private static final int SPINS = (NCPU > 1) ? 1 << 6 : 0; + /** Maximum number of retries before blocking at head on acquisition */ + private static final int HEAD_SPINS = (NCPU > 1) ? 1 << 10 : 0; + /** Maximum number of retries before re-blocking */ - private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 12 : 0; + private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 16 : 0; /** The period for yielding when waiting for overflow spinlock */ private static final int OVERFLOW_YIELD_RATE = 7; // must be power 2 - 1 @@ -415,8 +422,8 @@ public class StampedLock implements java.io.Serializable { * @return a stamp that can be used to unlock or convert mode */ public long readLock() { - long s, next; // bypass acquireRead on fully unlocked case only - return ((((s = state) & ABITS) == 0L && + long s = state, next; // bypass acquireRead on common uncontended case + return ((whead == wtail && (s & ABITS) < RFULL && U.compareAndSwapLong(this, STATE, s, next = s + RUNIT)) ? next : acquireRead(false, 0L)); } @@ -1012,17 +1019,8 @@ public class StampedLock implements java.io.Serializable { if (t.status <= 0) q = t; } - if (q != null) { - for (WNode r = q;;) { // release co-waiters too - if ((w = r.thread) != null) { - r.thread = null; - U.unpark(w); - } - if ((r = q.cowait) == null) - break; - U.compareAndSwapObject(q, WCOWAIT, r, r.cowait); - } - } + if (q != null && (w = q.thread) != null) + U.unpark(w); } } @@ -1038,22 +1036,22 @@ public class StampedLock implements java.io.Serializable { private long acquireWrite(boolean interruptible, long deadline) { WNode node = null, p; for (int spins = -1;;) { // spin while enqueuing - long s, ns; - if (((s = state) & ABITS) == 0L) { + long m, s, ns; + if ((m = (s = state) & ABITS) == 0L) { if (U.compareAndSwapLong(this, STATE, s, ns = s + WBIT)) return ns; } + else if (spins < 0) + spins = (m == WBIT && wtail == whead) ? SPINS : 0; else if (spins > 0) { if (LockSupport.nextSecondarySeed() >= 0) --spins; } else if ((p = wtail) == null) { // initialize queue - WNode h = new WNode(WMODE, null); - if (U.compareAndSwapObject(this, WHEAD, null, h)) - wtail = h; + WNode hd = new WNode(WMODE, null); + if (U.compareAndSwapObject(this, WHEAD, null, hd)) + wtail = hd; } - else if (spins < 0) - spins = (p == whead) ? SPINS : 0; else if (node == null) node = new WNode(WMODE, p); else if (node.prev != p) @@ -1064,14 +1062,18 @@ public class StampedLock implements java.io.Serializable { } } - for (int spins = SPINS;;) { - WNode np, pp; int ps; long s, ns; Thread w; - while ((np = node.prev) != p && np != null) - (p = np).next = node; // stale - if (whead == p) { + for (int spins = -1;;) { + WNode h, np, pp; int ps; + if ((h = whead) == p) { + if (spins < 0) + spins = HEAD_SPINS; + else if (spins < MAX_HEAD_SPINS) + spins <<= 1; for (int k = spins;;) { // spin at head + long s, ns; if (((s = state) & ABITS) == 0L) { - if (U.compareAndSwapLong(this, STATE, s, ns = s+WBIT)) { + if (U.compareAndSwapLong(this, STATE, s, + ns = s + WBIT)) { whead = node; node.prev = null; return ns; @@ -1081,33 +1083,45 @@ public class StampedLock implements java.io.Serializable { --k <= 0) break; } - if (spins < MAX_HEAD_SPINS) - spins <<= 1; } - if ((ps = p.status) == 0) - U.compareAndSwapInt(p, WSTATUS, 0, WAITING); - else if (ps == CANCELLED) { - if ((pp = p.prev) != null) { - node.prev = pp; - pp.next = node; + else if (h != null) { // help release stale waiters + WNode c; Thread w; + while ((c = h.cowait) != null) { + if (U.compareAndSwapObject(h, WCOWAIT, c, c.cowait) && + (w = c.thread) != null) + U.unpark(w); } } - else { - long time; // 0 argument to park means no timeout - if (deadline == 0L) - time = 0L; - else if ((time = deadline - System.nanoTime()) <= 0L) - return cancelWaiter(node, node, false); - Thread wt = Thread.currentThread(); - U.putObject(wt, PARKBLOCKER, this); // emulate LockSupport.park - node.thread = wt; - if (node.prev == p && p.status == WAITING && // recheck - (p != whead || (state & ABITS) != 0L)) - U.park(false, time); - node.thread = null; - U.putObject(wt, PARKBLOCKER, null); - if (interruptible && Thread.interrupted()) - return cancelWaiter(node, node, true); + if (whead == h) { + if ((np = node.prev) != p) { + if (np != null) + (p = np).next = node; // stale + } + else if ((ps = p.status) == 0) + U.compareAndSwapInt(p, WSTATUS, 0, WAITING); + else if (ps == CANCELLED) { + if ((pp = p.prev) != null) { + node.prev = pp; + pp.next = node; + } + } + else { + long time; // 0 argument to park means no timeout + if (deadline == 0L) + time = 0L; + else if ((time = deadline - System.nanoTime()) <= 0L) + return cancelWaiter(node, node, false); + Thread wt = Thread.currentThread(); + U.putObject(wt, PARKBLOCKER, this); + node.thread = wt; + if (p.status < 0 && (p != h || (state & ABITS) != 0L) && + whead == h && node.prev == p) + U.park(false, time); // emulate LockSupport.park + node.thread = null; + U.putObject(wt, PARKBLOCKER, null); + if (interruptible && Thread.interrupted()) + return cancelWaiter(node, node, true); + } } } } @@ -1122,138 +1136,159 @@ public class StampedLock implements java.io.Serializable { * @return next state, or INTERRUPTED */ private long acquireRead(boolean interruptible, long deadline) { - WNode node = null, group = null, p; + WNode node = null, p; for (int spins = -1;;) { - for (;;) { - long s, m, ns; WNode h, q; Thread w; // anti-barging guard - if (group == null && (h = whead) != null && - (q = h.next) != null && q.mode != RMODE) - break; - if ((m = (s = state) & ABITS) < RFULL ? - U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT) : - (m < WBIT && (ns = tryIncReaderOverflow(s)) != 0L)) { - if (group != null) { // help release others - for (WNode r = group;;) { - if ((w = r.thread) != null) { - r.thread = null; - U.unpark(w); + WNode h; + if ((h = whead) == (p = wtail)) { + for (long m, s, ns;;) { + if ((m = (s = state) & ABITS) < RFULL ? + U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT) : + (m < WBIT && (ns = tryIncReaderOverflow(s)) != 0L)) + return ns; + else if (m >= WBIT) { + if (spins > 0) { + if (LockSupport.nextSecondarySeed() >= 0) + --spins; + } + else { + if (spins == 0) { + WNode nh = whead, np = wtail; + if ((nh == h && np == p) || (h = nh) != (p = np)) + break; } - if ((r = group.cowait) == null) - break; - U.compareAndSwapObject(group, WCOWAIT, r, r.cowait); + spins = SPINS; } } - return ns; } - if (m >= WBIT) - break; } - if (spins > 0) { - if (LockSupport.nextSecondarySeed() >= 0) - --spins; + if (p == null) { // initialize queue + WNode hd = new WNode(WMODE, null); + if (U.compareAndSwapObject(this, WHEAD, null, hd)) + wtail = hd; } - else if ((p = wtail) == null) { - WNode h = new WNode(WMODE, null); - if (U.compareAndSwapObject(this, WHEAD, null, h)) - wtail = h; - } - else if (spins < 0) - spins = (p == whead) ? SPINS : 0; else if (node == null) - node = new WNode(WMODE, p); - else if (node.prev != p) - node.prev = p; - else if (p.mode == RMODE && p != whead) { - WNode pp = p.prev; // become co-waiter with group p - if (pp != null && p == wtail && - U.compareAndSwapObject(p, WCOWAIT, - node.cowait = p.cowait, node)) { - node.thread = Thread.currentThread(); - for (long time;;) { + node = new WNode(RMODE, p); + else if (h == p || p.mode != RMODE) { + if (node.prev != p) + node.prev = p; + else if (U.compareAndSwapObject(this, WTAIL, p, node)) { + p.next = node; + break; + } + } + else if (!U.compareAndSwapObject(p, WCOWAIT, + node.cowait = p.cowait, node)) + node.cowait = null; + else { + for (;;) { + WNode pp, c; Thread w; + if ((h = whead) != null && (c = h.cowait) != null && + U.compareAndSwapObject(h, WCOWAIT, c, c.cowait) && + (w = c.thread) != null) // help release + U.unpark(w); + if (h == (pp = p.prev) || h == p || pp == null) { + long m, s, ns; + do { + if ((m = (s = state) & ABITS) < RFULL ? + U.compareAndSwapLong(this, STATE, s, + ns = s + RUNIT) : + (m < WBIT && + (ns = tryIncReaderOverflow(s)) != 0L)) + return ns; + } while (m < WBIT); + } + if (whead == h && p.prev == pp) { + long time; + if (pp == null || h == p || p.status > 0) { + node = null; // throw away + break; + } if (deadline == 0L) time = 0L; else if ((time = deadline - System.nanoTime()) <= 0L) return cancelWaiter(node, p, false); - if (node.thread == null) - break; - if (p.prev != pp || p.status == CANCELLED || - p == whead || p.prev != pp) { - node.thread = null; - break; - } Thread wt = Thread.currentThread(); U.putObject(wt, PARKBLOCKER, this); - if (node.thread == null) // must recheck - break; - U.park(false, time); + node.thread = wt; + if ((h != pp || (state & ABITS) == WBIT) && + whead == h && p.prev == pp) + U.park(false, time); + node.thread = null; U.putObject(wt, PARKBLOCKER, null); if (interruptible && Thread.interrupted()) return cancelWaiter(node, p, true); } - group = p; } - node = null; // throw away - } - else if (U.compareAndSwapObject(this, WTAIL, p, node)) { - p.next = node; - break; } } - for (int spins = SPINS;;) { - WNode np, pp, r; int ps; long m, s, ns; Thread w; - while ((np = node.prev) != p && np != null) - (p = np).next = node; - if (whead == p) { - for (int k = spins;;) { - if ((m = (s = state) & ABITS) != WBIT) { - if (m < RFULL ? - U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT): - (ns = tryIncReaderOverflow(s)) != 0L) { - whead = node; - node.prev = null; - while ((r = node.cowait) != null) { - if (U.compareAndSwapObject(node, WCOWAIT, - r, r.cowait) && - (w = r.thread) != null) { - r.thread = null; - U.unpark(w); // release co-waiter - } - } - return ns; + for (int spins = -1;;) { + WNode h, np, pp; int ps; + if ((h = whead) == p) { + if (spins < 0) + spins = HEAD_SPINS; + else if (spins < MAX_HEAD_SPINS) + spins <<= 1; + for (int k = spins;;) { // spin at head + long m, s, ns; + if ((m = (s = state) & ABITS) < RFULL ? + U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT) : + (m < WBIT && (ns = tryIncReaderOverflow(s)) != 0L)) { + WNode c; Thread w; + whead = node; + node.prev = null; + while ((c = node.cowait) != null) { + if (U.compareAndSwapObject(node, WCOWAIT, + c, c.cowait) && + (w = c.thread) != null) + U.unpark(w); } + return ns; } - else if (LockSupport.nextSecondarySeed() >= 0 && - --k <= 0) + else if (m >= WBIT && + LockSupport.nextSecondarySeed() >= 0 && --k <= 0) break; } - if (spins < MAX_HEAD_SPINS) - spins <<= 1; } - if ((ps = p.status) == 0) - U.compareAndSwapInt(p, WSTATUS, 0, WAITING); - else if (ps == CANCELLED) { - if ((pp = p.prev) != null) { - node.prev = pp; - pp.next = node; + else if (h != null) { + WNode c; Thread w; + while ((c = h.cowait) != null) { + if (U.compareAndSwapObject(h, WCOWAIT, c, c.cowait) && + (w = c.thread) != null) + U.unpark(w); } } - else { - long time; - if (deadline == 0L) - time = 0L; - else if ((time = deadline - System.nanoTime()) <= 0L) - return cancelWaiter(node, node, false); - Thread wt = Thread.currentThread(); - U.putObject(wt, PARKBLOCKER, this); - node.thread = wt; - if (node.prev == p && p.status == WAITING && - (p != whead || (state & ABITS) != WBIT)) - U.park(false, time); - node.thread = null; - U.putObject(wt, PARKBLOCKER, null); - if (interruptible && Thread.interrupted()) - return cancelWaiter(node, node, true); + if (whead == h) { + if ((np = node.prev) != p) { + if (np != null) + (p = np).next = node; // stale + } + else if ((ps = p.status) == 0) + U.compareAndSwapInt(p, WSTATUS, 0, WAITING); + else if (ps == CANCELLED) { + if ((pp = p.prev) != null) { + node.prev = pp; + pp.next = node; + } + } + else { + long time; + if (deadline == 0L) + time = 0L; + else if ((time = deadline - System.nanoTime()) <= 0L) + return cancelWaiter(node, node, false); + Thread wt = Thread.currentThread(); + U.putObject(wt, PARKBLOCKER, this); + node.thread = wt; + if (p.status < 0 && + (p != h || (state & ABITS) == WBIT) && + whead == h && node.prev == p) + U.park(false, time); + node.thread = null; + U.putObject(wt, PARKBLOCKER, null); + if (interruptible && Thread.interrupted()) + return cancelWaiter(node, node, true); + } } } } @@ -1278,22 +1313,19 @@ public class StampedLock implements java.io.Serializable { if (node != null && group != null) { Thread w; node.status = CANCELLED; - node.thread = null; // unsplice cancelled nodes from group for (WNode p = group, q; (q = p.cowait) != null;) { - if (q.status == CANCELLED) - U.compareAndSwapObject(p, WNEXT, q, q.next); + if (q.status == CANCELLED) { + U.compareAndSwapObject(p, WCOWAIT, q, q.cowait); + p = group; // restart + } else p = q; } if (group == node) { - WNode r; // detach and wake up uncancelled co-waiters - while ((r = node.cowait) != null) { - if (U.compareAndSwapObject(node, WCOWAIT, r, r.cowait) && - (w = r.thread) != null) { - r.thread = null; - U.unpark(w); - } + for (WNode r = group.cowait; r != null; r = r.cowait) { + if ((w = r.thread) != null) + U.unpark(w); // wake up uncancelled co-waiters } for (WNode pred = node.prev; pred != null; ) { // unsplice WNode succ, pp; // find valid successor diff --git a/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java new file mode 100644 index 00000000000..6d459372515 --- /dev/null +++ b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java @@ -0,0 +1,88 @@ +/* + * 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 + * @run main/othervm/timeout=60 ReadersUnlockAfterWriteUnlock + * @bug 8023234 + * @summary StampedLock serializes readers on writer unlock + * @author Dmitry Chyuko + * @author Aleksey Shipilev + */ + +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.locks.StampedLock; + +public class ReadersUnlockAfterWriteUnlock { + static final int RNUM = 2; + static final StampedLock sl = new StampedLock(); + static volatile boolean isDone; + + static CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1); + static CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM); + static CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1); + + static class Reader extends Thread { + final String name; + Reader(String name) { + super(); + this.name = name; + } + public void run() { + while (!isDone && !isInterrupted()) { + try { + iterationStart.await(); + writerHasLock.await(); + long rs = sl.readLock(); + + // single reader blocks here indefinitely if readers + // are serialized + readersHaveLocks.await(); + + sl.unlockRead(rs); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + } + } + + public static void main(String[] args) throws InterruptedException { + for (int r = 0 ; r < RNUM; ++r) { + new Reader("r" + r).start(); + } + int i; + for (i = 0; i < 1024; ++i) { + try { + iterationStart.await(); + long ws = sl.writeLock(); + writerHasLock.await(); + Thread.sleep(10); + sl.unlockWrite(ws); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + isDone = true; + } + +} From e0b682f2d8b912abc0f94c00cecf1709f746bfc7 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Mon, 26 Aug 2013 11:46:05 -0400 Subject: [PATCH 040/117] 8011944: Sort fails with ArrayIndexOutOfBoundsException Increase the size of pending stack and add test cases Reviewed-by: alanb --- .../classes/java/util/ComparableTimSort.java | 3 +- jdk/src/share/classes/java/util/TimSort.java | 3 +- .../java/util/Arrays/TimSortStackSize.java | 116 ++++++++++++++++++ 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/util/Arrays/TimSortStackSize.java diff --git a/jdk/src/share/classes/java/util/ComparableTimSort.java b/jdk/src/share/classes/java/util/ComparableTimSort.java index 76b5fd56a00..e7c7ac020bd 100644 --- a/jdk/src/share/classes/java/util/ComparableTimSort.java +++ b/jdk/src/share/classes/java/util/ComparableTimSort.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2009 Google Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -146,7 +147,7 @@ class ComparableTimSort { */ int stackLen = (len < 120 ? 5 : len < 1542 ? 10 : - len < 119151 ? 19 : 40); + len < 119151 ? 24 : 40); runBase = new int[stackLen]; runLen = new int[stackLen]; } diff --git a/jdk/src/share/classes/java/util/TimSort.java b/jdk/src/share/classes/java/util/TimSort.java index 35493ff0bd6..9966f74df37 100644 --- a/jdk/src/share/classes/java/util/TimSort.java +++ b/jdk/src/share/classes/java/util/TimSort.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright 2009 Google Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -176,7 +177,7 @@ class TimSort { */ int stackLen = (len < 120 ? 5 : len < 1542 ? 10 : - len < 119151 ? 19 : 40); + len < 119151 ? 24 : 40); runBase = new int[stackLen]; runLen = new int[stackLen]; } diff --git a/jdk/test/java/util/Arrays/TimSortStackSize.java b/jdk/test/java/util/Arrays/TimSortStackSize.java new file mode 100644 index 00000000000..c05cc52a163 --- /dev/null +++ b/jdk/test/java/util/Arrays/TimSortStackSize.java @@ -0,0 +1,116 @@ +/* + * 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 8011944 + * @summary Test TimSort stack size + */ +import java.util.Arrays; +import java.util.ArrayDeque; + +public class TimSortStackSize { + + public static void main(String[] args) { + testComparableTimSort(); + testTimSort(); + } + + static void testComparableTimSort() { + System.out.printf("testComparableTimSort()%n"); + Arrays.sort(genData()); + } + + static void testTimSort() { + System.out.printf("testTimSort()%n"); + Arrays.sort(genData(), Integer::compare); + } + + private static final int MIN = 16; + + private static final int BOUND1 = 2 * MIN + 1; + private static final int BOUND2 = BOUND1 + MIN + 2; + private static final int BOUND3 = BOUND1 + 1 + BOUND2; + private static final int BOUND4 = BOUND2 + 1 + BOUND3; + private static final int BOUND5 = BOUND3 + 1 + BOUND4; + + static int build(int size, int B, ArrayDeque chunks) { + chunks.addFirst(B); + if (size < BOUND1) { + chunks.addFirst(size); + return size; + } + + int asize = (size + 2) / 2; + if (size >= BOUND2 && asize < BOUND1) { + asize = BOUND1; + } else if (size >= BOUND3 && asize < BOUND2) { + asize = BOUND2; + } else if (size >= BOUND4 && asize < BOUND3) { + asize = BOUND3; + } else if (size >= BOUND5 && asize < BOUND4) { + asize = BOUND4; + } + if (size - asize >= B) { + throw new AssertionError(" " + size + " , " + asize + " , " + B); + } + return build(asize, size - asize, chunks); + } + + static Integer[] genData() { + ArrayDeque chunks = new ArrayDeque(); + chunks.addFirst(MIN); + + int B = MIN + 4; + int A = B + MIN + 1; + + for (int i = 0; i < 8; i++) { + int eps = build(A, B, chunks); + B = B + A + 1; + A = B + eps + 1; + } + chunks.addFirst(B); + chunks.addFirst(A); + int total = 0; + for (Integer len : chunks) { + total += len; + } + int pow = MIN; + while (pow < total) { + pow += pow; + } + chunks.addLast(pow - total); + System.out.println(" Total: " + total); + Integer[] array = new Integer[pow]; + int off = 0; + int pos = 0; + for (Integer len : chunks) { + for (int i = 0; i < len; i++) { + array[pos++] = Integer.valueOf(i == 0 ? 0 : 1); + } + off++; + } + return array; + } + +} From 86af118ec0e78d3228fbd5647981005034a61ceb Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Mon, 26 Aug 2013 18:26:35 +0400 Subject: [PATCH 041/117] 8016018: Typo in AbstractStringBuilder#indexOf and #lastIndexOf descriptions Reviewed-by: alanb, chegar --- jdk/src/share/classes/java/lang/AbstractStringBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java index a5bde616f8a..3260da6ae99 100644 --- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java +++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java @@ -1307,7 +1307,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * specified substring, starting at the specified index. The integer * returned is the smallest value {@code k} for which: *
-     *     k >= Math.min(fromIndex, str.length()) &&
+     *     k >= Math.min(fromIndex, this.length()) &&
      *                   this.toString().startsWith(str, k)
      * 
* If no such value of k exists, then -1 is returned. @@ -1346,7 +1346,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { * specified substring. The integer returned is the largest value k * such that: *
-     *     k <= Math.min(fromIndex, str.length()) &&
+     *     k <= Math.min(fromIndex, this.length()) &&
      *                   this.toString().startsWith(str, k)
      * 
* If no such value of k exists, then -1 is returned. From 5c937b723c0325ed52203efa9e707780b60dc57a Mon Sep 17 00:00:00 2001 From: Bill Pittore Date: Mon, 26 Aug 2013 11:27:48 -0400 Subject: [PATCH 042/117] 8014135: The JVMTI specification does not conform to recent changes in JNI specification Added support for statically linked agents Reviewed-by: alanb, sspitsyn, bobv, coleenp --- .../com/sun/tools/attach/VirtualMachine.java | 81 ++++++++++++------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java b/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java index aad0be2cfc9..29464d88da6 100644 --- a/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java +++ b/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -59,7 +59,7 @@ import java.io.IOException; * {@link java.lang.instrument} for a detailed description on how these agents * are loaded and started). The {@link #loadAgentLibrary loadAgentLibrary} and * {@link #loadAgentPath loadAgentPath} methods are used to load agents that - * are deployed in a dynamic library and make use of the JVM Tools * Interface.

* @@ -298,25 +298,29 @@ public abstract class VirtualMachine { *

A JVM * TI client is called an agent. It is developed in a native language. * A JVM TI agent is deployed in a platform specific manner but it is typically the - * platform equivalent of a dynamic library. This method causes the given agent - * library to be loaded into the target VM (if not already loaded). + * platform equivalent of a dynamic library. Alternatively, it may be statically linked into the VM. + * This method causes the given agent library to be loaded into the target + * VM (if not already loaded or if not statically linked into the VM). * It then causes the target VM to invoke the Agent_OnAttach function + * or, for a statically linked agent named 'L', the Agent_OnAttach_L function * as specified in the * JVM Tools - * Interface specification. Note that the Agent_OnAttach + * Interface specification. Note that the Agent_OnAttach[_L] * function is invoked even if the agent library was loaded prior to invoking * this method. * *

The agent library provided is the name of the agent library. It is interpreted * in the target virtual machine in an implementation-dependent manner. Typically an * implementation will expand the library name into an operating system specific file - * name. For example, on UNIX systems, the name foo might be expanded to - * libfoo.so, and located using the search path specified by the - * LD_LIBRARY_PATH environment variable.

+ * name. For example, on UNIX systems, the name L might be expanded to + * libL.so, and located using the search path specified by the + * LD_LIBRARY_PATH environment variable. If the agent named 'L' is + * statically linked into the VM then the VM must export a function named + * Agent_OnAttach_L.

* - *

If the Agent_OnAttach function in the agent library returns + *

If the Agent_OnAttach[_L] function in the agent library returns * an error then an {@link com.sun.tools.attach.AgentInitializationException} is - * thrown. The return value from the Agent_OnAttach can then be + * thrown. The return value from the Agent_OnAttach[_L] can then be * obtained by invoking the {@link * com.sun.tools.attach.AgentInitializationException#returnValue() returnValue} * method on the exception.

@@ -325,15 +329,16 @@ public abstract class VirtualMachine { * The name of the agent library. * * @param options - * The options to provide to the Agent_OnAttach + * The options to provide to the Agent_OnAttach[_L] * function (can be null). * * @throws AgentLoadException - * If the agent library does not exist, or cannot be loaded for - * another reason. + * If the agent library does not exist, the agent library is not + * statically linked with the VM, or the agent library cannot be + * loaded for another reason. * * @throws AgentInitializationException - * If the Agent_OnAttach function returns an error + * If the Agent_OnAttach[_L] function returns an error. * * @throws IOException * If an I/O error occurs @@ -359,11 +364,12 @@ public abstract class VirtualMachine { * The name of the agent library. * * @throws AgentLoadException - * If the agent library does not exist, or cannot be loaded for - * another reason. + * If the agent library does not exist, the agent library is not + * statically linked with the VM, or the agent library cannot be + * loaded for another reason. * * @throws AgentInitializationException - * If the Agent_OnAttach function returns an error + * If the Agent_OnAttach[_L] function returns an error. * * @throws IOException * If an I/O error occurs @@ -383,12 +389,23 @@ public abstract class VirtualMachine { *

A JVM * TI client is called an agent. It is developed in a native language. * A JVM TI agent is deployed in a platform specific manner but it is typically the - * platform equivalent of a dynamic library. This method causes the given agent - * library to be loaded into the target VM (if not already loaded). - * It then causes the target VM to invoke the Agent_OnAttach function - * as specified in the + * platform equivalent of a dynamic library. Alternatively, the native + * library specified by the agentPath parameter may be statically + * linked with the VM. The parsing of the agentPath parameter into + * a statically linked library name is done in a platform + * specific manner in the VM. For example, in UNIX, an agentPath parameter + * of /a/b/libL.so would name a library 'L'. + * + * See the JVM TI Specification for more details. + * + * This method causes the given agent library to be loaded into the target + * VM (if not already loaded or if not statically linked into the VM). + * It then causes the target VM to invoke the Agent_OnAttach + * function or, for a statically linked agent named 'L', the + * Agent_OnAttach_L function as specified in the * JVM Tools - * Interface specification. Note that the Agent_OnAttach + * Interface specification. + * Note that the Agent_OnAttach[_L] * function is invoked even if the agent library was loaded prior to invoking * this method. * @@ -396,9 +413,9 @@ public abstract class VirtualMachine { * agent library. Unlike {@link #loadAgentLibrary loadAgentLibrary}, the library name * is not expanded in the target virtual machine.

* - *

If the Agent_OnAttach function in the agent library returns + *

If the Agent_OnAttach[_L] function in the agent library returns * an error then an {@link com.sun.tools.attach.AgentInitializationException} is - * thrown. The return value from the Agent_OnAttach can then be + * thrown. The return value from the Agent_OnAttach[_L] can then be * obtained by invoking the {@link * com.sun.tools.attach.AgentInitializationException#returnValue() returnValue} * method on the exception.

@@ -407,15 +424,16 @@ public abstract class VirtualMachine { * The full path of the agent library. * * @param options - * The options to provide to the Agent_OnAttach + * The options to provide to the Agent_OnAttach[_L] * function (can be null). * * @throws AgentLoadException - * If the agent library does not exist, or cannot be loaded for - * another reason. + * If the agent library does not exist, the agent library is not + * statically linked with the VM, or the agent library cannot be + * loaded for another reason. * * @throws AgentInitializationException - * If the Agent_OnAttach function returns an error + * If the Agent_OnAttach[_L] function returns an error. * * @throws IOException * If an I/O error occurs @@ -441,11 +459,12 @@ public abstract class VirtualMachine { * The full path to the agent library. * * @throws AgentLoadException - * If the agent library does not exist, or cannot be loaded for - * another reason. + * If the agent library does not exist, the agent library is not + * statically linked with the VM, or the agent library cannot be + * loaded for another reason. * * @throws AgentInitializationException - * If the Agent_OnAttach function returns an error + * If the Agent_OnAttach[_L] function returns an error. * * @throws IOException * If an I/O error occurs From 231a351a47d4d3fb8034115584bef6847486bc68 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Mon, 26 Aug 2013 22:55:03 +0200 Subject: [PATCH 043/117] 8020292: j.u.SplittableRandom Co-authored-by: Guy Steele Co-authored-by: Doug Lea Co-authored-by: Brian Goetz Reviewed-by: mduigou --- .../classes/java/util/SplittableRandom.java | 1002 +++++++++++++++++ .../SplittableRandomTest.java | 511 +++++++++ .../tests/java/util/SplittableRandomTest.java | 367 ++++++ 3 files changed, 1880 insertions(+) create mode 100644 jdk/src/share/classes/java/util/SplittableRandom.java create mode 100644 jdk/test/java/util/SplittableRandom/SplittableRandomTest.java create mode 100644 jdk/test/java/util/stream/test/org/openjdk/tests/java/util/SplittableRandomTest.java diff --git a/jdk/src/share/classes/java/util/SplittableRandom.java b/jdk/src/share/classes/java/util/SplittableRandom.java new file mode 100644 index 00000000000..5a990f4d215 --- /dev/null +++ b/jdk/src/share/classes/java/util/SplittableRandom.java @@ -0,0 +1,1002 @@ +/* + * 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 java.util; + +import java.security.SecureRandom; +import java.net.InetAddress; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.IntConsumer; +import java.util.function.LongConsumer; +import java.util.function.DoubleConsumer; +import java.util.stream.StreamSupport; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.DoubleStream; + +/** + * A generator of uniform pseudorandom values applicable for use in + * (among other contexts) isolated parallel computations that may + * generate subtasks. Class {@code SplittableRandom} supports methods for + * producing pseudorandom numbers of type {@code int}, {@code long}, + * and {@code double} with similar usages as for class + * {@link java.util.Random} but differs in the following ways: + * + *
    + * + *
  • Series of generated values pass the DieHarder suite testing + * independence and uniformity properties of random number generators. + * (Most recently validated with version + * 3.31.1.) These tests validate only the methods for certain + * types and ranges, but similar properties are expected to hold, at + * least approximately, for others as well. The period + * (length of any series of generated values before it repeats) is at + * least 264.
  • + * + *
  • Method {@link #split} constructs and returns a new + * SplittableRandom instance that shares no mutable state with the + * current instance. However, with very high probability, the + * values collectively generated by the two objects have the same + * statistical properties as if the same quantity of values were + * generated by a single thread using a single {@code + * SplittableRandom} object.
  • + * + *
  • Instances of SplittableRandom are not thread-safe. + * They are designed to be split, not shared, across threads. For + * example, a {@link java.util.concurrent.ForkJoinTask + * fork/join-style} computation using random numbers might include a + * construction of the form {@code new + * Subtask(aSplittableRandom.split()).fork()}. + * + *
  • This class provides additional methods for generating random + * streams, that employ the above techniques when used in {@code + * stream.parallel()} mode.
  • + * + *
+ * + *

Instances of {@code SplittableRandom} are not cryptographically + * secure. Consider instead using {@link java.security.SecureRandom} + * in security-sensitive applications. Additionally, + * default-constructed instances do not use a cryptographically random + * seed unless the {@linkplain System#getProperty system property} + * {@code java.util.secureRandomSeed} is set to {@code true}. + * + * @author Guy Steele + * @author Doug Lea + * @since 1.8 + */ +public final class SplittableRandom { + + /* + * Implementation Overview. + * + * This algorithm was inspired by the "DotMix" algorithm by + * Leiserson, Schardl, and Sukha "Deterministic Parallel + * Random-Number Generation for Dynamic-Multithreading Platforms", + * PPoPP 2012, as well as those in "Parallel random numbers: as + * easy as 1, 2, 3" by Salmon, Morae, Dror, and Shaw, SC 2011. It + * differs mainly in simplifying and cheapening operations. + * + * The primary update step (method nextSeed()) is to add a + * constant ("gamma") to the current (64 bit) seed, forming a + * simple sequence. The seed and the gamma values for any two + * SplittableRandom instances are highly likely to be different. + * + * Methods nextLong, nextInt, and derivatives do not return the + * sequence (seed) values, but instead a hash-like bit-mix of + * their bits, producing more independently distributed sequences. + * For nextLong, the mix64 bit-mixing function computes the same + * value as the "64-bit finalizer" function in Austin Appleby's + * MurmurHash3 algorithm. See + * http://code.google.com/p/smhasher/wiki/MurmurHash3 , which + * comments: "The constants for the finalizers were generated by a + * simple simulated-annealing algorithm, and both avalanche all + * bits of 'h' to within 0.25% bias." The mix32 function is + * equivalent to (int)(mix64(seed) >>> 32), but faster because it + * omits a step that doesn't contribute to result. + * + * The split operation uses the current generator to form the seed + * and gamma for another SplittableRandom. To conservatively + * avoid potential correlations between seed and value generation, + * gamma selection (method nextGamma) uses the "Mix13" constants + * for MurmurHash3 described by David Stafford + * (http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html) + * To avoid potential weaknesses in bit-mixing transformations, we + * restrict gammas to odd values with at least 12 and no more than + * 52 bits set. Rather than rejecting candidates with too few or + * too many bits set, method nextGamma flips some bits (which has + * the effect of mapping at most 4 to any given gamma value). + * This reduces the effective set of 64bit odd gamma values by + * about 214, a very tiny percentage, and serves as an + * automated screening for sequence constant selection that is + * left as an empirical decision in some other hashing and crypto + * algorithms. + * + * The resulting generator thus transforms a sequence in which + * (typically) many bits change on each step, with an inexpensive + * mixer with good (but less than cryptographically secure) + * avalanching. + * + * The default (no-argument) constructor, in essence, invokes + * split() for a common "seeder" SplittableRandom. Unlike other + * cases, this split must be performed in a thread-safe manner, so + * we use an AtomicLong to represent the seed rather than use an + * explicit SplittableRandom. To bootstrap the seeder, we start + * off using a seed based on current time and host unless the + * java.util.secureRandomSeed property is set. This serves as a + * slimmed-down (and insecure) variant of SecureRandom that also + * avoids stalls that may occur when using /dev/random. + * + * It is a relatively simple matter to apply the basic design here + * to use 128 bit seeds. However, emulating 128bit arithmetic and + * carrying around twice the state add more overhead than appears + * warranted for current usages. + * + * File organization: First the non-public methods that constitute + * the main algorithm, then the main public methods, followed by + * some custom spliterator classes needed for stream methods. + */ + + /** + * The initial gamma value for (unsplit) SplittableRandoms. Must + * be odd with at least 12 and no more than 52 bits set. Currently + * set to the golden ratio scaled to 64bits. + */ + private static final long INITIAL_GAMMA = 0x9e3779b97f4a7c15L; + + /** + * The least non-zero value returned by nextDouble(). This value + * is scaled by a random value of 53 bits to produce a result. + */ + private static final double DOUBLE_UNIT = 1.0 / (1L << 53); + + /** + * The seed. Updated only via method nextSeed. + */ + private long seed; + + /** + * The step value. + */ + private final long gamma; + + /** + * Internal constructor used by all others except default constructor. + */ + private SplittableRandom(long seed, long gamma) { + this.seed = seed; + this.gamma = gamma; + } + + /** + * Computes MurmurHash3 64bit mix function. + */ + private static long mix64(long z) { + z = (z ^ (z >>> 33)) * 0xff51afd7ed558ccdL; + z = (z ^ (z >>> 33)) * 0xc4ceb9fe1a85ec53L; + return z ^ (z >>> 33); + } + + /** + * Returns the 32 high bits of mix64(z) as int. + */ + private static int mix32(long z) { + z = (z ^ (z >>> 33)) * 0xff51afd7ed558ccdL; + return (int)(((z ^ (z >>> 33)) * 0xc4ceb9fe1a85ec53L) >>> 32); + } + + /** + * Returns the gamma value to use for a new split instance. + */ + private static long nextGamma(long z) { + z = (z ^ (z >>> 30)) * 0xbf58476d1ce4e5b9L; // Stafford "Mix13" + z = (z ^ (z >>> 27)) * 0x94d049bb133111ebL; + z = (z ^ (z >>> 31)) | 1L; // force to be odd + int n = Long.bitCount(z); // ensure enough 0 and 1 bits + return (n < 12 || n > 52) ? z ^ 0xaaaaaaaaaaaaaaaaL : z; + } + + /** + * Adds gamma to seed. + */ + private long nextSeed() { + return seed += gamma; + } + + /** + * The seed generator for default constructors. + */ + private static final AtomicLong seeder = new AtomicLong(initialSeed()); + + private static long initialSeed() { + String pp = java.security.AccessController.doPrivileged( + new sun.security.action.GetPropertyAction( + "java.util.secureRandomSeed")); + if (pp != null && pp.equalsIgnoreCase("true")) { + byte[] seedBytes = java.security.SecureRandom.getSeed(8); + long s = (long)(seedBytes[0]) & 0xffL; + for (int i = 1; i < 8; ++i) + s = (s << 8) | ((long)(seedBytes[i]) & 0xffL); + return s; + } + int hh = 0; // hashed host address + try { + hh = InetAddress.getLocalHost().hashCode(); + } catch (Exception ignore) { + } + return (mix64((((long)hh) << 32) ^ System.currentTimeMillis()) ^ + mix64(System.nanoTime())); + } + + // IllegalArgumentException messages + static final String BadBound = "bound must be positive"; + static final String BadRange = "bound must be greater than origin"; + static final String BadSize = "size must be non-negative"; + + /* + * Internal versions of nextX methods used by streams, as well as + * the public nextX(origin, bound) methods. These exist mainly to + * avoid the need for multiple versions of stream spliterators + * across the different exported forms of streams. + */ + + /** + * The form of nextLong used by LongStream Spliterators. If + * origin is greater than bound, acts as unbounded form of + * nextLong, else as bounded form. + * + * @param origin the least value, unless greater than bound + * @param bound the upper bound (exclusive), must not equal origin + * @return a pseudorandom value + */ + final long internalNextLong(long origin, long bound) { + /* + * Four Cases: + * + * 1. If the arguments indicate unbounded form, act as + * nextLong(). + * + * 2. If the range is an exact power of two, apply the + * associated bit mask. + * + * 3. If the range is positive, loop to avoid potential bias + * when the implicit nextLong() bound (264) is not + * evenly divisible by the range. The loop rejects candidates + * computed from otherwise over-represented values. The + * expected number of iterations under an ideal generator + * varies from 1 to 2, depending on the bound. The loop itself + * takes an unlovable form. Because the first candidate is + * already available, we need a break-in-the-middle + * construction, which is concisely but cryptically performed + * within the while-condition of a body-less for loop. + * + * 4. Otherwise, the range cannot be represented as a positive + * long. The loop repeatedly generates unbounded longs until + * obtaining a candidate meeting constraints (with an expected + * number of iterations of less than two). + */ + + long r = mix64(nextSeed()); + if (origin < bound) { + long n = bound - origin, m = n - 1; + if ((n & m) == 0L) // power of two + r = (r & m) + origin; + else if (n > 0L) { // reject over-represented candidates + for (long u = r >>> 1; // ensure nonnegative + u + m - (r = u % n) < 0L; // rejection check + u = mix64(nextSeed()) >>> 1) // retry + ; + r += origin; + } + else { // range not representable as long + while (r < origin || r >= bound) + r = mix64(nextSeed()); + } + } + return r; + } + + /** + * The form of nextInt used by IntStream Spliterators. + * Exactly the same as long version, except for types. + * + * @param origin the least value, unless greater than bound + * @param bound the upper bound (exclusive), must not equal origin + * @return a pseudorandom value + */ + final int internalNextInt(int origin, int bound) { + int r = mix32(nextSeed()); + if (origin < bound) { + int n = bound - origin, m = n - 1; + if ((n & m) == 0) + r = (r & m) + origin; + else if (n > 0) { + for (int u = r >>> 1; + u + m - (r = u % n) < 0; + u = mix32(nextSeed()) >>> 1) + ; + r += origin; + } + else { + while (r < origin || r >= bound) + r = mix32(nextSeed()); + } + } + return r; + } + + /** + * The form of nextDouble used by DoubleStream Spliterators. + * + * @param origin the least value, unless greater than bound + * @param bound the upper bound (exclusive), must not equal origin + * @return a pseudorandom value + */ + final double internalNextDouble(double origin, double bound) { + double r = (nextLong() >>> 11) * DOUBLE_UNIT; + if (origin < bound) { + r = r * (bound - origin) + origin; + if (r >= bound) // correct for rounding + r = Double.longBitsToDouble(Double.doubleToLongBits(bound) - 1); + } + return r; + } + + /* ---------------- public methods ---------------- */ + + /** + * Creates a new SplittableRandom instance using the specified + * initial seed. SplittableRandom instances created with the same + * seed in the same program generate identical sequences of values. + * + * @param seed the initial seed + */ + public SplittableRandom(long seed) { + this(seed, INITIAL_GAMMA); + } + + /** + * Creates a new SplittableRandom instance that is likely to + * generate sequences of values that are statistically independent + * of those of any other instances in the current program; and + * may, and typically does, vary across program invocations. + */ + public SplittableRandom() { // emulate seeder.split() + this.gamma = nextGamma(this.seed = seeder.addAndGet(INITIAL_GAMMA)); + } + + /** + * Constructs and returns a new SplittableRandom instance that + * shares no mutable state with this instance. However, with very + * high probability, the set of values collectively generated by + * the two objects has the same statistical properties as if the + * same quantity of values were generated by a single thread using + * a single SplittableRandom object. Either or both of the two + * objects may be further split using the {@code split()} method, + * and the same expected statistical properties apply to the + * entire set of generators constructed by such recursive + * splitting. + * + * @return the new SplittableRandom instance + */ + public SplittableRandom split() { + long s = nextSeed(); + return new SplittableRandom(s, nextGamma(s)); + } + + /** + * Returns a pseudorandom {@code int} value. + * + * @return a pseudorandom {@code int} value + */ + public int nextInt() { + return mix32(nextSeed()); + } + + /** + * Returns a pseudorandom {@code int} value between zero (inclusive) + * and the specified bound (exclusive). + * + * @param bound the upper bound (exclusive). Must be positive. + * @return a pseudorandom {@code int} value between zero + * (inclusive) and the bound (exclusive) + * @throws IllegalArgumentException if {@code bound} is not positive + */ + public int nextInt(int bound) { + if (bound <= 0) + throw new IllegalArgumentException(BadBound); + // Specialize internalNextInt for origin 0 + int r = mix32(nextSeed()); + int m = bound - 1; + if ((bound & m) == 0) // power of two + r &= m; + else { // reject over-represented candidates + for (int u = r >>> 1; + u + m - (r = u % bound) < 0; + u = mix32(nextSeed()) >>> 1) + ; + } + return r; + } + + /** + * Returns a pseudorandom {@code int} value between the specified + * origin (inclusive) and the specified bound (exclusive). + * + * @param origin the least value returned + * @param bound the upper bound (exclusive) + * @return a pseudorandom {@code int} value between the origin + * (inclusive) and the bound (exclusive) + * @throws IllegalArgumentException if {@code origin} is greater than + * or equal to {@code bound} + */ + public int nextInt(int origin, int bound) { + if (origin >= bound) + throw new IllegalArgumentException(BadRange); + return internalNextInt(origin, bound); + } + + /** + * Returns a pseudorandom {@code long} value. + * + * @return a pseudorandom {@code long} value + */ + public long nextLong() { + return mix64(nextSeed()); + } + + /** + * Returns a pseudorandom {@code long} value between zero (inclusive) + * and the specified bound (exclusive). + * + * @param bound the upper bound (exclusive). Must be positive. + * @return a pseudorandom {@code long} value between zero + * (inclusive) and the bound (exclusive) + * @throws IllegalArgumentException if {@code bound} is not positive + */ + public long nextLong(long bound) { + if (bound <= 0) + throw new IllegalArgumentException(BadBound); + // Specialize internalNextLong for origin 0 + long r = mix64(nextSeed()); + long m = bound - 1; + if ((bound & m) == 0L) // power of two + r &= m; + else { // reject over-represented candidates + for (long u = r >>> 1; + u + m - (r = u % bound) < 0L; + u = mix64(nextSeed()) >>> 1) + ; + } + return r; + } + + /** + * Returns a pseudorandom {@code long} value between the specified + * origin (inclusive) and the specified bound (exclusive). + * + * @param origin the least value returned + * @param bound the upper bound (exclusive) + * @return a pseudorandom {@code long} value between the origin + * (inclusive) and the bound (exclusive) + * @throws IllegalArgumentException if {@code origin} is greater than + * or equal to {@code bound} + */ + public long nextLong(long origin, long bound) { + if (origin >= bound) + throw new IllegalArgumentException(BadRange); + return internalNextLong(origin, bound); + } + + /** + * Returns a pseudorandom {@code double} value between zero + * (inclusive) and one (exclusive). + * + * @return a pseudorandom {@code double} value between zero + * (inclusive) and one (exclusive) + */ + public double nextDouble() { + return (mix64(nextSeed()) >>> 11) * DOUBLE_UNIT; + } + + /** + * Returns a pseudorandom {@code double} value between 0.0 + * (inclusive) and the specified bound (exclusive). + * + * @param bound the upper bound (exclusive). Must be positive. + * @return a pseudorandom {@code double} value between zero + * (inclusive) and the bound (exclusive) + * @throws IllegalArgumentException if {@code bound} is not positive + */ + public double nextDouble(double bound) { + if (!(bound > 0.0)) + throw new IllegalArgumentException(BadBound); + double result = (mix64(nextSeed()) >>> 11) * DOUBLE_UNIT * bound; + return (result < bound) ? result : // correct for rounding + Double.longBitsToDouble(Double.doubleToLongBits(bound) - 1); + } + + /** + * Returns a pseudorandom {@code double} value between the specified + * origin (inclusive) and bound (exclusive). + * + * @param origin the least value returned + * @param bound the upper bound (exclusive) + * @return a pseudorandom {@code double} value between the origin + * (inclusive) and the bound (exclusive) + * @throws IllegalArgumentException if {@code origin} is greater than + * or equal to {@code bound} + */ + public double nextDouble(double origin, double bound) { + if (!(origin < bound)) + throw new IllegalArgumentException(BadRange); + return internalNextDouble(origin, bound); + } + + /** + * Returns a pseudorandom {@code boolean} value. + * + * @return a pseudorandom {@code boolean} value + */ + public boolean nextBoolean() { + return mix32(nextSeed()) < 0; + } + + // stream methods, coded in a way intended to better isolate for + // maintenance purposes the small differences across forms. + + /** + * Returns a stream producing the given {@code streamSize} number + * of pseudorandom {@code int} values from this generator and/or + * one split from it. + * + * @param streamSize the number of values to generate + * @return a stream of pseudorandom {@code int} values + * @throws IllegalArgumentException if {@code streamSize} is + * less than zero + */ + public IntStream ints(long streamSize) { + if (streamSize < 0L) + throw new IllegalArgumentException(BadSize); + return StreamSupport.intStream + (new RandomIntsSpliterator + (this, 0L, streamSize, Integer.MAX_VALUE, 0), + false); + } + + /** + * Returns an effectively unlimited stream of pseudorandom {@code int} + * values from this generator and/or one split from it. + * + * @implNote This method is implemented to be equivalent to {@code + * ints(Long.MAX_VALUE)}. + * + * @return a stream of pseudorandom {@code int} values + */ + public IntStream ints() { + return StreamSupport.intStream + (new RandomIntsSpliterator + (this, 0L, Long.MAX_VALUE, Integer.MAX_VALUE, 0), + false); + } + + /** + * Returns a stream producing the given {@code streamSize} number + * of pseudorandom {@code int} values from this generator and/or one split + * from it; each value conforms to the given origin (inclusive) and bound + * (exclusive). + * + * @param streamSize the number of values to generate + * @param randomNumberOrigin the origin (inclusive) of each random value + * @param randomNumberBound the bound (exclusive) of each random value + * @return a stream of pseudorandom {@code int} values, + * each with the given origin (inclusive) and bound (exclusive) + * @throws IllegalArgumentException if {@code streamSize} is + * less than zero, or {@code randomNumberOrigin} + * is greater than or equal to {@code randomNumberBound} + */ + public IntStream ints(long streamSize, int randomNumberOrigin, + int randomNumberBound) { + if (streamSize < 0L) + throw new IllegalArgumentException(BadSize); + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(BadRange); + return StreamSupport.intStream + (new RandomIntsSpliterator + (this, 0L, streamSize, randomNumberOrigin, randomNumberBound), + false); + } + + /** + * Returns an effectively unlimited stream of pseudorandom {@code + * int} values from this generator and/or one split from it; each value + * conforms to the given origin (inclusive) and bound (exclusive). + * + * @implNote This method is implemented to be equivalent to {@code + * ints(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound)}. + * + * @param randomNumberOrigin the origin (inclusive) of each random value + * @param randomNumberBound the bound (exclusive) of each random value + * @return a stream of pseudorandom {@code int} values, + * each with the given origin (inclusive) and bound (exclusive) + * @throws IllegalArgumentException if {@code randomNumberOrigin} + * is greater than or equal to {@code randomNumberBound} + */ + public IntStream ints(int randomNumberOrigin, int randomNumberBound) { + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(BadRange); + return StreamSupport.intStream + (new RandomIntsSpliterator + (this, 0L, Long.MAX_VALUE, randomNumberOrigin, randomNumberBound), + false); + } + + /** + * Returns a stream producing the given {@code streamSize} number + * of pseudorandom {@code long} values from this generator and/or + * one split from it. + * + * @param streamSize the number of values to generate + * @return a stream of pseudorandom {@code long} values + * @throws IllegalArgumentException if {@code streamSize} is + * less than zero + */ + public LongStream longs(long streamSize) { + if (streamSize < 0L) + throw new IllegalArgumentException(BadSize); + return StreamSupport.longStream + (new RandomLongsSpliterator + (this, 0L, streamSize, Long.MAX_VALUE, 0L), + false); + } + + /** + * Returns an effectively unlimited stream of pseudorandom {@code + * long} values from this generator and/or one split from it. + * + * @implNote This method is implemented to be equivalent to {@code + * longs(Long.MAX_VALUE)}. + * + * @return a stream of pseudorandom {@code long} values + */ + public LongStream longs() { + return StreamSupport.longStream + (new RandomLongsSpliterator + (this, 0L, Long.MAX_VALUE, Long.MAX_VALUE, 0L), + false); + } + + /** + * Returns a stream producing the given {@code streamSize} number of + * pseudorandom {@code long} values from this generator and/or one split + * from it; each value conforms to the given origin (inclusive) and bound + * (exclusive). + * + * @param streamSize the number of values to generate + * @param randomNumberOrigin the origin (inclusive) of each random value + * @param randomNumberBound the bound (exclusive) of each random value + * @return a stream of pseudorandom {@code long} values, + * each with the given origin (inclusive) and bound (exclusive) + * @throws IllegalArgumentException if {@code streamSize} is + * less than zero, or {@code randomNumberOrigin} + * is greater than or equal to {@code randomNumberBound} + */ + public LongStream longs(long streamSize, long randomNumberOrigin, + long randomNumberBound) { + if (streamSize < 0L) + throw new IllegalArgumentException(BadSize); + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(BadRange); + return StreamSupport.longStream + (new RandomLongsSpliterator + (this, 0L, streamSize, randomNumberOrigin, randomNumberBound), + false); + } + + /** + * Returns an effectively unlimited stream of pseudorandom {@code + * long} values from this generator and/or one split from it; each value + * conforms to the given origin (inclusive) and bound (exclusive). + * + * @implNote This method is implemented to be equivalent to {@code + * longs(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound)}. + * + * @param randomNumberOrigin the origin (inclusive) of each random value + * @param randomNumberBound the bound (exclusive) of each random value + * @return a stream of pseudorandom {@code long} values, + * each with the given origin (inclusive) and bound (exclusive) + * @throws IllegalArgumentException if {@code randomNumberOrigin} + * is greater than or equal to {@code randomNumberBound} + */ + public LongStream longs(long randomNumberOrigin, long randomNumberBound) { + if (randomNumberOrigin >= randomNumberBound) + throw new IllegalArgumentException(BadRange); + return StreamSupport.longStream + (new RandomLongsSpliterator + (this, 0L, Long.MAX_VALUE, randomNumberOrigin, randomNumberBound), + false); + } + + /** + * Returns a stream producing the given {@code streamSize} number of + * pseudorandom {@code double} values from this generator and/or one split + * from it; each value is between zero (inclusive) and one (exclusive). + * + * @param streamSize the number of values to generate + * @return a stream of {@code double} values + * @throws IllegalArgumentException if {@code streamSize} is + * less than zero + */ + public DoubleStream doubles(long streamSize) { + if (streamSize < 0L) + throw new IllegalArgumentException(BadSize); + return StreamSupport.doubleStream + (new RandomDoublesSpliterator + (this, 0L, streamSize, Double.MAX_VALUE, 0.0), + false); + } + + /** + * Returns an effectively unlimited stream of pseudorandom {@code + * double} values from this generator and/or one split from it; each value + * is between zero (inclusive) and one (exclusive). + * + * @implNote This method is implemented to be equivalent to {@code + * doubles(Long.MAX_VALUE)}. + * + * @return a stream of pseudorandom {@code double} values + */ + public DoubleStream doubles() { + return StreamSupport.doubleStream + (new RandomDoublesSpliterator + (this, 0L, Long.MAX_VALUE, Double.MAX_VALUE, 0.0), + false); + } + + /** + * Returns a stream producing the given {@code streamSize} number of + * pseudorandom {@code double} values from this generator and/or one split + * from it; each value conforms to the given origin (inclusive) and bound + * (exclusive). + * + * @param streamSize the number of values to generate + * @param randomNumberOrigin the origin (inclusive) of each random value + * @param randomNumberBound the bound (exclusive) of each random value + * @return a stream of pseudorandom {@code double} values, + * each with the given origin (inclusive) and bound (exclusive) + * @throws IllegalArgumentException if {@code streamSize} is + * less than zero + * @throws IllegalArgumentException if {@code randomNumberOrigin} + * is greater than or equal to {@code randomNumberBound} + */ + public DoubleStream doubles(long streamSize, double randomNumberOrigin, + double randomNumberBound) { + if (streamSize < 0L) + throw new IllegalArgumentException(BadSize); + if (!(randomNumberOrigin < randomNumberBound)) + throw new IllegalArgumentException(BadRange); + return StreamSupport.doubleStream + (new RandomDoublesSpliterator + (this, 0L, streamSize, randomNumberOrigin, randomNumberBound), + false); + } + + /** + * Returns an effectively unlimited stream of pseudorandom {@code + * double} values from this generator and/or one split from it; each value + * conforms to the given origin (inclusive) and bound (exclusive). + * + * @implNote This method is implemented to be equivalent to {@code + * doubles(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound)}. + * + * @param randomNumberOrigin the origin (inclusive) of each random value + * @param randomNumberBound the bound (exclusive) of each random value + * @return a stream of pseudorandom {@code double} values, + * each with the given origin (inclusive) and bound (exclusive) + * @throws IllegalArgumentException if {@code randomNumberOrigin} + * is greater than or equal to {@code randomNumberBound} + */ + public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound) { + if (!(randomNumberOrigin < randomNumberBound)) + throw new IllegalArgumentException(BadRange); + return StreamSupport.doubleStream + (new RandomDoublesSpliterator + (this, 0L, Long.MAX_VALUE, randomNumberOrigin, randomNumberBound), + false); + } + + /** + * Spliterator for int streams. We multiplex the four int + * versions into one class by treating a bound less than origin as + * unbounded, and also by treating "infinite" as equivalent to + * Long.MAX_VALUE. For splits, it uses the standard divide-by-two + * approach. The long and double versions of this class are + * identical except for types. + */ + static final class RandomIntsSpliterator implements Spliterator.OfInt { + final SplittableRandom rng; + long index; + final long fence; + final int origin; + final int bound; + RandomIntsSpliterator(SplittableRandom rng, long index, long fence, + int origin, int bound) { + this.rng = rng; this.index = index; this.fence = fence; + this.origin = origin; this.bound = bound; + } + + public RandomIntsSpliterator trySplit() { + long i = index, m = (i + fence) >>> 1; + return (m <= i) ? null : + new RandomIntsSpliterator(rng.split(), i, index = m, origin, bound); + } + + public long estimateSize() { + return fence - index; + } + + public int characteristics() { + return (Spliterator.SIZED | Spliterator.SUBSIZED | + Spliterator.NONNULL | Spliterator.IMMUTABLE); + } + + public boolean tryAdvance(IntConsumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + consumer.accept(rng.internalNextInt(origin, bound)); + index = i + 1; + return true; + } + return false; + } + + public void forEachRemaining(IntConsumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + index = f; + SplittableRandom r = rng; + int o = origin, b = bound; + do { + consumer.accept(r.internalNextInt(o, b)); + } while (++i < f); + } + } + } + + /** + * Spliterator for long streams. + */ + static final class RandomLongsSpliterator implements Spliterator.OfLong { + final SplittableRandom rng; + long index; + final long fence; + final long origin; + final long bound; + RandomLongsSpliterator(SplittableRandom rng, long index, long fence, + long origin, long bound) { + this.rng = rng; this.index = index; this.fence = fence; + this.origin = origin; this.bound = bound; + } + + public RandomLongsSpliterator trySplit() { + long i = index, m = (i + fence) >>> 1; + return (m <= i) ? null : + new RandomLongsSpliterator(rng.split(), i, index = m, origin, bound); + } + + public long estimateSize() { + return fence - index; + } + + public int characteristics() { + return (Spliterator.SIZED | Spliterator.SUBSIZED | + Spliterator.NONNULL | Spliterator.IMMUTABLE); + } + + public boolean tryAdvance(LongConsumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + consumer.accept(rng.internalNextLong(origin, bound)); + index = i + 1; + return true; + } + return false; + } + + public void forEachRemaining(LongConsumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + index = f; + SplittableRandom r = rng; + long o = origin, b = bound; + do { + consumer.accept(r.internalNextLong(o, b)); + } while (++i < f); + } + } + + } + + /** + * Spliterator for double streams. + */ + static final class RandomDoublesSpliterator implements Spliterator.OfDouble { + final SplittableRandom rng; + long index; + final long fence; + final double origin; + final double bound; + RandomDoublesSpliterator(SplittableRandom rng, long index, long fence, + double origin, double bound) { + this.rng = rng; this.index = index; this.fence = fence; + this.origin = origin; this.bound = bound; + } + + public RandomDoublesSpliterator trySplit() { + long i = index, m = (i + fence) >>> 1; + return (m <= i) ? null : + new RandomDoublesSpliterator(rng.split(), i, index = m, origin, bound); + } + + public long estimateSize() { + return fence - index; + } + + public int characteristics() { + return (Spliterator.SIZED | Spliterator.SUBSIZED | + Spliterator.NONNULL | Spliterator.IMMUTABLE); + } + + public boolean tryAdvance(DoubleConsumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + consumer.accept(rng.internalNextDouble(origin, bound)); + index = i + 1; + return true; + } + return false; + } + + public void forEachRemaining(DoubleConsumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + index = f; + SplittableRandom r = rng; + double o = origin, b = bound; + do { + consumer.accept(r.internalNextDouble(o, b)); + } while (++i < f); + } + } + } + +} diff --git a/jdk/test/java/util/SplittableRandom/SplittableRandomTest.java b/jdk/test/java/util/SplittableRandom/SplittableRandomTest.java new file mode 100644 index 00000000000..23ed242d06d --- /dev/null +++ b/jdk/test/java/util/SplittableRandom/SplittableRandomTest.java @@ -0,0 +1,511 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.SplittableRandom; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.LongAdder; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertTrue; + +/** + * @test + * @run testng SplittableRandomTest + * @run testng/othervm -Djava.util.secureRandomSeed=true SplittableRandomTest + * @summary test methods on SplittableRandom + */ +@Test +public class SplittableRandomTest { + + // Note: this test was copied from the 166 TCK SplittableRandomTest test + // and modified to be a TestNG test + + /* + * Testing coverage notes: + * + * 1. Many of the test methods are adapted from ThreadLocalRandomTest. + * + * 2. These tests do not check for random number generator quality. + * But we check for minimal API compliance by requiring that + * repeated calls to nextX methods, up to NCALLS tries, produce at + * least two distinct results. (In some possible universe, a + * "correct" implementation might fail, but the odds are vastly + * less than that of encountering a hardware failure while running + * the test.) For bounded nextX methods, we sample various + * intervals across multiples of primes. In other tests, we repeat + * under REPS different values. + */ + + // max numbers of calls to detect getting stuck on one value + static final int NCALLS = 10000; + + // max sampled int bound + static final int MAX_INT_BOUND = (1 << 28); + + // max sampled long bound + static final long MAX_LONG_BOUND = (1L << 42); + + // Number of replications for other checks + static final int REPS = 20; + + /** + * Repeated calls to nextInt produce at least two distinct results + */ + public void testNextInt() { + SplittableRandom sr = new SplittableRandom(); + int f = sr.nextInt(); + int i = 0; + while (i < NCALLS && sr.nextInt() == f) + ++i; + assertTrue(i < NCALLS); + } + + /** + * Repeated calls to nextLong produce at least two distinct results + */ + public void testNextLong() { + SplittableRandom sr = new SplittableRandom(); + long f = sr.nextLong(); + int i = 0; + while (i < NCALLS && sr.nextLong() == f) + ++i; + assertTrue(i < NCALLS); + } + + /** + * Repeated calls to nextDouble produce at least two distinct results + */ + public void testNextDouble() { + SplittableRandom sr = new SplittableRandom(); + double f = sr.nextDouble(); + int i = 0; + while (i < NCALLS && sr.nextDouble() == f) + ++i; + assertTrue(i < NCALLS); + } + + /** + * Two SplittableRandoms created with the same seed produce the + * same values for nextLong. + */ + public void testSeedConstructor() { + for (long seed = 2; seed < MAX_LONG_BOUND; seed += 15485863) { + SplittableRandom sr1 = new SplittableRandom(seed); + SplittableRandom sr2 = new SplittableRandom(seed); + for (int i = 0; i < REPS; ++i) + assertEquals(sr1.nextLong(), sr2.nextLong()); + } + } + + /** + * A SplittableRandom produced by split() of a default-constructed + * SplittableRandom generates a different sequence + */ + public void testSplit1() { + SplittableRandom sr = new SplittableRandom(); + for (int reps = 0; reps < REPS; ++reps) { + SplittableRandom sc = sr.split(); + int i = 0; + while (i < NCALLS && sr.nextLong() == sc.nextLong()) + ++i; + assertTrue(i < NCALLS); + } + } + + /** + * A SplittableRandom produced by split() of a seeded-constructed + * SplittableRandom generates a different sequence + */ + public void testSplit2() { + SplittableRandom sr = new SplittableRandom(12345); + for (int reps = 0; reps < REPS; ++reps) { + SplittableRandom sc = sr.split(); + int i = 0; + while (i < NCALLS && sr.nextLong() == sc.nextLong()) + ++i; + assertTrue(i < NCALLS); + } + } + + /** + * nextInt(negative) throws IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNextIntBoundedNeg() { + SplittableRandom sr = new SplittableRandom(); + int f = sr.nextInt(-17); + } + + /** + * nextInt(least >= bound) throws IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNextIntBadBounds() { + SplittableRandom sr = new SplittableRandom(); + int f = sr.nextInt(17, 2); + } + + /** + * nextInt(bound) returns 0 <= value < bound; + * repeated calls produce at least two distinct results + */ + public void testNextIntBounded() { + SplittableRandom sr = new SplittableRandom(); + // sample bound space across prime number increments + for (int bound = 2; bound < MAX_INT_BOUND; bound += 524959) { + int f = sr.nextInt(bound); + assertTrue(0 <= f && f < bound); + int i = 0; + int j; + while (i < NCALLS && + (j = sr.nextInt(bound)) == f) { + assertTrue(0 <= j && j < bound); + ++i; + } + assertTrue(i < NCALLS); + } + } + + /** + * nextInt(least, bound) returns least <= value < bound; + * repeated calls produce at least two distinct results + */ + public void testNextIntBounded2() { + SplittableRandom sr = new SplittableRandom(); + for (int least = -15485863; least < MAX_INT_BOUND; least += 524959) { + for (int bound = least + 2; bound > least && bound < MAX_INT_BOUND; bound += 49979687) { + int f = sr.nextInt(least, bound); + assertTrue(least <= f && f < bound); + int i = 0; + int j; + while (i < NCALLS && + (j = sr.nextInt(least, bound)) == f) { + assertTrue(least <= j && j < bound); + ++i; + } + assertTrue(i < NCALLS); + } + } + } + + /** + * nextLong(negative) throws IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNextLongBoundedNeg() { + SplittableRandom sr = new SplittableRandom(); + long f = sr.nextLong(-17); + } + + /** + * nextLong(least >= bound) throws IllegalArgumentException + */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testNextLongBadBounds() { + SplittableRandom sr = new SplittableRandom(); + long f = sr.nextLong(17, 2); + } + + /** + * nextLong(bound) returns 0 <= value < bound; + * repeated calls produce at least two distinct results + */ + public void testNextLongBounded() { + SplittableRandom sr = new SplittableRandom(); + for (long bound = 2; bound < MAX_LONG_BOUND; bound += 15485863) { + long f = sr.nextLong(bound); + assertTrue(0 <= f && f < bound); + int i = 0; + long j; + while (i < NCALLS && + (j = sr.nextLong(bound)) == f) { + assertTrue(0 <= j && j < bound); + ++i; + } + assertTrue(i < NCALLS); + } + } + + /** + * nextLong(least, bound) returns least <= value < bound; + * repeated calls produce at least two distinct results + */ + public void testNextLongBounded2() { + SplittableRandom sr = new SplittableRandom(); + for (long least = -86028121; least < MAX_LONG_BOUND; least += 982451653L) { + for (long bound = least + 2; bound > least && bound < MAX_LONG_BOUND; bound += Math.abs(bound * 7919)) { + long f = sr.nextLong(least, bound); + assertTrue(least <= f && f < bound); + int i = 0; + long j; + while (i < NCALLS && + (j = sr.nextLong(least, bound)) == f) { + assertTrue(least <= j && j < bound); + ++i; + } + assertTrue(i < NCALLS); + } + } + } + + /** + * nextDouble(least, bound) returns least <= value < bound; + * repeated calls produce at least two distinct results + */ + public void testNextDoubleBounded2() { + SplittableRandom sr = new SplittableRandom(); + for (double least = 0.0001; least < 1.0e20; least *= 8) { + for (double bound = least * 1.001; bound < 1.0e20; bound *= 16) { + double f = sr.nextDouble(least, bound); + assertTrue(least <= f && f < bound); + int i = 0; + double j; + while (i < NCALLS && + (j = sr.nextDouble(least, bound)) == f) { + assertTrue(least <= j && j < bound); + ++i; + } + assertTrue(i < NCALLS); + } + } + } + + /** + * Invoking sized ints, long, doubles, with negative sizes throws + * IllegalArgumentException + */ + public void testBadStreamSize() { + SplittableRandom r = new SplittableRandom(); + executeAndCatchIAE(() -> r.ints(-1L)); + executeAndCatchIAE(() -> r.ints(-1L, 2, 3)); + executeAndCatchIAE(() -> r.longs(-1L)); + executeAndCatchIAE(() -> r.longs(-1L, -1L, 1L)); + executeAndCatchIAE(() -> r.doubles(-1L)); + executeAndCatchIAE(() -> r.doubles(-1L, .5, .6)); + } + + /** + * Invoking bounded ints, long, doubles, with illegal bounds throws + * IllegalArgumentException + */ + public void testBadStreamBounds() { + SplittableRandom r = new SplittableRandom(); + executeAndCatchIAE(() -> r.ints(2, 1)); + executeAndCatchIAE(() -> r.ints(10, 42, 42)); + executeAndCatchIAE(() -> r.longs(-1L, -1L)); + executeAndCatchIAE(() -> r.longs(10, 1L, -2L)); + executeAndCatchIAE(() -> r.doubles(0.0, 0.0)); + executeAndCatchIAE(() -> r.doubles(10, .5, .4)); + } + + private void executeAndCatchIAE(Runnable r) { + executeAndCatch(IllegalArgumentException.class, r); + } + + private void executeAndCatch(Class expected, Runnable r) { + Exception caught = null; + try { + r.run(); + } + catch (Exception e) { + caught = e; + } + + assertNotNull(caught, + String.format("No Exception was thrown, expected an Exception of %s to be thrown", + expected.getName())); + Assert.assertTrue(expected.isInstance(caught), + String.format("Exception thrown %s not an instance of %s", + caught.getClass().getName(), expected.getName())); + } + + /** + * A parallel sized stream of ints generates the given number of values + */ + public void testIntsCount() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 0; + for (int reps = 0; reps < REPS; ++reps) { + counter.reset(); + r.ints(size).parallel().forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + size += 524959; + } + } + + /** + * A parallel sized stream of longs generates the given number of values + */ + public void testLongsCount() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 0; + for (int reps = 0; reps < REPS; ++reps) { + counter.reset(); + r.longs(size).parallel().forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + size += 524959; + } + } + + /** + * A parallel sized stream of doubles generates the given number of values + */ + public void testDoublesCount() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 0; + for (int reps = 0; reps < REPS; ++reps) { + counter.reset(); + r.doubles(size).parallel().forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + size += 524959; + } + } + + /** + * Each of a parallel sized stream of bounded ints is within bounds + */ + public void testBoundedInts() { + AtomicInteger fails = new AtomicInteger(0); + SplittableRandom r = new SplittableRandom(); + long size = 12345L; + for (int least = -15485867; least < MAX_INT_BOUND; least += 524959) { + for (int bound = least + 2; bound > least && bound < MAX_INT_BOUND; bound += 67867967) { + final int lo = least, hi = bound; + r.ints(size, lo, hi).parallel(). + forEach(x -> {if (x < lo || x >= hi) + fails.getAndIncrement(); }); + } + } + assertEquals(fails.get(), 0); + } + + /** + * Each of a parallel sized stream of bounded longs is within bounds + */ + public void testBoundedLongs() { + AtomicInteger fails = new AtomicInteger(0); + SplittableRandom r = new SplittableRandom(); + long size = 123L; + for (long least = -86028121; least < MAX_LONG_BOUND; least += 1982451653L) { + for (long bound = least + 2; bound > least && bound < MAX_LONG_BOUND; bound += Math.abs(bound * 7919)) { + final long lo = least, hi = bound; + r.longs(size, lo, hi).parallel(). + forEach(x -> {if (x < lo || x >= hi) + fails.getAndIncrement(); }); + } + } + assertEquals(fails.get(), 0); + } + + /** + * Each of a parallel sized stream of bounded doubles is within bounds + */ + public void testBoundedDoubles() { + AtomicInteger fails = new AtomicInteger(0); + SplittableRandom r = new SplittableRandom(); + long size = 456; + for (double least = 0.00011; least < 1.0e20; least *= 9) { + for (double bound = least * 1.0011; bound < 1.0e20; bound *= 17) { + final double lo = least, hi = bound; + r.doubles(size, lo, hi).parallel(). + forEach(x -> {if (x < lo || x >= hi) + fails.getAndIncrement(); }); + } + } + assertEquals(fails.get(), 0); + } + + /** + * A parallel unsized stream of ints generates at least 100 values + */ + public void testUnsizedIntsCount() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 100; + r.ints().limit(size).parallel().forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + } + + /** + * A parallel unsized stream of longs generates at least 100 values + */ + public void testUnsizedLongsCount() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 100; + r.longs().limit(size).parallel().forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + } + + /** + * A parallel unsized stream of doubles generates at least 100 values + */ + public void testUnsizedDoublesCount() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 100; + r.doubles().limit(size).parallel().forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + } + + /** + * A sequential unsized stream of ints generates at least 100 values + */ + public void testUnsizedIntsCountSeq() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 100; + r.ints().limit(size).forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + } + + /** + * A sequential unsized stream of longs generates at least 100 values + */ + public void testUnsizedLongsCountSeq() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 100; + r.longs().limit(size).forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + } + + /** + * A sequential unsized stream of doubles generates at least 100 values + */ + public void testUnsizedDoublesCountSeq() { + LongAdder counter = new LongAdder(); + SplittableRandom r = new SplittableRandom(); + long size = 100; + r.doubles().limit(size).forEach(x -> {counter.increment();}); + assertEquals(counter.sum(), size); + } + +} diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/SplittableRandomTest.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/SplittableRandomTest.java new file mode 100644 index 00000000000..30b5e7d6da8 --- /dev/null +++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/SplittableRandomTest.java @@ -0,0 +1,367 @@ +/* + * 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. + */ +package org.openjdk.tests.java.util; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Spliterator; +import java.util.SplittableRandom; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.DoubleStream; +import java.util.stream.DoubleStreamTestScenario; +import java.util.stream.IntStream; +import java.util.stream.IntStreamTestScenario; +import java.util.stream.LongStream; +import java.util.stream.LongStreamTestScenario; +import java.util.stream.OpTestCase; +import java.util.stream.StreamSupport; +import java.util.stream.TestData; + +@Test +public class SplittableRandomTest extends OpTestCase { + + static class RandomBoxedSpliterator implements Spliterator { + final SplittableRandom rng; + long index; + final long fence; + final Function rngF; + + RandomBoxedSpliterator(SplittableRandom rng, long index, long fence, Function rngF) { + this.rng = rng; + this.index = index; + this.fence = fence; + this.rngF = rngF; + } + + public RandomBoxedSpliterator trySplit() { + long i = index, m = (i + fence) >>> 1; + return (m <= i) ? null : + new RandomBoxedSpliterator<>(rng.split(), i, index = m, rngF); + } + + public long estimateSize() { + return fence - index; + } + + public int characteristics() { + return (Spliterator.SIZED | Spliterator.SUBSIZED | + Spliterator.NONNULL | Spliterator.IMMUTABLE); + } + + @Override + public boolean tryAdvance(Consumer consumer) { + if (consumer == null) throw new NullPointerException(); + long i = index, f = fence; + if (i < f) { + consumer.accept(rngF.apply(rng)); + index = i + 1; + return true; + } + return false; + } + } + + static final int SIZE = 1 << 16; + + // Ensure there is a range of a power of 2 + static final int[] BOUNDS = {256}; + static final int[] ORIGINS = {-16, 0, 16}; + + static > ResultAsserter> randomAsserter(int size, T origin, T bound) { + return (act, exp, ord, par) -> { + int count = 0; + Set> values = new HashSet<>(); + for (Comparable t : act) { + if (origin.compareTo(bound) < 0) { + assertTrue(t.compareTo(origin) >= 0); + assertTrue(t.compareTo(bound) < 0); + } + values.add(t); + count++; + } + assertEquals(count, size); + // Assert that at least one different result is produced + // For the size of the data it is highly improbable that this + // will cause a false negative (i.e. a false failure) + assertTrue(values.size() > 1); + }; + } + + @DataProvider(name = "ints") + public static Object[][] intsDataProvider() { + List data = new ArrayList<>(); + + // Function to create a stream using a RandomBoxedSpliterator + + Function, IntStream> rbsf = + sf -> StreamSupport.stream(new RandomBoxedSpliterator<>(new SplittableRandom(), 0, SIZE, sf), false). + mapToInt(i -> i); + + // Unbounded + + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new SplittableRandom().ints().limit(%d)", SIZE), + () -> new SplittableRandom().ints().limit(SIZE)), + randomAsserter(SIZE, Integer.MAX_VALUE, 0) + }); + + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new SplittableRandom().ints(%d)", SIZE), + () -> new SplittableRandom().ints(SIZE)), + randomAsserter(SIZE, Integer.MAX_VALUE, 0) + }); + + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextInt())", SIZE), + () -> rbsf.apply(sr -> sr.nextInt())), + randomAsserter(SIZE, Integer.MAX_VALUE, 0) + }); + + // Bounded + + for (int b : BOUNDS) { + for (int o : ORIGINS) { + final int origin = o; + final int bound = b; + + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new SplittableRandom().ints(%d, %d).limit(%d)", origin, bound, SIZE), + () -> new SplittableRandom().ints(origin, bound).limit(SIZE)), + randomAsserter(SIZE, origin, bound) + }); + + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new SplittableRandom().ints(%d, %d, %d)", SIZE, origin, bound), + () -> new SplittableRandom().ints(SIZE, origin, bound)), + randomAsserter(SIZE, origin, bound) + }); + + if (origin == 0) { + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextInt(%d))", SIZE, bound), + () -> rbsf.apply(sr -> sr.nextInt(bound))), + randomAsserter(SIZE, origin, bound) + }); + } + + data.add(new Object[]{ + TestData.Factory.ofIntSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextInt(%d, %d))", SIZE, origin, bound), + () -> rbsf.apply(sr -> sr.nextInt(origin, bound))), + randomAsserter(SIZE, origin, bound) + }); + } + } + + return data.toArray(new Object[0][]); + } + + @Test(dataProvider = "ints") + public void testInts(TestData.OfInt data, ResultAsserter> ra) { + withData(data). + stream(s -> s). + without(IntStreamTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED). + resultAsserter(ra). + exercise(); + } + + @DataProvider(name = "longs") + public static Object[][] longsDataProvider() { + List data = new ArrayList<>(); + + // Function to create a stream using a RandomBoxedSpliterator + + Function, LongStream> rbsf = + sf -> StreamSupport.stream(new RandomBoxedSpliterator<>(new SplittableRandom(), 0, SIZE, sf), false). + mapToLong(i -> i); + + // Unbounded + + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new SplittableRandom().longs().limit(%d)", SIZE), + () -> new SplittableRandom().longs().limit(SIZE)), + randomAsserter(SIZE, Long.MAX_VALUE, 0L) + }); + + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new SplittableRandom().longs(%d)", SIZE), + () -> new SplittableRandom().longs(SIZE)), + randomAsserter(SIZE, Long.MAX_VALUE, 0L) + }); + + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextLong())", SIZE), + () -> rbsf.apply(sr -> sr.nextLong())), + randomAsserter(SIZE, Long.MAX_VALUE, 0L) + }); + + // Bounded + + for (int b : BOUNDS) { + for (int o : ORIGINS) { + final long origin = o; + final long bound = b; + + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new SplittableRandom().longs(%d, %d).limit(%d)", origin, bound, SIZE), + () -> new SplittableRandom().longs(origin, bound).limit(SIZE)), + randomAsserter(SIZE, origin, bound) + }); + + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new SplittableRandom().longs(%d, %d, %d)", SIZE, origin, bound), + () -> new SplittableRandom().longs(SIZE, origin, bound)), + randomAsserter(SIZE, origin, bound) + }); + + if (origin == 0) { + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextLong(%d))", SIZE, bound), + () -> rbsf.apply(sr -> sr.nextLong(bound))), + randomAsserter(SIZE, origin, bound) + }); + } + + data.add(new Object[]{ + TestData.Factory.ofLongSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextLong(%d, %d))", SIZE, origin, bound), + () -> rbsf.apply(sr -> sr.nextLong(origin, bound))), + randomAsserter(SIZE, origin, bound) + }); + } + } + + return data.toArray(new Object[0][]); + } + + @Test(dataProvider = "longs") + public void testLongs(TestData.OfLong data, ResultAsserter> ra) { + withData(data). + stream(s -> s). + without(LongStreamTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED). + resultAsserter(ra). + exercise(); + } + + @DataProvider(name = "doubles") + public static Object[][] doublesDataProvider() { + List data = new ArrayList<>(); + + // Function to create a stream using a RandomBoxedSpliterator + + Function, DoubleStream> rbsf = + sf -> StreamSupport.stream(new RandomBoxedSpliterator<>(new SplittableRandom(), 0, SIZE, sf), false). + mapToDouble(i -> i); + + // Unbounded + + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new SplittableRandom().doubles().limit(%d)", SIZE), + () -> new SplittableRandom().doubles().limit(SIZE)), + randomAsserter(SIZE, Double.MAX_VALUE, 0d) + }); + + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new SplittableRandom().doubles(%d)", SIZE), + () -> new SplittableRandom().doubles(SIZE)), + randomAsserter(SIZE, Double.MAX_VALUE, 0d) + }); + + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextDouble())", SIZE), + () -> rbsf.apply(sr -> sr.nextDouble())), + randomAsserter(SIZE, Double.MAX_VALUE, 0d) + }); + + // Bounded + + for (int b : BOUNDS) { + for (int o : ORIGINS) { + final double origin = o; + final double bound = b; + + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new SplittableRandom().doubles(%f, %f).limit(%d)", origin, bound, SIZE), + () -> new SplittableRandom().doubles(origin, bound).limit(SIZE)), + randomAsserter(SIZE, origin, bound) + }); + + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new SplittableRandom().doubles(%d, %f, %f)", SIZE, origin, bound), + () -> new SplittableRandom().doubles(SIZE, origin, bound)), + randomAsserter(SIZE, origin, bound) + }); + + if (origin == 0) { + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextDouble(%f))", SIZE, bound), + () -> rbsf.apply(sr -> sr.nextDouble(bound))), + randomAsserter(SIZE, origin, bound) + }); + } + + data.add(new Object[]{ + TestData.Factory.ofDoubleSupplier( + String.format("new RandomBoxedSpliterator(0, %d, sr -> sr.nextDouble(%f, %f))", SIZE, origin, bound), + () -> rbsf.apply(sr -> sr.nextDouble(origin, bound))), + randomAsserter(SIZE, origin, bound) + }); + } + } + + return data.toArray(new Object[0][]); + } + + @Test(dataProvider = "doubles") + public void testDoubles(TestData.OfDouble data, ResultAsserter> ra) { + withData(data). + stream(s -> s). + without(DoubleStreamTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED). + resultAsserter(ra). + exercise(); + } +} From 849788a425dcccfded4905f701d487773826751e Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 27 Aug 2013 17:50:52 +0800 Subject: [PATCH 044/117] 8015669: KerberosPrincipal::equals should ignore name-type Reviewed-by: mullan --- .../auth/kerberos/KerberosPrincipal.java | 14 ++--- jdk/test/sun/security/krb5/auto/KPEquals.java | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 jdk/test/sun/security/krb5/auto/KPEquals.java diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java index 6962f2a43d3..1c033803cc7 100644 --- a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java +++ b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java @@ -197,8 +197,7 @@ public final class KerberosPrincipal * {@code KerberosPrincipal} and the two * {@code KerberosPrincipal} instances are equivalent. * More formally two {@code KerberosPrincipal} instances are equal - * if the values returned by {@code getName()} are equal and the - * values returned by {@code getNameType()} are equal. + * if the values returned by {@code getName()} are equal. * * @param other the Object to compare to * @return true if the Object passed in represents the same principal @@ -211,15 +210,10 @@ public final class KerberosPrincipal if (! (other instanceof KerberosPrincipal)) { return false; - } else { - String myFullName = getName(); - String otherFullName = ((KerberosPrincipal) other).getName(); - if (nameType == ((KerberosPrincipal)other).nameType && - myFullName.equals(otherFullName)) { - return true; - } } - return false; + String myFullName = getName(); + String otherFullName = ((KerberosPrincipal) other).getName(); + return myFullName.equals(otherFullName); } /** diff --git a/jdk/test/sun/security/krb5/auto/KPEquals.java b/jdk/test/sun/security/krb5/auto/KPEquals.java new file mode 100644 index 00000000000..7a7aaa34f24 --- /dev/null +++ b/jdk/test/sun/security/krb5/auto/KPEquals.java @@ -0,0 +1,55 @@ +/* + * 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 8015669 + * @summary KerberosPrincipal::equals should ignore name-type + * @compile -XDignore.symbol.file KPEquals.java + * @run main/othervm KPEquals + */ + +import sun.security.jgss.GSSUtil; + +import javax.security.auth.kerberos.KerberosKey; +import javax.security.auth.kerberos.KerberosPrincipal; +import javax.security.auth.kerberos.KeyTab; + +public class KPEquals { + + public static void main(String[] args) throws Exception { + new OneKDC(null).writeJAASConf(); + Context c = Context.fromJAAS("client"); + Context s = Context.fromThinAir(); + KerberosPrincipal kp = new KerberosPrincipal( + OneKDC.SERVER + "@" + OneKDC.REALM, + KerberosPrincipal.KRB_NT_SRV_INST); + s.s().getPrincipals().add(kp); + for (KerberosKey k: KeyTab.getInstance(kp).getKeys(kp)) { + s.s().getPrivateCredentials().add(k); + } + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); + s.startAsServer(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); + Context.handshake(c, s); + } +} From c5fd247e16d75945a5940f2a57f2f2e4febb3dbe Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 27 Aug 2013 17:50:55 +0800 Subject: [PATCH 045/117] 8022761: regression: SecurityException is NOT thrown while trying to pack a wrongly signed Indexed Jar file Reviewed-by: sherman --- .../classes/java/util/jar/JarVerifier.java | 4 +- .../sun/security/tools/jarsigner/jvindex.sh | 76 +++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 jdk/test/sun/security/tools/jarsigner/jvindex.sh diff --git a/jdk/src/share/classes/java/util/jar/JarVerifier.java b/jdk/src/share/classes/java/util/jar/JarVerifier.java index 73748c1083d..30459e54324 100644 --- a/jdk/src/share/classes/java/util/jar/JarVerifier.java +++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java @@ -32,6 +32,7 @@ import java.security.*; import java.security.cert.CertificateException; import java.util.zip.ZipEntry; +import sun.misc.JarIndex; import sun.security.util.ManifestDigester; import sun.security.util.ManifestEntryVerifier; import sun.security.util.SignatureFileVerifier; @@ -139,7 +140,8 @@ class JarVerifier { return; } - if (uname.equals(JarFile.MANIFEST_NAME)) { + if (uname.equals(JarFile.MANIFEST_NAME) || + uname.equals(JarIndex.INDEX_NAME)) { return; } diff --git a/jdk/test/sun/security/tools/jarsigner/jvindex.sh b/jdk/test/sun/security/tools/jarsigner/jvindex.sh new file mode 100644 index 00000000000..c4435b68121 --- /dev/null +++ b/jdk/test/sun/security/tools/jarsigner/jvindex.sh @@ -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. +# + +# @test +# @bug 8022761 +# @summary regression: SecurityException is NOT thrown while trying to pack a wrongly signed Indexed Jar file +# + +if [ "${TESTJAVA}" = "" ] ; then + JAVAC_CMD=`which javac` + TESTJAVA=`dirname $JAVAC_CMD`/.. +fi + +# set platform-dependent variables +OS=`uname -s` +case "$OS" in + Windows_* ) + FS="\\" + ;; + * ) + FS="/" + ;; +esac + +F=abcde +KS=jvindex.jks +JFILE=jvindex.jar + +KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit \ + -keystore $KS" +JAR=$TESTJAVA${FS}bin${FS}jar +JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner -keystore $KS -storepass changeit" + +rm $F $KS $JFILE 2> /dev/null + +echo 12345 > $F +$JAR cvf $JFILE $F + +ERR="" + +$KT -alias a -dname CN=a -genkey -validity 300 || ERR="$ERR 1" + +$JARSIGNER $JFILE a || ERR="$ERR 2" +$JAR i $JFILE + +# Make sure the $F line has "sm" (signed and in manifest) +$JARSIGNER -verify -verbose $JFILE | grep $F | grep sm || ERR="$ERR 3" + +if [ "$ERR" = "" ]; then + exit 0 +else + echo "ERR is $ERR" + exit 1 +fi + + From 05f2952a67a9b88e0283dbe3796e967d449cc688 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Tue, 27 Aug 2013 10:46:03 -0400 Subject: [PATCH 046/117] 8023769: JDK-8016850 broke the old build Remove files that were moved/removed from com/sun/security/auth/FILES_java.gmk Reviewed-by: chegar, xuelei --- jdk/make/com/sun/security/auth/FILES_java.gmk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jdk/make/com/sun/security/auth/FILES_java.gmk b/jdk/make/com/sun/security/auth/FILES_java.gmk index 3e96e9d58b3..fa4f7d4b8d0 100644 --- a/jdk/make/com/sun/security/auth/FILES_java.gmk +++ b/jdk/make/com/sun/security/auth/FILES_java.gmk @@ -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 @@ -43,8 +43,6 @@ FILES_java = \ com/sun/security/auth/UserPrincipal.java \ com/sun/security/auth/LdapPrincipal.java \ com/sun/security/auth/PolicyFile.java \ - com/sun/security/auth/SubjectCodeSource.java \ - com/sun/security/auth/PolicyParser.java \ com/sun/security/auth/PrincipalComparator.java \ com/sun/security/auth/callback/TextCallbackHandler.java \ com/sun/security/auth/callback/DialogCallbackHandler.java From 4520fbf9834fceedb35b806b1effe3417f2d7ce7 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Tue, 27 Aug 2013 12:04:32 -0400 Subject: [PATCH 047/117] 8019830: Add com.sun.media.sound to the list of restricted package Reviewed-by: vinnie --- jdk/src/share/lib/security/java.security-linux | 2 ++ jdk/src/share/lib/security/java.security-macosx | 2 ++ jdk/src/share/lib/security/java.security-solaris | 2 ++ jdk/src/share/lib/security/java.security-windows | 2 ++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java | 3 ++- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/lib/security/java.security-linux b/jdk/src/share/lib/security/java.security-linux index 2686cae4c4f..2c5f5f6c32a 100644 --- a/jdk/src/share/lib/security/java.security-linux +++ b/jdk/src/share/lib/security/java.security-linux @@ -181,6 +181,7 @@ package.access=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ @@ -225,6 +226,7 @@ package.definition=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx index 7ea2ee18735..44791b241f4 100644 --- a/jdk/src/share/lib/security/java.security-macosx +++ b/jdk/src/share/lib/security/java.security-macosx @@ -182,6 +182,7 @@ package.access=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ @@ -226,6 +227,7 @@ package.definition=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris index be885d3b187..a6ce253df8a 100644 --- a/jdk/src/share/lib/security/java.security-solaris +++ b/jdk/src/share/lib/security/java.security-solaris @@ -183,6 +183,7 @@ package.access=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ @@ -226,6 +227,7 @@ package.definition=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows index c06a56156ae..cca53ae3961 100644 --- a/jdk/src/share/lib/security/java.security-windows +++ b/jdk/src/share/lib/security/java.security-windows @@ -182,6 +182,7 @@ package.access=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ @@ -226,6 +227,7 @@ package.definition=sun.,\ com.sun.imageio.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ + com.sun.media.sound.,\ com.sun.proxy.,\ com.sun.org.apache.bcel.internal.,\ com.sun.org.apache.regexp.internal.,\ diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java index 7167bbb96c8..c6b9a1e59be 100644 --- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6741606 7146431 8000450 + * @bug 6741606 7146431 8000450 8019830 * @summary Make sure all restricted packages listed in the package.access * property in the java.security file are blocked * @run main/othervm CheckPackageAccess @@ -54,6 +54,7 @@ public class CheckPackageAccess { "com.sun.imageio.", "com.sun.istack.internal.", "com.sun.jmx.", + "com.sun.media.sound.", "com.sun.proxy.", "com.sun.org.apache.bcel.internal.", "com.sun.org.apache.regexp.internal.", From ab9f31ab536a49a91c58abfaef3f8f91777058b5 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 27 Aug 2013 11:46:25 -0700 Subject: [PATCH 048/117] 8023827: Fix doclint issues in javax.net.ssl Reviewed-by: wetmore, xuelei --- jdk/src/share/classes/javax/net/ssl/SNIHostName.java | 3 ++- jdk/src/share/classes/javax/net/ssl/X509KeyManager.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/javax/net/ssl/SNIHostName.java b/jdk/src/share/classes/javax/net/ssl/SNIHostName.java index 588a8547e11..d5e71414497 100644 --- a/jdk/src/share/classes/javax/net/ssl/SNIHostName.java +++ b/jdk/src/share/classes/javax/net/ssl/SNIHostName.java @@ -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 @@ -293,6 +293,7 @@ public final class SNIHostName extends SNIServerName { * the * regular expression pattern * representing the hostname(s) to match + * @return a {@code SNIMatcher} object for {@code SNIHostName}s * @throws NullPointerException if {@code regex} is * {@code null} * @throws java.util.regex.PatternSyntaxException if the regular expression's diff --git a/jdk/src/share/classes/javax/net/ssl/X509KeyManager.java b/jdk/src/share/classes/javax/net/ssl/X509KeyManager.java index 5174adfe412..69ab91ae94d 100644 --- a/jdk/src/share/classes/javax/net/ssl/X509KeyManager.java +++ b/jdk/src/share/classes/javax/net/ssl/X509KeyManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, 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 @@ -40,7 +40,7 @@ import java.net.Socket; *

    *
  • determine the set of aliases that are available for negotiations * based on the criteria presented, - *
  • select the best alias based on + *
  • select the best alias based on * the criteria presented, and *
  • obtain the corresponding key material for given aliases. *
From b87db568f08306339fb64c78c43a418da5051e41 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Mon, 26 Aug 2013 22:32:50 -0700 Subject: [PATCH 049/117] 8023275: Wrapping collections should override default methods Reviewed-by: mduigou, psandoz --- .../share/classes/java/util/Collections.java | 57 ++++++- jdk/test/java/util/Collections/Wrappers.java | 146 ++++++++++++++++++ 2 files changed, 197 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/util/Collections/Wrappers.java diff --git a/jdk/src/share/classes/java/util/Collections.java b/jdk/src/share/classes/java/util/Collections.java index 16263277f70..2404b4fc9ad 100644 --- a/jdk/src/share/classes/java/util/Collections.java +++ b/jdk/src/share/classes/java/util/Collections.java @@ -27,7 +27,6 @@ package java.util; import java.io.Serializable; import java.io.ObjectOutputStream; import java.io.IOException; -import java.io.InvalidObjectException; import java.lang.reflect.Array; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -35,6 +34,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import java.util.stream.IntStream; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -1148,7 +1148,16 @@ public class Collections { public Spliterator spliterator() { return (Spliterator)c.spliterator(); } - + @SuppressWarnings("unchecked") + @Override + public Stream stream() { + return (Stream)c.stream(); + } + @SuppressWarnings("unchecked") + @Override + public Stream parallelStream() { + return (Stream)c.parallelStream(); + } } /** @@ -2009,8 +2018,8 @@ public class Collections { * through the returned collection.

* * It is imperative that the user manually synchronize on the returned - * collection when traversing it via {@link Iterator} or - * {@link Spliterator}: + * collection when traversing it via {@link Iterator}, {@link Spliterator} + * or {@link Stream}: *

      *  Collection c = Collections.synchronizedCollection(myCollection);
      *     ...
@@ -2120,6 +2129,14 @@ public class Collections {
         public Spliterator spliterator() {
             return c.spliterator(); // Must be manually synched by user!
         }
+        @Override
+        public Stream stream() {
+            return c.stream(); // Must be manually synched by user!
+        }
+        @Override
+        public Stream parallelStream() {
+            return c.parallelStream(); // Must be manually synched by user!
+        }
         private void writeObject(ObjectOutputStream s) throws IOException {
             synchronized (mutex) {s.defaultWriteObject();}
         }
@@ -3172,6 +3189,10 @@ public class Collections {
         }
         @Override
         public Spliterator spliterator() {return c.spliterator();}
+        @Override
+        public Stream stream()           {return c.stream();}
+        @Override
+        public Stream parallelStream()   {return c.parallelStream();}
     }
 
     /**
@@ -5096,6 +5117,22 @@ public class Collections {
                                                    ") > toIndex(" + toIndex + ")");
             return new CopiesList<>(toIndex - fromIndex, element);
         }
+
+        // Override default methods in Collection
+        @Override
+        public Stream stream() {
+            return IntStream.range(0, n).mapToObj(i -> element);
+        }
+
+        @Override
+        public Stream parallelStream() {
+            return IntStream.range(0, n).parallel().mapToObj(i -> element);
+        }
+
+        @Override
+        public Spliterator spliterator() {
+            return stream().spliterator();
+        }
     }
 
     /**
@@ -5503,6 +5540,10 @@ public class Collections {
 
         @Override
         public Spliterator spliterator() {return s.spliterator();}
+        @Override
+        public Stream stream()           {return s.stream();}
+        @Override
+        public Stream parallelStream()   {return s.parallelStream();}
 
         private static final long serialVersionUID = 2454657854757543876L;
 
@@ -5568,10 +5609,14 @@ public class Collections {
         @Override
         public void forEach(Consumer action) {q.forEach(action);}
         @Override
-        public Spliterator spliterator() {return q.spliterator();}
-        @Override
         public boolean removeIf(Predicate filter) {
             return q.removeIf(filter);
         }
+        @Override
+        public Spliterator spliterator() {return q.spliterator();}
+        @Override
+        public Stream stream()           {return q.stream();}
+        @Override
+        public Stream parallelStream()   {return q.parallelStream();}
     }
 }
diff --git a/jdk/test/java/util/Collections/Wrappers.java b/jdk/test/java/util/Collections/Wrappers.java
new file mode 100644
index 00000000000..3882a4efdd1
--- /dev/null
+++ b/jdk/test/java/util/Collections/Wrappers.java
@@ -0,0 +1,146 @@
+/*
+ * 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
+ * @run testng Wrappers
+ * @summary Ensure Collections wrapping classes provide non-default implementations
+ */
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+import static org.testng.Assert.assertFalse;
+
+@Test(groups = "unit")
+public class Wrappers {
+    static Object[][] collections;
+
+    @DataProvider(name="collections")
+    public static Object[][] collectionCases() {
+        if (collections != null) {
+            return collections;
+        }
+
+        List cases = new ArrayList<>();
+        LinkedList seedList = new LinkedList<>();
+        ArrayList seedRandomAccess = new ArrayList<>();
+        TreeSet seedSet = new TreeSet<>();
+        TreeMap seedMap = new TreeMap<>();
+
+        for (int i = 1; i <= 10; i++) {
+            seedList.add(i);
+            seedRandomAccess.add(i);
+            seedSet.add(i);
+            seedMap.put(i, i);
+        }
+
+        cases.add(new Object[] { Collections.unmodifiableCollection(seedList) });
+        cases.add(new Object[] { Collections.unmodifiableList(seedList) });
+        cases.add(new Object[] { Collections.unmodifiableList(seedRandomAccess) });
+        cases.add(new Object[] { Collections.unmodifiableSet(seedSet) });
+        cases.add(new Object[] { Collections.unmodifiableSortedSet(seedSet) });
+        cases.add(new Object[] { Collections.unmodifiableNavigableSet(seedSet) });
+
+        // As sets from map also need to be unmodifiable, thus a wrapping
+        // layer exist and should not have default methods
+        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.unmodifiableMap(seedMap).values() });
+        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.unmodifiableSortedMap(seedMap).values() });
+        cases.add(new Object[] { Collections.unmodifiableNavigableMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.unmodifiableNavigableMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.unmodifiableNavigableMap(seedMap).values() });
+
+        // Synchronized
+        cases.add(new Object[] { Collections.synchronizedCollection(seedList) });
+        cases.add(new Object[] { Collections.synchronizedList(seedList) });
+        cases.add(new Object[] { Collections.synchronizedList(seedRandomAccess) });
+        cases.add(new Object[] { Collections.synchronizedSet(seedSet) });
+        cases.add(new Object[] { Collections.synchronizedSortedSet(seedSet) });
+        cases.add(new Object[] { Collections.synchronizedNavigableSet(seedSet) });
+
+        // As sets from map also need to be synchronized on the map, thus a
+        // wrapping layer exist and should not have default methods
+        cases.add(new Object[] { Collections.synchronizedMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.synchronizedMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.synchronizedMap(seedMap).values() });
+        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.synchronizedSortedMap(seedMap).values() });
+        cases.add(new Object[] { Collections.synchronizedNavigableMap(seedMap).entrySet() });
+        cases.add(new Object[] { Collections.synchronizedNavigableMap(seedMap).keySet() });
+        cases.add(new Object[] { Collections.synchronizedNavigableMap(seedMap).values() });
+
+        // Checked
+        cases.add(new Object[] { Collections.checkedCollection(seedList, Integer.class) });
+        cases.add(new Object[] { Collections.checkedList(seedList, Integer.class) });
+        cases.add(new Object[] { Collections.checkedList(seedRandomAccess, Integer.class) });
+        cases.add(new Object[] { Collections.checkedSet(seedSet, Integer.class) });
+        cases.add(new Object[] { Collections.checkedSortedSet(seedSet, Integer.class) });
+        cases.add(new Object[] { Collections.checkedNavigableSet(seedSet, Integer.class) });
+        cases.add(new Object[] { Collections.checkedQueue(seedList, Integer.class) });
+
+        // asLifoQueue is another wrapper
+        cases.add(new Object[] { Collections.asLifoQueue(seedList) });
+
+        collections = cases.toArray(new Object[0][]);
+        return collections;
+    }
+
+    static Method[] defaultMethods;
+
+    static {
+        List list = new ArrayList<>();
+        Method[] methods = Collection.class.getMethods();
+        for (Method m: methods) {
+            if (m.isDefault()) {
+                list.add(m);
+            }
+        }
+        defaultMethods = list.toArray(new Method[0]);
+    }
+
+    @Test(dataProvider = "collections")
+    public static void testAllDefaultMethodsOverridden(Collection c) throws NoSuchMethodException {
+        Class cls = c.getClass();
+        for (Method m: defaultMethods) {
+            Method m2 = cls.getMethod(m.getName(), m.getParameterTypes());
+            // default had been override
+            assertFalse(m2.isDefault(), cls.getCanonicalName());
+        }
+    }
+}
+

From d912aa501eb2b51ae468b01e1bb535365d999473 Mon Sep 17 00:00:00 2001
From: Xueming Shen 
Date: Tue, 27 Aug 2013 12:54:44 -0700
Subject: [PATCH 050/117] 8023647: "abc1c".matches("(\\w)+1\\1")) returns false

To correct the wrong GroupCurly group index backoff code

Reviewed-by: alanb
---
 jdk/src/share/classes/java/util/regex/Pattern.java |  6 ++----
 jdk/test/java/util/regex/RegExTest.java            | 12 +++++++++++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/jdk/src/share/classes/java/util/regex/Pattern.java b/jdk/src/share/classes/java/util/regex/Pattern.java
index 4eedd34c72a..1dc72c10cd3 100644
--- a/jdk/src/share/classes/java/util/regex/Pattern.java
+++ b/jdk/src/share/classes/java/util/regex/Pattern.java
@@ -4456,16 +4456,16 @@ loop:   for(int x=0, offset=0; x p = Pattern.compile("[a-z]+").asPredicate();

From 1d19a4f5df8085a57cea8acc5d8c5c9327dfaeff Mon Sep 17 00:00:00 2001
From: Henry Jen 
Date: Wed, 21 Aug 2013 20:41:35 -0700
Subject: [PATCH 051/117] 8023528: Rename Comparator combinators to
 disambiguate overloading methods

Reviewed-by: mduigou, smarks
---
 .../share/classes/java/util/Comparator.java   | 32 +++++++-------
 jdk/test/java/util/Comparator/BasicTest.java  | 42 +++++++++----------
 jdk/test/java/util/Map/EntryComparators.java  |  4 +-
 .../function/BinaryOperator/BasicTest.java    | 14 +++----
 4 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/jdk/src/share/classes/java/util/Comparator.java b/jdk/src/share/classes/java/util/Comparator.java
index 55d5efb9866..b19481df198 100644
--- a/jdk/src/share/classes/java/util/Comparator.java
+++ b/jdk/src/share/classes/java/util/Comparator.java
@@ -199,7 +199,7 @@ public interface Comparator {
      * composed using following code,
      *
      * 
{@code
-     *     Comparator cmp = Comparator.comparing(String::length)
+     *     Comparator cmp = Comparator.comparingInt(String::length)
      *             .thenComparing(String.CASE_INSENSITIVE_ORDER);
      * }
* @@ -270,18 +270,18 @@ public interface Comparator { * extracts a {@code int} sort key. * * @implSpec This default implementation behaves as if {@code - * thenComparing(comparing(keyExtractor))}. + * thenComparing(comparingInt(keyExtractor))}. * * @param keyExtractor the function used to extract the integer sort key * @return a lexicographic-order comparator composed of this and then the * {@code int} sort key * @throws NullPointerException if the argument is null. - * @see #comparing(ToIntFunction) + * @see #comparingInt(ToIntFunction) * @see #thenComparing(Comparator) * @since 1.8 */ - default Comparator thenComparing(ToIntFunction keyExtractor) { - return thenComparing(comparing(keyExtractor)); + default Comparator thenComparingInt(ToIntFunction keyExtractor) { + return thenComparing(comparingInt(keyExtractor)); } /** @@ -289,18 +289,18 @@ public interface Comparator { * extracts a {@code long} sort key. * * @implSpec This default implementation behaves as if {@code - * thenComparing(comparing(keyExtractor))}. + * thenComparing(comparingLong(keyExtractor))}. * * @param keyExtractor the function used to extract the long sort key * @return a lexicographic-order comparator composed of this and then the * {@code long} sort key * @throws NullPointerException if the argument is null. - * @see #comparing(ToLongFunction) + * @see #comparingLong(ToLongFunction) * @see #thenComparing(Comparator) * @since 1.8 */ - default Comparator thenComparing(ToLongFunction keyExtractor) { - return thenComparing(comparing(keyExtractor)); + default Comparator thenComparingLong(ToLongFunction keyExtractor) { + return thenComparing(comparingLong(keyExtractor)); } /** @@ -308,18 +308,18 @@ public interface Comparator { * extracts a {@code double} sort key. * * @implSpec This default implementation behaves as if {@code - * thenComparing(comparing(keyExtractor))}. + * thenComparing(comparingDouble(keyExtractor))}. * * @param keyExtractor the function used to extract the double sort key * @return a lexicographic-order comparator composed of this and then the * {@code double} sort key * @throws NullPointerException if the argument is null. - * @see #comparing(ToDoubleFunction) + * @see #comparingDouble(ToDoubleFunction) * @see #thenComparing(Comparator) * @since 1.8 */ - default Comparator thenComparing(ToDoubleFunction keyExtractor) { - return thenComparing(comparing(keyExtractor)); + default Comparator thenComparingDouble(ToDoubleFunction keyExtractor) { + return thenComparing(comparingDouble(keyExtractor)); } /** @@ -484,7 +484,7 @@ public interface Comparator { * @throws NullPointerException if the argument is null * @since 1.8 */ - public static Comparator comparing(ToIntFunction keyExtractor) { + public static Comparator comparingInt(ToIntFunction keyExtractor) { Objects.requireNonNull(keyExtractor); return (Comparator & Serializable) (c1, c2) -> Integer.compare(keyExtractor.applyAsInt(c1), keyExtractor.applyAsInt(c2)); @@ -505,7 +505,7 @@ public interface Comparator { * @throws NullPointerException if the argument is null * @since 1.8 */ - public static Comparator comparing(ToLongFunction keyExtractor) { + public static Comparator comparingLong(ToLongFunction keyExtractor) { Objects.requireNonNull(keyExtractor); return (Comparator & Serializable) (c1, c2) -> Long.compare(keyExtractor.applyAsLong(c1), keyExtractor.applyAsLong(c2)); @@ -526,7 +526,7 @@ public interface Comparator { * @throws NullPointerException if the argument is null * @since 1.8 */ - public static Comparator comparing(ToDoubleFunction keyExtractor) { + public static Comparator comparingDouble(ToDoubleFunction keyExtractor) { Objects.requireNonNull(keyExtractor); return (Comparator & Serializable) (c1, c2) -> Double.compare(keyExtractor.applyAsDouble(c1), keyExtractor.applyAsDouble(c2)); diff --git a/jdk/test/java/util/Comparator/BasicTest.java b/jdk/test/java/util/Comparator/BasicTest.java index 5bbb700e0b3..b4eb5d4ac40 100644 --- a/jdk/test/java/util/Comparator/BasicTest.java +++ b/jdk/test/java/util/Comparator/BasicTest.java @@ -90,7 +90,7 @@ public class BasicTest { Thing[] things = new Thing[intValues.length]; for (int i=0; i comp = Comparator.comparing(new ToIntFunction() { + Comparator comp = Comparator.comparingInt(new ToIntFunction() { @Override public int applyAsInt(Thing thing) { return thing.getIntField(); @@ -104,7 +104,7 @@ public class BasicTest { Thing[] things = new Thing[longValues.length]; for (int i=0; i comp = Comparator.comparing(new ToLongFunction() { + Comparator comp = Comparator.comparingLong(new ToLongFunction() { @Override public long applyAsLong(Thing thing) { return thing.getLongField(); @@ -118,7 +118,7 @@ public class BasicTest { Thing[] things = new Thing[doubleValues.length]; for (int i=0; i comp = Comparator.comparing(new ToDoubleFunction() { + Comparator comp = Comparator.comparingDouble(new ToDoubleFunction() { @Override public double applyAsDouble(Thing thing) { return thing.getDoubleField(); @@ -211,8 +211,8 @@ public class BasicTest { }; public void testComparatorDefaultMethods() { - Comparator cmp = Comparator.comparing((Function) People::getFirstName); - Comparator cmp2 = Comparator.comparing((Function) People::getLastName); + Comparator cmp = Comparator.comparing(People::getFirstName); + Comparator cmp2 = Comparator.comparing(People::getLastName); // reverseOrder assertComparison(cmp.reversed(), people[1], people[0]); // thenComparing(Comparator) @@ -222,20 +222,20 @@ public class BasicTest { assertComparison(cmp.thenComparing(People::getLastName), people[0], people[1]); assertComparison(cmp.thenComparing(People::getLastName), people[4], people[0]); // thenComparing(ToIntFunction) - assertComparison(cmp.thenComparing(People::getAge), people[0], people[1]); - assertComparison(cmp.thenComparing(People::getAge), people[1], people[5]); + assertComparison(cmp.thenComparingInt(People::getAge), people[0], people[1]); + assertComparison(cmp.thenComparingInt(People::getAge), people[1], people[5]); // thenComparing(ToLongFunction) - assertComparison(cmp.thenComparing(People::getAgeAsLong), people[0], people[1]); - assertComparison(cmp.thenComparing(People::getAgeAsLong), people[1], people[5]); + assertComparison(cmp.thenComparingLong(People::getAgeAsLong), people[0], people[1]); + assertComparison(cmp.thenComparingLong(People::getAgeAsLong), people[1], people[5]); // thenComparing(ToDoubleFunction) - assertComparison(cmp.thenComparing(People::getAgeAsDouble), people[0], people[1]); - assertComparison(cmp.thenComparing(People::getAgeAsDouble), people[1], people[5]); + assertComparison(cmp.thenComparingDouble(People::getAgeAsDouble), people[0], people[1]); + assertComparison(cmp.thenComparingDouble(People::getAgeAsDouble), people[1], people[5]); } public void testNullsFirst() { Comparator strcmp = Comparator.nullsFirst(Comparator.naturalOrder()); - Comparator cmp = Comparator.comparing(People::getLastName, strcmp) + Comparator cmp = Comparator.comparing(People::getLastName, strcmp) .thenComparing(People::getFirstName, strcmp); // Mary.null vs Mary.Cook - solve by last name assertComparison(cmp, people[6], people[5]); @@ -243,7 +243,7 @@ public class BasicTest { assertComparison(cmp, people[7], people[6]); // More than one thenComparing - strcmp = Comparator.nullsFirst(Comparator.comparing((ToIntFunction) String::length) + strcmp = Comparator.nullsFirst(Comparator.comparingInt(String::length) .thenComparing(String.CASE_INSENSITIVE_ORDER)); assertComparison(strcmp, null, "abc"); assertComparison(strcmp, "ab", "abc"); @@ -273,7 +273,7 @@ public class BasicTest { public void testNullsLast() { Comparator strcmp = Comparator.nullsLast(Comparator.naturalOrder()); - Comparator cmp = Comparator.comparing(People::getLastName, strcmp) + Comparator cmp = Comparator.comparing(People::getLastName, strcmp) .thenComparing(People::getFirstName, strcmp); // Mary.null vs Mary.Cook - solve by last name assertComparison(cmp, people[5], people[6]); @@ -281,7 +281,7 @@ public class BasicTest { assertComparison(cmp, people[7], people[6]); // More than one thenComparing - strcmp = Comparator.nullsLast(Comparator.comparing((ToIntFunction) String::length) + strcmp = Comparator.nullsLast(Comparator.comparingInt(String::length) .thenComparing(String.CASE_INSENSITIVE_ORDER)); assertComparison(strcmp, "abc", null); assertComparison(strcmp, "ab", "abc"); @@ -341,28 +341,28 @@ public class BasicTest { } catch (NullPointerException npe) {} try { - Comparator cmp = Comparator.comparing((Function) null, Comparator.naturalOrder()); + Comparator cmp = Comparator.comparing(null, Comparator.naturalOrder()); fail("comparing(null, cmp) should throw NPE"); } catch (NullPointerException npe) {} try { - Comparator cmp = Comparator.comparing((Function) People::getFirstName, null); + Comparator cmp = Comparator.comparing(People::getFirstName, null); fail("comparing(f, null) should throw NPE"); } catch (NullPointerException npe) {} try { - Comparator cmp = Comparator.comparing((Function) null); + Comparator cmp = Comparator.comparing(null); fail("comparing(null) should throw NPE"); } catch (NullPointerException npe) {} try { - Comparator cmp = Comparator.comparing((ToIntFunction) null); + Comparator cmp = Comparator.comparingInt(null); fail("comparing(null) should throw NPE"); } catch (NullPointerException npe) {} try { - Comparator cmp = Comparator.comparing((ToLongFunction) null); + Comparator cmp = Comparator.comparingLong(null); fail("comparing(null) should throw NPE"); } catch (NullPointerException npe) {} try { - Comparator cmp = Comparator.comparing((ToDoubleFunction) null); + Comparator cmp = Comparator.comparingDouble(null); fail("comparing(null) should throw NPE"); } catch (NullPointerException npe) {} } diff --git a/jdk/test/java/util/Map/EntryComparators.java b/jdk/test/java/util/Map/EntryComparators.java index ce607a36901..631107eada9 100644 --- a/jdk/test/java/util/Map/EntryComparators.java +++ b/jdk/test/java/util/Map/EntryComparators.java @@ -115,8 +115,8 @@ public class EntryComparators { // Comparator cmp = Comparator.naturalOrder(); // Should fail to compiler as People is not comparable // We can use simple comparator, but those have been tested above. // Thus choose to do compose for some level of interation. - Comparator cmp1 = Comparator.comparing((Function) People::getFirstName); - Comparator cmp2 = Comparator.comparing((Function) People::getLastName); + Comparator cmp1 = Comparator.comparing(People::getFirstName); + Comparator cmp2 = Comparator.comparing(People::getLastName); Comparator cmp = cmp1.thenComparing(cmp2); assertPairComparison(people[0], people[0], people[1], people[1], diff --git a/jdk/test/java/util/function/BinaryOperator/BasicTest.java b/jdk/test/java/util/function/BinaryOperator/BasicTest.java index 1519fb88177..0c37a9c5c62 100644 --- a/jdk/test/java/util/function/BinaryOperator/BasicTest.java +++ b/jdk/test/java/util/function/BinaryOperator/BasicTest.java @@ -67,26 +67,26 @@ public class BasicTest { }; public void testMaxBy() { - Comparator cmp = Comparator.comparing((Function) People::getFirstName); + Comparator cmp = Comparator.comparing(People::getFirstName); // lesser assertSame(maxBy(cmp).apply(people[0], people[1]), people[1]); // euqal - cmp = Comparator.comparing((Function) People::getLastName); + cmp = Comparator.comparing(People::getLastName); assertSame(maxBy(cmp).apply(people[0], people[1]), people[0]); // greater - cmp = Comparator.comparing((ToIntFunction) People::getAge); + cmp = Comparator.comparingInt(People::getAge); assertSame(maxBy(cmp).apply(people[0], people[1]), people[0]); } - public void testLesserOf() { - Comparator cmp = Comparator.comparing((Function) People::getFirstName); + public void testMinBy() { + Comparator cmp = Comparator.comparing(People::getFirstName); // lesser assertSame(minBy(cmp).apply(people[0], people[1]), people[0]); // euqal - cmp = Comparator.comparing((Function) People::getLastName); + cmp = Comparator.comparing(People::getLastName); assertSame(minBy(cmp).apply(people[0], people[1]), people[0]); // greater - cmp = Comparator.comparing((ToIntFunction) People::getAge); + cmp = Comparator.comparingInt(People::getAge); assertSame(minBy(cmp).apply(people[0], people[1]), people[1]); } From f3ca3801d9915c9fa6b70bc085584e959bfcca67 Mon Sep 17 00:00:00 2001 From: Vladimir Kempik Date: Wed, 21 Aug 2013 22:12:11 -0700 Subject: [PATCH 052/117] 8020530: Non heap memory size calculated incorrectly Reviewed-by: coleenp, sla --- hotspot/src/share/vm/services/management.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index a2c8944ee42..5cc0cc4ffcc 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -876,8 +876,6 @@ JVM_ENTRY(jobject, jmm_GetMemoryUsage(JNIEnv* env, jboolean heap)) total_used += u.used(); total_committed += u.committed(); - // if any one of the memory pool has undefined init_size or max_size, - // set it to -1 if (u.init_size() == (size_t)-1) { has_undefined_init_size = true; } @@ -894,6 +892,15 @@ JVM_ENTRY(jobject, jmm_GetMemoryUsage(JNIEnv* env, jboolean heap)) } } + // if any one of the memory pool has undefined init_size or max_size, + // set it to -1 + if (has_undefined_init_size) { + total_init = (size_t)-1; + } + if (has_undefined_max_size) { + total_max = (size_t)-1; + } + MemoryUsage usage((heap ? InitialHeapSize : total_init), total_used, total_committed, From 7b989a82fd6d727cef92ff53884c2bf7aef26bbc Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 22 Aug 2013 10:22:44 +0100 Subject: [PATCH 053/117] 8022316: Generic throws, overriding and method reference Reviewed-by: jjg, mcimadamore --- .../com/sun/tools/javac/code/Types.java | 23 +++++- ...lerErrorGenericThrowPlusMethodRefTest.java | 78 +++++++++++++++++++ ...ilerErrorGenericThrowPlusMethodRefTest.out | 2 + 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java create mode 100644 langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index e1887b5f4a6..06744bf6d06 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -505,12 +505,27 @@ public class Types { //merge thrown types - form the intersection of all the thrown types in //all the signatures in the list + boolean toErase = !bestSoFar.type.hasTag(FORALL); List thrown = null; - for (Symbol msym1 : methodSyms) { - Type mt1 = memberType(origin.type, msym1); + Type mt1 = memberType(origin.type, bestSoFar); + for (Symbol msym2 : methodSyms) { + Type mt2 = memberType(origin.type, msym2); + List thrown_mt2 = mt2.getThrownTypes(); + if (toErase) { + thrown_mt2 = erasure(thrown_mt2); + } else { + /* If bestSoFar is generic then all the methods are generic. + * The opposite is not true: a non generic method can override + * a generic method (raw override) so it's safe to cast mt1 and + * mt2 to ForAll. + */ + ForAll fa1 = (ForAll)mt1; + ForAll fa2 = (ForAll)mt2; + thrown_mt2 = subst(thrown_mt2, fa2.tvars, fa1.tvars); + } thrown = (thrown == null) ? - mt1.getThrownTypes() : - chk.intersect(mt1.getThrownTypes(), thrown); + thrown_mt2 : + chk.intersect(thrown_mt2, thrown); } final List thrown1 = thrown; diff --git a/langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java b/langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java new file mode 100644 index 00000000000..f7d0391649e --- /dev/null +++ b/langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.java @@ -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. 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. + */ + +/* + * @test + * @bug 8022316 + * @summary Generic throws, overriding and method reference + * @compile/fail/ref=CompilerErrorGenericThrowPlusMethodRefTest.out -XDrawDiagnostics CompilerErrorGenericThrowPlusMethodRefTest.java + */ + +@SuppressWarnings("unchecked") +public class CompilerErrorGenericThrowPlusMethodRefTest { + interface SAM11 { + public void foo() throws E ; + } + + interface SAM12 extends SAM11{ + @Override + public void foo() throws Throwable; + } + + public void boo() throws RuntimeException {} + + static void test1() { + try { + SAM12 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::boo; + s2.foo(); + } catch(Throwable ex) {} + } + + static void test2() { + SAM11 s1 = null; + s1.foo(); + s1.foo(); + } + + interface SAM21 { + void m(E arg) throws E; + } + + interface SAM22 { + void m(F arg) throws F; + } + + interface SAM23 extends SAM21, SAM22 {} + + public void bar(E e) throws E {} + + static void test3(E e) { + try { + SAM23 s2 = new CompilerErrorGenericThrowPlusMethodRefTest()::bar; + s2.m(e); + } catch(Exception ex) {} + } + +} diff --git a/langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out b/langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out new file mode 100644 index 00000000000..58015ae026e --- /dev/null +++ b/langtools/test/tools/javac/T8022316/CompilerErrorGenericThrowPlusMethodRefTest.out @@ -0,0 +1,2 @@ +CompilerErrorGenericThrowPlusMethodRefTest.java:55:26: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception +1 error From c65abc95dfa512606607d6d6378cf17c1dc34678 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 22 Aug 2013 13:12:43 +0100 Subject: [PATCH 054/117] 8023112: javac should not use lazy constant evaluation approach for method references Reviewed-by: jjg, mcimadamore --- .../com/sun/tools/javac/comp/Attr.java | 4 +- .../com/sun/tools/javac/comp/MemberEnter.java | 56 +++++++++++++++++- ...pLazyConstantCreationForMethodRefTest.java | 58 +++++++++++++++++++ 3 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/T8023112/SkipLazyConstantCreationForMethodRefTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 17557b3f139..6ef409d9339 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1063,9 +1063,7 @@ public class Attr extends JCTree.Visitor { if (tree.init != null) { if ((v.flags_field & FINAL) != 0 && - !tree.init.hasTag(NEWCLASS) && - !tree.init.hasTag(LAMBDA) && - !tree.init.hasTag(REFERENCE)) { + memberEnter.needsLazyConstValue(tree.init)) { // In this case, `v' is final. Ensure that it's initializer is // evaluated. v.getConstValue(); // ensure initializer is evaluated diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index cdd3db2bcdd..9f9dd4fb874 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -677,8 +677,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { if (tree.init != null) { v.flags_field |= HASINIT; if ((v.flags_field & FINAL) != 0 && - !tree.init.hasTag(NEWCLASS) && - !tree.init.hasTag(LAMBDA)) { + needsLazyConstValue(tree.init)) { Env initEnv = getInitEnv(tree, env); initEnv.info.enclVar = v; v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init); @@ -700,6 +699,59 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } } + public boolean needsLazyConstValue(JCTree tree) { + InitTreeVisitor initTreeVisitor = new InitTreeVisitor(); + tree.accept(initTreeVisitor); + return initTreeVisitor.result; + } + + /** Visitor class for expressions which might be constant expressions. + */ + static class InitTreeVisitor extends JCTree.Visitor { + + private boolean result = true; + + @Override + public void visitTree(JCTree tree) {} + + @Override + public void visitNewClass(JCNewClass that) { + result = false; + } + + @Override + public void visitLambda(JCLambda that) { + result = false; + } + + @Override + public void visitReference(JCMemberReference that) { + result = false; + } + + @Override + public void visitSelect(JCFieldAccess tree) { + tree.selected.accept(this); + } + + @Override + public void visitConditional(JCConditional tree) { + tree.cond.accept(this); + tree.truepart.accept(this); + tree.falsepart.accept(this); + } + + @Override + public void visitParens(JCParens tree) { + tree.expr.accept(this); + } + + @Override + public void visitTypeCast(JCTypeCast tree) { + tree.expr.accept(this); + } + } + /** Create a fresh environment for a variable's initializer. * If the variable is a field, the owner of the environment's scope * is be the variable itself, otherwise the owner is the method diff --git a/langtools/test/tools/javac/T8023112/SkipLazyConstantCreationForMethodRefTest.java b/langtools/test/tools/javac/T8023112/SkipLazyConstantCreationForMethodRefTest.java new file mode 100644 index 00000000000..e0c530c5c47 --- /dev/null +++ b/langtools/test/tools/javac/T8023112/SkipLazyConstantCreationForMethodRefTest.java @@ -0,0 +1,58 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8023112 + * @summary Mixing up the method type argument with the class type for method + * reference ClassType::new + * @compile SkipLazyConstantCreationForMethodRefTest.java + */ + +public class SkipLazyConstantCreationForMethodRefTest { + SkipLazyConstantCreationForMethodRefTest(int a, boolean b) {} + SkipLazyConstantCreationForMethodRefTest() {} +} + +class SubClass extends SkipLazyConstantCreationForMethodRefTest { + SubClass(int a, boolean b) {} +} + +interface SAM { + SubClass m(int a, boolean b); +} + +interface Tester1 { + SAM s11 = SubClass::new; + SAM s12 = (SubClass::new); + SAM s13 = (SAM)SubClass::new; + SAM s14 = true ? s11 : s12; + SAM s15 = true ? s11 : (SAM)SubClass::new; + SAM s16 = true ? (SAM)SubClass::new : s12; +} + +interface Tester2 { + SAM s21 = Tester1.s11; +} From cc6216ae2ecdf8d51eb70ebd4aeb8f361c740fef Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 22 Aug 2013 18:46:26 +0530 Subject: [PATCH 055/117] 8023551: Mirror functions can not be invoked using invokeMethod, invokeFunction Reviewed-by: attila, jlaskey, lagergren --- .../api/scripting/NashornScriptEngine.java | 15 ++++--- .../api/scripting/ScriptObjectMirror.java | 20 +++++---- nashorn/test/script/basic/JDK-8023551.js | 42 +++++++++++++++++++ .../test/script/basic/JDK-8023551.js.EXPECTED | 2 + .../api/scripting/ScriptEngineTest.java | 26 ++++++++++++ 5 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8023551.js create mode 100644 nashorn/test/script/basic/JDK-8023551.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index 063bc08fd70..e3f09139e95 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -321,10 +321,11 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C private ScriptObject getNashornGlobalFrom(final ScriptContext ctxt) { final Bindings bindings = ctxt.getBindings(ScriptContext.ENGINE_SCOPE); if (bindings instanceof ScriptObjectMirror) { - ScriptObject sobj = ((ScriptObjectMirror)bindings).getScriptObject(); - if (sobj instanceof GlobalObject) { - return sobj; - } + final ScriptObjectMirror mirror = (ScriptObjectMirror)bindings; + ScriptObject sobj = ((ScriptObjectMirror)bindings).getScriptObject(); + if (sobj instanceof GlobalObject && sobj.isOfContext(nashornContext)) { + return sobj; + } } // didn't find global object from context given - return the engine-wide global @@ -402,8 +403,10 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C args = ScriptRuntime.EMPTY_ARRAY; } // if no arguments passed, expose it - args = ((GlobalObject)ctxtGlobal).wrapAsObject(args); - ctxtGlobal.set("arguments", args, false); + if (! (args instanceof ScriptObject)) { + args = ((GlobalObject)ctxtGlobal).wrapAsObject(args); + ctxtGlobal.set("arguments", args, false); + } } private Object invokeImpl(final Object selfObject, final String name, final Object... args) throws ScriptException, NoSuchMethodException { diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index dbdb9b67bd5..0e11c8af8cf 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -99,12 +99,14 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { } final Object val = functionName == null? sobj : sobj.get(functionName); - if (! (val instanceof ScriptFunction)) { - throw new NoSuchMethodException("No such function " + ((functionName != null)? functionName : "")); + if (val instanceof ScriptFunction) { + final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args; + return wrap(ScriptRuntime.checkAndApply((ScriptFunction)val, sobj, unwrapArray(modArgs, global)), global); + } else if (val instanceof ScriptObjectMirror && ((ScriptObjectMirror)val).isFunction()) { + return ((ScriptObjectMirror)val).call(null, args); } - final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args; - return wrap(ScriptRuntime.checkAndApply((ScriptFunction)val, sobj, unwrapArray(modArgs, global)), global); + throw new NoSuchMethodException("No such function " + ((functionName != null)? functionName : "")); } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { @@ -127,12 +129,14 @@ public final class ScriptObjectMirror extends JSObject implements Bindings { } final Object val = functionName == null? sobj : sobj.get(functionName); - if (! (val instanceof ScriptFunction)) { - throw new RuntimeException("not a constructor " + ((functionName != null)? functionName : "")); + if (val instanceof ScriptFunction) { + final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args; + return wrap(ScriptRuntime.checkAndConstruct((ScriptFunction)val, unwrapArray(modArgs, global)), global); + } else if (val instanceof ScriptObjectMirror && ((ScriptObjectMirror)val).isFunction()) { + return ((ScriptObjectMirror)val).newObject(null, args); } - final Object[] modArgs = globalChanged? wrapArray(args, oldGlobal) : args; - return wrap(ScriptRuntime.checkAndConstruct((ScriptFunction)val, unwrapArray(modArgs, global)), global); + throw new RuntimeException("not a constructor " + ((functionName != null)? functionName : "")); } catch (final RuntimeException | Error e) { throw e; } catch (final Throwable t) { diff --git a/nashorn/test/script/basic/JDK-8023551.js b/nashorn/test/script/basic/JDK-8023551.js new file mode 100644 index 00000000000..8545fbb5ef4 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023551.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023551: Mirror functions can not be invoked using invokeMethod, invokeFunction + * + * @test + * @run + */ + +var m = new javax.script.ScriptEngineManager(); +var e = m.getEngineByName("nashorn"); + +function func(x) { + print("func: " + x); +} + +e.put("func", func); +e.invokeFunction("func", "hello"); + +var obj = e.eval("({ foo: func })"); +e.invokeMethod(obj, "foo", "world"); diff --git a/nashorn/test/script/basic/JDK-8023551.js.EXPECTED b/nashorn/test/script/basic/JDK-8023551.js.EXPECTED new file mode 100644 index 00000000000..90e9041f6fc --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023551.js.EXPECTED @@ -0,0 +1,2 @@ +func: hello +func: world diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index fe4bf39ba45..3cad7095517 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -1256,4 +1256,30 @@ public class ScriptEngineTest { // dos2unix - fix line endings if running on windows assertEquals(sw.toString().replaceAll("\r", ""), "34 true hello\n"); } + + @Test + public void mirrorNewObjectGlobalFunctionTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final ScriptEngine e2 = m.getEngineByName("nashorn"); + + e.eval("function func() {}"); + e2.put("foo", e.get("func")); + final Object e2global = e2.eval("this"); + final Object newObj = ((ScriptObjectMirror)e2global).newObject("foo"); + assertTrue(newObj instanceof ScriptObjectMirror); + } + + @Test + public void mirrorNewObjectInstanceFunctionTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final ScriptEngine e2 = m.getEngineByName("nashorn"); + + e.eval("function func() {}"); + e2.put("func", e.get("func")); + final Object e2obj = e2.eval("({ foo: func })"); + final Object newObj = ((ScriptObjectMirror)e2obj).newObject("foo"); + assertTrue(newObj instanceof ScriptObjectMirror); + } } From 863bbb911b3e84a556cdf0dd56360dc18642408c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Thu, 22 Aug 2013 17:23:50 +0200 Subject: [PATCH 056/117] 8023531: new RegExp('').toString() should return '/(?:)/' Reviewed-by: sundar, jlaskey --- .../internal/runtime/ScriptObject.java | 58 +++++----- .../nashorn/internal/runtime/WithObject.java | 2 +- .../internal/runtime/regexp/RegExp.java | 2 +- nashorn/test/script/basic/JDK-8023531.js | 106 ++++++++++++++++++ 4 files changed, 135 insertions(+), 33 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8023531.js diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 481a708bcb7..363891d9ce4 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -1008,10 +1008,6 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return getMap().findProperty(key); } - static String convertKey(final Object key) { - return (key instanceof String) ? (String)key : JSType.toString(key); - } - /** * Overridden by {@link jdk.nashorn.internal.objects.NativeArguments} class (internal use.) * Used for argument access in a vararg function using parameter name. @@ -2374,7 +2370,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getInt(index); } - return getInt(index, convertKey(key)); + return getInt(index, JSType.toString(key)); } @Override @@ -2386,7 +2382,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getInt(index); } - return getInt(index, convertKey(key)); + return getInt(index, JSType.toString(key)); } @Override @@ -2398,7 +2394,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getInt(index); } - return getInt(index, convertKey(key)); + return getInt(index, JSType.toString(key)); } @Override @@ -2409,7 +2405,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getInt(key); } - return getInt(key, convertKey(key)); + return getInt(key, JSType.toString(key)); } private long getLong(final int index, final String key) { @@ -2451,7 +2447,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getLong(index); } - return getLong(index, convertKey(key)); + return getLong(index, JSType.toString(key)); } @Override @@ -2463,7 +2459,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getLong(index); } - return getLong(index, convertKey(key)); + return getLong(index, JSType.toString(key)); } @Override @@ -2475,7 +2471,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getLong(index); } - return getLong(index, convertKey(key)); + return getLong(index, JSType.toString(key)); } @Override @@ -2486,7 +2482,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getLong(key); } - return getLong(key, convertKey(key)); + return getLong(key, JSType.toString(key)); } private double getDouble(final int index, final String key) { @@ -2528,7 +2524,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getDouble(index); } - return getDouble(index, convertKey(key)); + return getDouble(index, JSType.toString(key)); } @Override @@ -2540,7 +2536,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getDouble(index); } - return getDouble(index, convertKey(key)); + return getDouble(index, JSType.toString(key)); } @Override @@ -2552,7 +2548,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getDouble(index); } - return getDouble(index, convertKey(key)); + return getDouble(index, JSType.toString(key)); } @Override @@ -2563,7 +2559,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getDouble(key); } - return getDouble(key, convertKey(key)); + return getDouble(key, JSType.toString(key)); } private Object get(final int index, final String key) { @@ -2605,7 +2601,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getObject(index); } - return get(index, convertKey(key)); + return get(index, JSType.toString(key)); } @Override @@ -2617,7 +2613,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getObject(index); } - return get(index, convertKey(key)); + return get(index, JSType.toString(key)); } @Override @@ -2629,7 +2625,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getObject(index); } - return get(index, convertKey(key)); + return get(index, JSType.toString(key)); } @Override @@ -2640,7 +2636,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return array.getObject(key); } - return get(key, convertKey(key)); + return get(key, JSType.toString(key)); } /** @@ -2655,7 +2651,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr final long longIndex = index & JSType.MAX_UINT; if (!getArray().has(index)) { - final String key = convertKey(longIndex); + final String key = JSType.toString(longIndex); final FindProperty find = findProperty(key, true); if (find != null) { @@ -2801,7 +2797,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return; } - final String propName = convertKey(key); + final String propName = JSType.toString(key); final FindProperty find = findProperty(propName, true); setObject(find, strict, propName, value); @@ -3023,7 +3019,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr } } - final FindProperty find = findProperty(convertKey(key), true); + final FindProperty find = findProperty(JSType.toString(key), true); return find != null; } @@ -3040,7 +3036,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr } } - final FindProperty find = findProperty(convertKey(key), true); + final FindProperty find = findProperty(JSType.toString(key), true); return find != null; } @@ -3057,7 +3053,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr } } - final FindProperty find = findProperty(convertKey(key), true); + final FindProperty find = findProperty(JSType.toString(key), true); return find != null; } @@ -3074,7 +3070,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr } } - final FindProperty find = findProperty(convertKey(key), true); + final FindProperty find = findProperty(JSType.toString(key), true); return find != null; } @@ -3087,7 +3083,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return true; } - final FindProperty find = findProperty(convertKey(key), false); + final FindProperty find = findProperty(JSType.toString(key), false); return find != null; } @@ -3100,7 +3096,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return true; } - final FindProperty find = findProperty(convertKey(key), false); + final FindProperty find = findProperty(JSType.toString(key), false); return find != null; } @@ -3113,7 +3109,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return true; } - final FindProperty find = findProperty(convertKey(key), false); + final FindProperty find = findProperty(JSType.toString(key), false); return find != null; } @@ -3126,7 +3122,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr return true; } - final FindProperty find = findProperty(convertKey(key), false); + final FindProperty find = findProperty(JSType.toString(key), false); return find != null; } @@ -3196,7 +3192,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr } private boolean deleteObject(final Object key, final boolean strict) { - final String propName = convertKey(key); + final String propName = JSType.toString(key); final FindProperty find = findProperty(propName, false); if (find == null) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java index 7c08e8545ab..46de1d13ee5 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java @@ -73,7 +73,7 @@ public final class WithObject extends ScriptObject implements Scope { public boolean delete(final Object key, final boolean strict) { if (expression instanceof ScriptObject) { final ScriptObject self = (ScriptObject)expression; - final String propName = ScriptObject.convertKey(key); + final String propName = JSType.toString(key); final FindProperty find = self.findProperty(propName, true); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java index ff694b90790..65c944e14c9 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/regexp/RegExp.java @@ -60,7 +60,7 @@ public abstract class RegExp { * @param flags the flags string */ protected RegExp(final String source, final String flags) { - this.source = source; + this.source = source.length() == 0 ? "(?:)" : source; for (int i = 0; i < flags.length(); i++) { final char ch = flags.charAt(i); switch (ch) { diff --git a/nashorn/test/script/basic/JDK-8023531.js b/nashorn/test/script/basic/JDK-8023531.js new file mode 100644 index 00000000000..819e46b73cf --- /dev/null +++ b/nashorn/test/script/basic/JDK-8023531.js @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * JDK-8023531: new RegExp('').toString() should return '/(?:)/' + * + * @test + * @run + */ + +if (new RegExp("").toString() !== "/(?:)/") { + throw new Error(); +} else if (!(new RegExp("").test(""))) { + throw new Error(); +} + +if (new RegExp("", "g").toString() !== "/(?:)/g") { + throw new Error(); +} else if (!(new RegExp("", "g").test(""))) { + throw new Error(); +} + +if (new RegExp("", "i").toString() !== "/(?:)/i") { + throw new Error(); +} else if (!(new RegExp("", "i").test(""))) { + throw new Error(); +} + +if (new RegExp("", "m").toString() !== "/(?:)/m") { + throw new Error(); +} else if (!(new RegExp("", "m").test(""))) { + throw new Error(); +} + +if (RegExp("").toString() !== "/(?:)/") { + throw new Error(); +} else if (!RegExp("").test("")) { + throw new Error(); +} + +if (RegExp("", "g").toString() !== "/(?:)/g") { + throw new Error(); +} else if (!RegExp("", "g").test("")) { + throw new Error(); +} + +if (RegExp("", "i").toString() !== "/(?:)/i") { + throw new Error(); +} else if (!RegExp("", "i").test("")) { + throw new Error(); +} + +if (RegExp("", "m").toString() !== "/(?:)/m") { + throw new Error(); +} else if (!RegExp("", "m").test("")) { + throw new Error(); +} + +var re = /abc/; +re.compile(""); +if (re.toString() !== "/(?:)/") { + throw new Error(); +} else if (!re.test("")) { + throw new Error(); +} + +re.compile("", "g"); +if (re.toString() !== "/(?:)/g") { + throw new Error(); +} else if (!re.test("")) { + throw new Error(); +} + +re.compile("", "i"); +if (re.toString() !== "/(?:)/i") { + throw new Error(); +} else if (!re.test("")) { + throw new Error(); +} + +re.compile("", "m"); +if (re.toString() !== "/(?:)/m") { + throw new Error(); +} else if (!re.test("")) { + throw new Error(); +} From 2df9b70f5e59694313df2acb99f92c2e701ce449 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Thu, 22 Aug 2013 11:52:27 -0400 Subject: [PATCH 057/117] 7121403: [TESTBUG] runtime/7051189/Xchecksig.sh fails on 64bit solaris 8023393: Need to suppress info message if -Xcheck:jni used with libjsig.dylab on Mac OSX Rewrite 7051189 test in Java, port Linux fix for 7051189 to Mac OSX. Reviewed-by: coleenp, dholmes, mseledtsov, ccheung --- hotspot/src/os/bsd/vm/os_bsd.cpp | 8 +- hotspot/test/runtime/7051189/Xchecksig.sh | 126 ------------------ .../runtime/XCheckJniJsig/XCheckJSig.java | 82 ++++++++++++ 3 files changed, 88 insertions(+), 128 deletions(-) delete mode 100644 hotspot/test/runtime/7051189/Xchecksig.sh create mode 100644 hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index cc6d13e2c1d..1db3739fa84 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -3287,11 +3287,15 @@ void os::Bsd::install_signal_handlers() { // and if UserSignalHandler is installed all bets are off if (CheckJNICalls) { if (libjsig_is_loaded) { - tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); + if (PrintJNIResolving) { + tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); + } check_signals = false; } if (AllowUserSignalHandlers) { - tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); + if (PrintJNIResolving) { + tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); + } check_signals = false; } } diff --git a/hotspot/test/runtime/7051189/Xchecksig.sh b/hotspot/test/runtime/7051189/Xchecksig.sh deleted file mode 100644 index 143e1445624..00000000000 --- a/hotspot/test/runtime/7051189/Xchecksig.sh +++ /dev/null @@ -1,126 +0,0 @@ -# -# Copyright (c) 2011, 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 Xchecksig.sh -# @bug 7051189 -# @summary Need to suppress info message if -xcheck:jni used with libjsig.so -# @run shell Xchecksig.sh -# - -if [ "${TESTSRC}" = "" ] -then - TESTSRC=${PWD} - echo "TESTSRC not set. Using "${TESTSRC}" as default" -fi -echo "TESTSRC=${TESTSRC}" -## Adding common setup Variables for running shell tests. -. ${TESTSRC}/../../test_env.sh - -OS=`uname -s` -case "$OS" in - Windows_* | CYGWIN_* ) - printf "Not testing libjsig.so on Windows. PASSED.\n " - exit 0 - ;; -esac - -JAVA=${TESTJAVA}${FS}bin${FS}java - -# LD_PRELOAD arch needs to match the binary we run, so run the java -# 64-bit binary directly if we are testing 64-bit (bin/ARCH/java). -# Check if TESTVMOPS contains -d64, but cannot use -# java ${TESTVMOPS} to run "java -d64" with LD_PRELOAD. - -if [ ${OS} -eq "SunOS" ] -then - printf "SunOS test TESTVMOPTS = ${TESTVMOPTS}" - printf ${TESTVMOPTS} | grep d64 > /dev/null - if [ $? -eq 0 ] - then - printf "SunOS 64-bit test\n" - BIT_FLAG=-d64 - fi -fi - -ARCH=`uname -p` -case $ARCH in - i386) - if [ X${BIT_FLAG} != "X" ] - then - ARCH=amd64 - JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java - fi - ;; - sparc) - if [ X${BIT_FLAG} != "X" ] - then - ARCH=sparcv9 - JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java - fi - ;; - * ) - printf "Not testing architecture $ARCH, skipping test.\n" - exit 0 - ;; -esac - -LIBJSIG=${COMPILEJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so - -# If libjsig and binary do not match, skip test. - -A=`file ${LIBJSIG} | awk '{ print $3 }'` -B=`file ${JAVA} | awk '{ print $3 }'` - -if [ $A -ne $B ] -then - printf "Mismatching binary and library to preload, skipping test.\n" - exit 0 -fi - -if [ ! -f ${LIBJSIG} ] -then - printf "Skipping test: libjsig missing for given architecture: ${LIBJSIG}\n" - exit 0 -fi -# Use java -version to test, java version info appears on stderr, -# the libjsig message we are removing appears on stdout. - -# grep returns zero meaning found, non-zero means not found: - -LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -version 2>&1 | grep "libjsig is activated" -if [ $? -eq 0 ]; then - printf "Failed: -Xcheck:jni prints message when libjsig.so is loaded.\n" - exit 1 -fi - - -LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated" -if [ $? != 0 ]; then - printf "Failed: -Xcheck:jni does not print message when libjsig.so is loaded and -verbose:jni is set.\n" - exit 1 -fi - -printf "PASSED\n" -exit 0 - diff --git a/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java b/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java new file mode 100644 index 00000000000..ae0ad73cd3d --- /dev/null +++ b/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java @@ -0,0 +1,82 @@ +/* + * 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 7051189 8023393 + * @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so + * @library /testlibrary + * @run main XCheckJSig + */ + +import java.util.*; +import com.oracle.java.testlibrary.*; + +public class XCheckJSig { + public static void main(String args[]) throws Throwable { + + System.out.println("Regression test for bugs 7051189 and 8023393"); + if (!Platform.isSolaris() && !Platform.isLinux() && !Platform.isOSX()) { + System.out.println("Test only applicable on Solaris, Linux, and Mac OSX, skipping"); + return; + } + + String jdk_path = System.getProperty("test.jdk"); + String os_arch = Platform.getOsArch(); + String libjsig; + String env_var; + if (Platform.isOSX()) { + libjsig = jdk_path + "/jre/lib/server/libjsig.dylib"; + env_var = "DYLD_INSERT_LIBRARIES"; + } else { + libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; + env_var = "LD_PRELOAD"; + } + String java_program; + if (Platform.isSolaris()) { + // On Solaris, need to call the 64-bit Java directly in order for + // LD_PRELOAD to work because libjsig.so is 64-bit. + java_program = jdk_path + "/jre/bin/" + os_arch + "/java"; + } else { + java_program = JDKToolFinder.getJDKTool("java"); + } + // If this test fails, these might be useful to know. + System.out.println("libjsig: " + libjsig); + System.out.println("osArch: " + os_arch); + System.out.println("java_program: " + java_program); + + ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version"); + Map env = pb.environment(); + env.put(env_var, libjsig); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("libjsig is activated"); + output.shouldHaveExitValue(0); + + pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version"); + env = pb.environment(); + env.put(env_var, libjsig); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("libjsig is activated"); + output.shouldHaveExitValue(0); + } +} From 0d3a9fcd89fe72288d9e22aa1c3584227159740e Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Thu, 22 Aug 2013 12:47:46 -0400 Subject: [PATCH 058/117] 8020745: Suspicious MethodParameters attribute generated for local classes capturing local variables Corrected an error in a previous patch that caused captured locals to be added to the beginning, not the end of a parameter list. Reviewed-by: jjg, mcimadamore, ksrini, abuckley --- .../com/sun/tools/javac/code/Symbol.java | 3 + .../com/sun/tools/javac/comp/Lower.java | 6 +- .../com/sun/tools/javac/jvm/ClassWriter.java | 8 + .../javac/8015701/AnonymousParameters.java | 89 ------ .../javac/MethodParameters/CaptureTest.java | 289 ++++++++++++++++++ 5 files changed, 303 insertions(+), 92 deletions(-) delete mode 100644 langtools/test/tools/javac/8015701/AnonymousParameters.java create mode 100644 langtools/test/tools/javac/MethodParameters/CaptureTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index b36254906d3..c4a4a820344 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -1231,6 +1231,9 @@ public abstract class Symbol implements Element { /** The extra (synthetic/mandated) parameters of the method. */ public List extraParams = List.nil(); + /** The captured local variables in an anonymous class */ + public List capturedLocals = List.nil(); + /** The parameters of the method. */ public List params = null; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index d5f4f4dbfe1..75e1d388666 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2735,9 +2735,9 @@ public class Lower extends TreeTranslator { for (List l = fvs; l.nonEmpty(); l = l.tail) { if (TreeInfo.isInitialConstructor(tree)) { final Name pName = proxyName(l.head.name); - m.extraParams = - m.extraParams.append((VarSymbol) - (proxies.lookup(pName).sym)); + m.capturedLocals = + m.capturedLocals.append((VarSymbol) + (proxies.lookup(pName).sym)); added = added.prepend( initField(tree.body.pos, pName)); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index ac8b94a8310..73eb2d34acf 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -657,6 +657,14 @@ public class ClassWriter extends ClassFile { databuf.appendChar(pool.put(s.name)); databuf.appendChar(flags); } + // Now write the captured locals + for (VarSymbol s : m.capturedLocals) { + final int flags = + ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) | + ((int) m.flags() & SYNTHETIC); + databuf.appendChar(pool.put(s.name)); + databuf.appendChar(flags); + } endAttr(attrIndex); return 1; } else diff --git a/langtools/test/tools/javac/8015701/AnonymousParameters.java b/langtools/test/tools/javac/8015701/AnonymousParameters.java deleted file mode 100644 index 746b2b9696a..00000000000 --- a/langtools/test/tools/javac/8015701/AnonymousParameters.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * 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 8015701 - * @summary javac should generate method parameters correctly. - * @compile -parameters AnonymousParameters.java - * @run main AnonymousParameters - */ -import java.lang.Class; -import java.lang.reflect.Constructor; -import java.lang.reflect.Parameter; -import java.util.concurrent.Callable; - -public class AnonymousParameters { - - String[] names = { - "this$0", - "val$message" - }; - - public static void main(String... args) throws Exception { - new AnonymousParameters().run(); - } - - void run() throws Exception { - Class cls = new ParameterNames().makeInner("hello").getClass(); - Constructor ctor = cls.getDeclaredConstructors()[0]; - Parameter[] params = ctor.getParameters(); - - if(params.length == 2) { - for(int i = 0; i < 2; i++) { - System.err.println("Testing parameter " + params[i].getName()); - if(!params[i].getName().equals(names[i])) - error("Expected parameter name " + names[i] + - " got " + params[i].getName()); - } - } else - error("Expected 2 parameters"); - - if(0 != errors) - throw new Exception("MethodParameters test failed with " + - errors + " errors"); - } - - void error(String msg) { - System.err.println("Error: " + msg); - errors++; - } - - int errors; -} - -class ParameterNames { - - public Callable makeInner(final String message) { - return new Callable() { - public String call() throws Exception { - return message; - } - }; - } - - public static void main(String... args) throws Exception { - ParameterNames test = new ParameterNames(); - System.out.println(test.makeInner("Hello").call()); - } -} diff --git a/langtools/test/tools/javac/MethodParameters/CaptureTest.java b/langtools/test/tools/javac/MethodParameters/CaptureTest.java new file mode 100644 index 00000000000..ed865faecd4 --- /dev/null +++ b/langtools/test/tools/javac/MethodParameters/CaptureTest.java @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8015701 + * @summary Test method parameter attribute generation with captured locals. + * @compile -parameters CaptureTest.java + * @run main CaptureTest + */ +import java.lang.Class; +import java.lang.reflect.Constructor; +import java.lang.reflect.Parameter; +import java.lang.reflect.Modifier; +import java.util.List; +import java.util.ArrayList; + +public class CaptureTest { + + private static final int SYNTHETIC = 0x1000; + private static final int MANDATED = 0x8000; + + public static void main(String... args) throws Exception { + new CaptureTest().run(); + } + + + private void run() throws Exception { + final Encloser pn = new Encloser(); + + /* Cases covered here: + * + * - Local class + * - Inner class + * - Anonymous class + * - Anonymous class extending a local + * - Anonymous class extending an inner + */ + pn.makeLocal("hello").check(); + pn.makeInner("hello").check(); + pn.makeAnon("hello").check(); + pn.makeAnonExtendsLocal("hello").check(); + pn.makeAnonExtendsInner("hello").check(); + + if (0 != errors) + throw new Exception("MethodParameters test failed with " + + errors + " errors"); + } + + private void error(final String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; + + abstract class Tester { + + public Tester(final int param) {} + + protected abstract String[] names(); + protected abstract int[] modifiers(); + protected abstract Class[] types(); + + public void check() { + final Class cls = this.getClass(); + final Constructor ctor = cls.getDeclaredConstructors()[0]; + final Parameter[] params = ctor.getParameters(); + final String[] names = names(); + final int[] modifiers = modifiers(); + final Class[] types = types(); + + System.err.println("Testing class " + cls); + + if (params.length == names.length) { + for (int i = 0; i < names.length; i++) { + System.err.println("Testing parameter " + params[i].getName()); + if (!params[i].getName().equals(names[i])) + error("Expected parameter name " + names[i] + + " got " + params[i].getName()); + if (params[i].getModifiers() != modifiers[i]) + error("Expected parameter modifiers " + + modifiers[i] + " got " + + params[i].getModifiers()); + if (!params[i].getType().equals(types[i])) + error("Expected parameter type " + types[i] + + " got " + params[i].getType()); + } + } else + error("Expected " + names.length + " parameters"); + + } + + } + + class Encloser { + private class InnerTester extends Tester { + public InnerTester(final int innerparam) { + super(innerparam); + } + + protected String[] names() { + return new String[] { + "this$1", + "innerparam" + }; + } + + protected int[] modifiers() { + return new int[] { + Modifier.FINAL | SYNTHETIC, + Modifier.FINAL + }; + } + + protected Class[] types() { + return new Class[] { + Encloser.class, + int.class + }; + } + } + + public Tester makeInner(final String message) { + return new InnerTester(2); + } + + public Tester makeLocal(final String message) { + class LocalTester extends Tester { + public LocalTester(final int localparam) { + super(localparam); + } + + protected String[] names() { + return new String[] { + "this$1", + "localparam", + "val$message" + }; + } + + protected int[] modifiers() { + return new int[] { + Modifier.FINAL | MANDATED, + Modifier.FINAL, + Modifier.FINAL | SYNTHETIC + }; + } + + protected Class[] types() { + return new Class[] { + Encloser.class, + int.class, + String.class + }; + } + + public String message() { + return message; + } + } + + return new LocalTester(2); + } + + public Tester makeAnonExtendsLocal(final String message) { + abstract class LocalTester extends Tester { + public LocalTester(final int localparam) { + super(localparam); + } + + protected String[] names() { + return new String[] { + "this$1", + "localparam", + "val$message" + }; + } + + protected int[] modifiers() { + return new int[] { + Modifier.FINAL | MANDATED, + Modifier.FINAL, + Modifier.FINAL | SYNTHETIC + }; + } + + protected Class[] types() { + return new Class[] { + Encloser.class, + int.class, + String.class + }; + } + + } + + return new LocalTester(2) { + public String message() { + return message; + } + }; + } + + public Tester makeAnonExtendsInner(final String message) { + return new InnerTester(2) { + protected String[] names() { + return new String[] { + "this$1", + "innerparam", + "val$message" + }; + } + + protected int[] modifiers() { + return new int[] { + Modifier.FINAL | MANDATED, + Modifier.FINAL, + Modifier.FINAL | SYNTHETIC + }; + } + + protected Class[] types() { + return new Class[] { + Encloser.class, + int.class, + String.class + }; + } + + public String message() { + return message; + } + }; + } + + public Tester makeAnon(final String message) { + return new Tester(2) { + protected String[] names() { + return new String[] { + "this$1", + "param", + "val$message" + }; + } + + protected int[] modifiers() { + return new int[] { + Modifier.FINAL | MANDATED, + Modifier.FINAL, + Modifier.FINAL | SYNTHETIC + }; + } + + protected Class[] types() { + return new Class[] { + Encloser.class, + int.class, + String.class + }; + } + + public String message() { + return message; + } + }; + } + } +} From 5d8a44e119b274e979d2398f593c848af3d28336 Mon Sep 17 00:00:00 2001 From: James Laskey Date: Thu, 22 Aug 2013 13:51:24 -0300 Subject: [PATCH 059/117] 8023228: Debugger information gather is too slow Reviewed-by: sundar, lagergren --- .../jdk/nashorn/internal/runtime/Context.java | 5 + .../internal/runtime/DebuggerSupport.java | 310 ++++++++++++++++++ 2 files changed, 315 insertions(+) create mode 100644 nashorn/src/jdk/nashorn/internal/runtime/DebuggerSupport.java diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 8834592a0b8..217080d0d3a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -91,6 +91,11 @@ public final class Context { */ public static final String NASHORN_JAVA_REFLECTION = "nashorn.JavaReflection"; + /* Force DebuggerSupport to be loaded. */ + static { + DebuggerSupport.FORCELOAD = true; + } + /** * ContextCodeInstaller that has the privilege of installing classes in the Context. * Can only be instantiated from inside the context and is opaque to other classes diff --git a/nashorn/src/jdk/nashorn/internal/runtime/DebuggerSupport.java b/nashorn/src/jdk/nashorn/internal/runtime/DebuggerSupport.java new file mode 100644 index 00000000000..e5017d7b247 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/runtime/DebuggerSupport.java @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2010, 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 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 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 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 jdk.nashorn.internal.runtime; + +import java.util.HashSet; +import java.util.Set; + +/** + * This class provides support for external debuggers. Its primary purpose is + * is to simplify the debugger tasks and provide better performance. + */ +final class DebuggerSupport { + /** + * Hook to force the loading of the DebuggerSupport class so that it is + * available to external debuggers. + */ + static boolean FORCELOAD = true; + + static { + /** + * Hook to force the loading of the DebuggerValueDesc class so that it is + * available to external debuggers. + */ + DebuggerValueDesc forceLoad = new DebuggerValueDesc(null, false, null, null); + } + + /** This class is used to send a bulk description of a value. */ + static class DebuggerValueDesc { + /** Property key (or index) or field name. */ + final String key; + + /** If the value is expandable. */ + final boolean expandable; + + /** Property or field value as object. */ + final Object valueAsObject; + + /** Property or field value as string. */ + final String valueAsString; + + DebuggerValueDesc(final String key, final boolean expandable, final Object valueAsObject, final String valueAsString) { + this.key = key; + this.expandable = expandable; + this.valueAsObject = valueAsObject; + this.valueAsString = valueAsString; + } + } + + /** + * Return the current context global. + * @return context global. + */ + static Object getGlobal() { + return Context.getGlobalTrusted(); + } + + /** + * This method returns a bulk description of an object's properties. + * @param object Script object to be displayed by the debugger. + * @param all true if to include non-enumerable values. + * @return An array of DebuggerValueDesc. + */ + static DebuggerValueDesc[] valueInfos(final Object object, final boolean all) { + assert object instanceof ScriptObject; + return getDebuggerValueDescs((ScriptObject)object, all, new HashSet<>()); + } + + /** + * This method returns a debugger description of the value. + * @param name Name of value (property name). + * @param value Data value. + * @param all true if to include non-enumerable values. + * @return A DebuggerValueDesc. + */ + static DebuggerValueDesc valueInfo(final String name, final Object value, final boolean all) { + return valueInfo(name, value, all, new HashSet<>()); + } + + /** + * This method returns a debugger description of the value. + * @param name Name of value (property name). + * @param value Data value. + * @param all true if to include non-enumerable values. + * @param duplicates Duplication set to avoid cycles. + * @return A DebuggerValueDesc. + */ + private static DebuggerValueDesc valueInfo(final String name, final Object value, final boolean all, final Set duplicates) { + if (value instanceof ScriptObject && !(value instanceof ScriptFunction)) { + final ScriptObject object = (ScriptObject)value; + return new DebuggerValueDesc(name, !object.isEmpty(), value, objectAsString(object, all, duplicates)); + } else { + return new DebuggerValueDesc(name, false, value, valueAsString(value)); + } + } + + /** + * Generate the descriptions for an object's properties. + * @param object Object to introspect. + * @param all true if to include non-enumerable values. + * @param duplicates Duplication set to avoid cycles. + * @return An array of DebuggerValueDesc. + */ + private static DebuggerValueDesc[] getDebuggerValueDescs(final ScriptObject object, final boolean all, final Set duplicates) { + if (duplicates.contains(object)) { + return null; + } + + duplicates.add(object); + + final String[] keys = object.getOwnKeys(all); + final DebuggerValueDesc[] descs = new DebuggerValueDesc[keys.length]; + + for (int i = 0; i < keys.length; i++) { + final String key = keys[i]; + descs[i] = valueInfo(key, object.get(key), true, duplicates); + } + + duplicates.remove(object); + + return descs; + } + + /** + * Generate a string representation of a Script object. + * @param object Script object to represent. + * @param all true if to include non-enumerable values. + * @param duplicates Duplication set to avoid cycles. + * @return String representation. + */ + private static String objectAsString(final ScriptObject object, final boolean all, final Set duplicates) { + final StringBuilder sb = new StringBuilder(); + + if (ScriptObject.isArray(object)) { + sb.append('['); + final long length = object.getLong("length"); + + for (long i = 0; i < length; i++) { + if (object.has(i)) { + final Object valueAsObject = object.get(i); + final boolean isUndefined = JSType.of(valueAsObject) == JSType.UNDEFINED; + + if (isUndefined) { + if (i != 0) { + sb.append(","); + } + } else { + if (i != 0) { + sb.append(", "); + } + + if (valueAsObject instanceof ScriptObject && !(valueAsObject instanceof ScriptFunction)) { + final String objectString = objectAsString((ScriptObject)valueAsObject, true, duplicates); + sb.append(objectString != null ? objectString : "{...}"); + } else { + sb.append(valueAsString(valueAsObject)); + } + } + } else { + if (i != 0) { + sb.append(','); + } + } + } + + sb.append(']'); + } else { + sb.append('{'); + final DebuggerValueDesc[] descs = getDebuggerValueDescs(object, all, duplicates); + + if (descs != null) { + for (int i = 0; i < descs.length; i++) { + if (i != 0) { + sb.append(", "); + } + + final String valueAsString = descs[i].valueAsString; + sb.append(descs[i].key); + sb.append(": "); + sb.append(descs[i].valueAsString); + } + } + + sb.append('}'); + } + + return sb.toString(); + } + + /** + * This method returns a string representation of a value. + * @param value Arbitrary value to be displayed by the debugger. + * @return A string representation of the value or an array of DebuggerValueDesc. + */ + private static String valueAsString(final Object value) { + final JSType type = JSType.of(value); + + switch (type) { + case BOOLEAN: + return value.toString(); + + case STRING: + return escape((String)value); + + case NUMBER: + return JSType.toString(((Number)value).doubleValue()); + + case NULL: + return "null"; + + case UNDEFINED: + return "undefined"; + + case OBJECT: + return ScriptRuntime.safeToString(value); + + case FUNCTION: + if (value instanceof ScriptFunction) { + return ((ScriptFunction)value).toSource(); + } else { + return value.toString(); + } + + default: + return value.toString(); + } + } + + /** + * Escape a string into a form that can be parsed by JavaScript. + * @param value String to be escaped. + * @return Escaped string. + */ + private static String escape(final String value) { + final StringBuilder sb = new StringBuilder(); + + sb.append("\""); + + for (final char ch : value.toCharArray()) { + switch (ch) { + case '\\': + sb.append("\\\\"); + break; + case '"': + sb.append("\\\""); + break; + case '\'': + sb.append("\\\'"); + break; + case '\b': + sb.append("\\b"); + break; + case '\f': + sb.append("\\f"); + break; + case '\n': + sb.append("\\n"); + break; + case '\r': + sb.append("\\r"); + break; + case '\t': + sb.append("\\t"); + break; + default: + if (ch < ' ' || ch >= 0xFF) { + sb.append("\\u"); + + final String hex = Integer.toHexString(ch); + for (int i = hex.length(); i < 4; i++) { + sb.append('0'); + } + sb.append(hex); + } else { + sb.append(ch); + } + + break; + } + } + + sb.append("\""); + + return sb.toString(); + } +} + + From 7b5f6c66a5cdc0ed4efb6e1e65c7ea41155314ec Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 22 Aug 2013 22:32:16 +0530 Subject: [PATCH 060/117] 8023560: Arbitrary javax.script.Bindings objects as ENGINE_SCOPE objects are not handled as expected Reviewed-by: jlaskey, lagergren, hannesw --- .../api/scripting/NashornScriptEngine.java | 57 ++++++++++++++++--- .../internal/runtime/ScriptEnvironment.java | 4 ++ .../runtime/resources/Options.properties | 8 +++ .../api/scripting/ScriptEngineTest.java | 47 +++++++++++++++ .../runtime/TrustedScriptEngineTest.java | 24 ++++++++ 5 files changed, 133 insertions(+), 7 deletions(-) diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index e3f09139e95..213b8890948 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -55,6 +55,7 @@ import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptException; +import javax.script.SimpleBindings; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ErrorManager; import jdk.nashorn.internal.runtime.GlobalObject; @@ -74,6 +75,11 @@ import jdk.nashorn.internal.runtime.options.Options; */ public final class NashornScriptEngine extends AbstractScriptEngine implements Compilable, Invocable { + /** + * Key used to associate Nashorn global object mirror with arbitrary Bindings instance. + */ + public static final String NASHORN_GLOBAL = "nashorn.global"; + private static AccessControlContext createPermAccCtxt(final String permName) { final Permissions perms = new Permissions(); perms.add(new RuntimePermission(permName)); @@ -85,6 +91,8 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C private final ScriptEngineFactory factory; private final Context nashornContext; + // do we want to share single Nashorn global instance across ENGINE_SCOPEs? + private final boolean _global_per_engine; private final ScriptObject global; // initialized bit late to be made 'final'. Property object for "context" // property of global object @@ -134,6 +142,9 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } }, CREATE_CONTEXT_ACC_CTXT); + // cache this option that is used often + this._global_per_engine = nashornContext.getEnv()._global_per_engine; + // create new global object this.global = createNashornGlobal(); // set the default engine scope for the default context @@ -176,8 +187,14 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C @Override public Bindings createBindings() { - final ScriptObject newGlobal = createNashornGlobal(); - return new ScriptObjectMirror(newGlobal, newGlobal); + if (_global_per_engine) { + // just create normal SimpleBindings. + // We use same 'global' for all Bindings. + return new SimpleBindings(); + } else { + final ScriptObject newGlobal = createNashornGlobal(); + return new ScriptObjectMirror(newGlobal, newGlobal); + } } // Compilable methods @@ -319,17 +336,43 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C } private ScriptObject getNashornGlobalFrom(final ScriptContext ctxt) { + if (_global_per_engine) { + // shared single global for all ENGINE_SCOPE Bindings + return global; + } + final Bindings bindings = ctxt.getBindings(ScriptContext.ENGINE_SCOPE); + // is this Nashorn's own Bindings implementation? if (bindings instanceof ScriptObjectMirror) { - final ScriptObjectMirror mirror = (ScriptObjectMirror)bindings; - ScriptObject sobj = ((ScriptObjectMirror)bindings).getScriptObject(); - if (sobj instanceof GlobalObject && sobj.isOfContext(nashornContext)) { + final ScriptObject sobj = globalFromMirror((ScriptObjectMirror)bindings); + if (sobj != null) { return sobj; } } - // didn't find global object from context given - return the engine-wide global - return global; + // Arbitrary user Bindings implementation. Look for NASHORN_GLOBAL in it! + Object scope = bindings.get(NASHORN_GLOBAL); + if (scope instanceof ScriptObjectMirror) { + final ScriptObject sobj = globalFromMirror((ScriptObjectMirror)scope); + if (sobj != null) { + return sobj; + } + } + + // We didn't find associated nashorn global mirror in the Bindings given! + // Create new global instance mirror and associate with the Bindings. + final ScriptObjectMirror mirror = (ScriptObjectMirror)createBindings(); + bindings.put(NASHORN_GLOBAL, mirror); + return mirror.getScriptObject(); + } + + private ScriptObject globalFromMirror(final ScriptObjectMirror mirror) { + ScriptObject sobj = mirror.getScriptObject(); + if (sobj instanceof GlobalObject && sobj.isOfContext(nashornContext)) { + return sobj; + } + + return null; } private ScriptObject createNashornGlobal() { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java index 8ab6af48ab1..5327471051a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java @@ -86,6 +86,9 @@ public final class ScriptEnvironment { /** Launch using as fx application */ public final boolean _fx; + /** Use single Global instance per jsr223 engine instance. */ + public final boolean _global_per_engine; + /** * Behavior when encountering a function declaration in a lexical context where only statements are acceptable * (function declarations are source elements, but not statements). @@ -208,6 +211,7 @@ public final class ScriptEnvironment { _function_statement = FunctionStatementBehavior.ACCEPT; } _fx = options.getBoolean("fx"); + _global_per_engine = options.getBoolean("global.per.engine"); _lazy_compilation = options.getBoolean("lazy.compilation"); _loader_per_compile = options.getBoolean("loader.per.compile"); _no_java = options.getBoolean("no.java"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties index e3510fa1004..508759f92f1 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Options.properties @@ -157,6 +157,14 @@ nashorn.option.fx = { \ default=false \ } +nashorn.option.global.per.engine = { \ + name="--global-per-engine", \ + desc="Use single Global instance per script engine instance.", \ + is_undocumented=true, \ + type=Boolean, \ + default=false \ +} + nashorn.option.log = { \ name="--log", \ is_undocumented=true, \ diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index 3cad7095517..b21b2414f84 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -47,6 +47,7 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; import javax.script.ScriptException; +import javax.script.SimpleBindings; import javax.script.SimpleScriptContext; import org.testng.Assert; import org.testng.annotations.Test; @@ -1282,4 +1283,50 @@ public class ScriptEngineTest { final Object newObj = ((ScriptObjectMirror)e2obj).newObject("foo"); assertTrue(newObj instanceof ScriptObjectMirror); } + + @Test + public void userEngineScopeBindingsTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + e.eval("function func() {}"); + + final ScriptContext newContext = new SimpleScriptContext(); + newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE); + // we are using a new bindings - so it should have 'func' defined + Object value = e.eval("typeof func", newContext); + assertTrue(value.equals("undefined")); + } + + @Test + public void userEngineScopeBindingsNoLeakTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final ScriptContext newContext = new SimpleScriptContext(); + newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE); + e.eval("function foo() {}", newContext); + + // in the default context's ENGINE_SCOPE, 'foo' shouldn't exist + assertTrue(e.eval("typeof foo").equals("undefined")); + } + + @Test + public void userEngineScopeBindingsRetentionTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final ScriptContext newContext = new SimpleScriptContext(); + newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE); + e.eval("function foo() {}", newContext); + + // definition retained with user's ENGINE_SCOPE Binding + assertTrue(e.eval("typeof foo", newContext).equals("function")); + + final Bindings oldBindings = newContext.getBindings(ScriptContext.ENGINE_SCOPE); + // but not in another ENGINE_SCOPE binding + newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE); + assertTrue(e.eval("typeof foo", newContext).equals("undefined")); + + // restore ENGINE_SCOPE and check again + newContext.setBindings(oldBindings, ScriptContext.ENGINE_SCOPE); + assertTrue(e.eval("typeof foo", newContext).equals("function")); + } } diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java index f7f7c6ae298..469d890ebd5 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java @@ -32,7 +32,10 @@ import static org.testng.Assert.fail; import javax.script.ScriptEngine; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; +import javax.script.ScriptContext; import javax.script.ScriptException; +import javax.script.SimpleBindings; +import javax.script.SimpleScriptContext; import jdk.nashorn.api.scripting.NashornScriptEngineFactory; import org.testng.annotations.Test; @@ -196,4 +199,25 @@ public class TrustedScriptEngineTest { } fail("Cannot find nashorn factory!"); } + + @Test + public void globalPerEngineTest() throws ScriptException { + final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); + final String[] options = new String[] { "--global-per-engine" }; + final ScriptEngine e = fac.getScriptEngine(options); + + e.eval("function foo() {}"); + + final ScriptContext newCtx = new SimpleScriptContext(); + newCtx.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE); + + // all global definitions shared and so 'foo' should be + // visible in new Bindings as well. + assertTrue(e.eval("typeof foo", newCtx).equals("function")); + + e.eval("function bar() {}", newCtx); + + // bar should be visible in default context + assertTrue(e.eval("typeof bar").equals("function")); + } } From f61c7dc88b26e52426264783dfdc63e097b60657 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 22 Aug 2013 10:20:50 -0700 Subject: [PATCH 061/117] 8023406: make/windows/build_vm_def.sh takes too long even when BUILD_WIN_SA != 1 Avoid dumping C++ vtable when BUILD_WIN_SA != 1 Reviewed-by: dcubed, sla, tbell --- hotspot/make/windows/build_vm_def.sh | 18 ++++++++++++++++-- hotspot/make/windows/makefiles/debug.make | 3 --- hotspot/make/windows/makefiles/fastdebug.make | 3 --- hotspot/make/windows/makefiles/product.make | 3 --- .../make/windows/makefiles/projectcreator.make | 6 +++++- hotspot/make/windows/makefiles/vm.make | 8 ++++++++ 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/hotspot/make/windows/build_vm_def.sh b/hotspot/make/windows/build_vm_def.sh index c54a1803b93..fa82d26a81a 100644 --- a/hotspot/make/windows/build_vm_def.sh +++ b/hotspot/make/windows/build_vm_def.sh @@ -42,8 +42,6 @@ else MKS_HOME=`dirname "$SH"` fi -echo "EXPORTS" > vm1.def - AWK="$MKS_HOME/awk.exe" if [ ! -e $AWK ]; then AWK="$MKS_HOME/gawk.exe" @@ -55,6 +53,22 @@ CAT="$MKS_HOME/cat.exe" RM="$MKS_HOME/rm.exe" DUMPBIN="link.exe /dump" +if [ "$1" = "-nosa" ]; then + echo EXPORTS > vm.def + echo "" + echo "***" + echo "*** Not building SA: BUILD_WIN_SA != 1" + echo "*** C++ Vtables NOT included in vm.def" + echo "*** This jvm.dll will NOT work properly with SA." + echo "***" + echo "*** When in doubt, set BUILD_WIN_SA=1, clean and rebuild." + echo "***" + echo "" + exit +fi + +echo "EXPORTS" > vm1.def + # When called from IDE the first param should contain the link version, otherwise may be nill if [ "x$1" != "x" ]; then LD_VER="$1" diff --git a/hotspot/make/windows/makefiles/debug.make b/hotspot/make/windows/makefiles/debug.make index 2fca2182841..14a07083434 100644 --- a/hotspot/make/windows/makefiles/debug.make +++ b/hotspot/make/windows/makefiles/debug.make @@ -49,9 +49,6 @@ HS_BUILD_ID=$(HS_BUILD_VER)-debug # Force resources to be rebuilt every time $(Res_Files): FORCE -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh - $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) diff --git a/hotspot/make/windows/makefiles/fastdebug.make b/hotspot/make/windows/makefiles/fastdebug.make index cde98f214ea..a85e129cf6e 100644 --- a/hotspot/make/windows/makefiles/fastdebug.make +++ b/hotspot/make/windows/makefiles/fastdebug.make @@ -48,9 +48,6 @@ HS_BUILD_ID=$(HS_BUILD_VER)-fastdebug # Force resources to be rebuilt every time $(Res_Files): FORCE -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh - $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) diff --git a/hotspot/make/windows/makefiles/product.make b/hotspot/make/windows/makefiles/product.make index 407484cd46e..713ec0e54ca 100644 --- a/hotspot/make/windows/makefiles/product.make +++ b/hotspot/make/windows/makefiles/product.make @@ -51,9 +51,6 @@ HS_BUILD_ID=$(HS_BUILD_VER) # Force resources to be rebuilt every time $(Res_Files): FORCE -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh - $(AOUT): $(Res_Files) $(Obj_Files) vm.def $(LD) @<< $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) diff --git a/hotspot/make/windows/makefiles/projectcreator.make b/hotspot/make/windows/makefiles/projectcreator.make index a5336c6bf51..d512796f8fe 100644 --- a/hotspot/make/windows/makefiles/projectcreator.make +++ b/hotspot/make/windows/makefiles/projectcreator.make @@ -92,6 +92,10 @@ ProjectCreatorIDEOptions = \ -disablePch getThread_windows_$(Platform_arch).cpp \ -disablePch_compiler2 opcodes.cpp +!if "$(BUILD_WIN_SA)" != "1" +BUILD_VM_DEF_FLAG=-nosa +!endif + # Common options for the IDE builds for c1, and c2 ProjectCreatorIDEOptions=\ $(ProjectCreatorIDEOptions) \ @@ -104,7 +108,7 @@ ProjectCreatorIDEOptions=\ -jdkTargetRoot $(HOTSPOTJDKDIST) \ -define ALIGN_STACK_FRAMES \ -define VM_LITTLE_ENDIAN \ - -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \ + -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(BUILD_VM_DEF_FLAG) $(LD_VER)" \ -ignoreFile jsig.c \ -ignoreFile jvmtiEnvRecommended.cpp \ -ignoreFile jvmtiEnvStub.cpp \ diff --git a/hotspot/make/windows/makefiles/vm.make b/hotspot/make/windows/makefiles/vm.make index 8b5e23d4a28..229be6870a7 100644 --- a/hotspot/make/windows/makefiles/vm.make +++ b/hotspot/make/windows/makefiles/vm.make @@ -393,3 +393,11 @@ default:: _build_pch_file.obj: @echo #include "precompiled.hpp" > ../generated/_build_pch_file.cpp $(CXX) $(CXX_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp + +!if "$(BUILD_WIN_SA)" != "1" +BUILD_VM_DEF_FLAG=-nosa +!endif + +vm.def: $(Obj_Files) + sh $(WorkSpace)/make/windows/build_vm_def.sh $(BUILD_VM_DEF_FLAG) + From 32a617d198df607b011264664622af777d831308 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 22 Aug 2013 12:41:20 -0700 Subject: [PATCH 062/117] 8022173: Relax some warnings in doclint Reviewed-by: darcy --- .../classes/com/sun/tools/doclint/HtmlTag.java | 13 ++++++++----- langtools/test/tools/doclint/html/ListTagsTest.java | 3 ++- .../test/tools/doclint/html/OtherTagsTest.java | 3 ++- langtools/test/tools/doclint/html/OtherTagsTest.out | 10 +++++----- .../test/tools/doclint/html/TableTagsTest.java | 3 ++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java index f1bce7d6795..3b8f8599e09 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java +++ b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java @@ -42,12 +42,14 @@ import static com.sun.tools.doclint.HtmlTag.Attr.*; * * The intent of this class is to embody the semantics of W3C HTML 4.01 * to the extent supported/used by javadoc. + * In time, we may wish to transition javadoc and doclint to using HTML 5. * * This is derivative of com.sun.tools.doclets.formats.html.markup.HtmlTag. * Eventually, these two should be merged back together, and possibly made * public. * * @see HTML 4.01 Specification + * @see HTML 5 Specification * @author Bhavesh Patel * @author Jonathan Gibbons (revised) */ @@ -119,7 +121,8 @@ public enum HtmlTag { HEAD(BlockType.OTHER, EndKind.REQUIRED), - HR(BlockType.BLOCK, EndKind.NONE), + HR(BlockType.BLOCK, EndKind.NONE, + attrs(AttrKind.OK, WIDTH)), // OK in 4.01; not allowed in 5 HTML(BlockType.OTHER, EndKind.REQUIRED), @@ -152,7 +155,7 @@ public enum HtmlTag { OL(BlockType.BLOCK, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT), - attrs(AttrKind.USE_CSS, START, TYPE)){ + attrs(AttrKind.OK, START, TYPE)) { @Override public boolean accepts(HtmlTag t) { return (t == LI); @@ -196,8 +199,8 @@ public enum HtmlTag { TABLE(BlockType.BLOCK, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT), attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER, - CELLPADDING, CELLSPACING), - attrs(AttrKind.USE_CSS, ALIGN, WIDTH, BGCOLOR)) { + CELLPADDING, CELLSPACING, WIDTH), // width OK in 4.01; not allowed in 5 + attrs(AttrKind.USE_CSS, ALIGN, BGCOLOR)) { @Override public boolean accepts(HtmlTag t) { switch (t) { @@ -267,7 +270,7 @@ public enum HtmlTag { UL(BlockType.BLOCK, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT), - attrs(AttrKind.USE_CSS, COMPACT, TYPE)){ + attrs(AttrKind.OK, COMPACT, TYPE)) { // OK in 4.01; not allowed in 5 @Override public boolean accepts(HtmlTag t) { return (t == LI); diff --git a/langtools/test/tools/doclint/html/ListTagsTest.java b/langtools/test/tools/doclint/html/ListTagsTest.java index 571c8f9e6f6..1d55bfd2cbf 100644 --- a/langtools/test/tools/doclint/html/ListTagsTest.java +++ b/langtools/test/tools/doclint/html/ListTagsTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8006251 8013405 + * @bug 8006251 8013405 8022173 * @summary test list tags * @library .. * @build DocLintTester @@ -15,6 +15,7 @@ public class ListTagsTest { *
  1. abc
*
  1. bad
*
  1. bad
+ *
  1. bad
*
  • abc
*/ public void supportedTags() { } diff --git a/langtools/test/tools/doclint/html/OtherTagsTest.java b/langtools/test/tools/doclint/html/OtherTagsTest.java index ce6af8246c7..df72dac05fd 100644 --- a/langtools/test/tools/doclint/html/OtherTagsTest.java +++ b/langtools/test/tools/doclint/html/OtherTagsTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8006251 + * @bug 8006251 8022173 * @summary test other tags * @library .. * @build DocLintTester @@ -14,6 +14,7 @@ public class OtherTagsTest { * * * + *
* * * diff --git a/langtools/test/tools/doclint/html/OtherTagsTest.out b/langtools/test/tools/doclint/html/OtherTagsTest.out index 0ead88e77a5..3fbcb15781c 100644 --- a/langtools/test/tools/doclint/html/OtherTagsTest.out +++ b/langtools/test/tools/doclint/html/OtherTagsTest.out @@ -10,19 +10,19 @@ OtherTagsTest.java:15: error: element not allowed in documentation comments: * ^ -OtherTagsTest.java:17: error: element not allowed in documentation comments: +OtherTagsTest.java:18: error: element not allowed in documentation comments: * ^ -OtherTagsTest.java:18: error: element not allowed in documentation comments: +OtherTagsTest.java:19: error: element not allowed in documentation comments: * ^ -OtherTagsTest.java:19: error: element not allowed in documentation comments: +OtherTagsTest.java:20: error: element not allowed in documentation comments: <noframes> * <noframes> ^ -OtherTagsTest.java:20: error: element not allowed in documentation comments: ^ -OtherTagsTest.java:21: error: element not allowed in documentation comments: +OtherTagsTest.java:22: error: element not allowed in documentation comments: <title> * <title> ^ 9 errors diff --git a/langtools/test/tools/doclint/html/TableTagsTest.java b/langtools/test/tools/doclint/html/TableTagsTest.java index 7cea1b35f9d..c5cb2e54290 100644 --- a/langtools/test/tools/doclint/html/TableTagsTest.java +++ b/langtools/test/tools/doclint/html/TableTagsTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8006251 + * @bug 8006251 8022173 * @summary test table tags * @library .. * @build DocLintTester @@ -39,6 +39,7 @@ public class TableTagsTest { *
*
*
+ *
*/ public void supportedTags() { } } From 5c6c0a8d1dc5e47897094766190ebe5d8f3e5d14 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Thu, 22 Aug 2013 19:27:42 -0400 Subject: [PATCH 063/117] 8023547: com/sun/jdi/RedefineMulti.sh fails with IllegalArgumentException after JDK-8021948 Need to check if the constant pool mapping returns 0. Reviewed-by: coleenp, sspitsyn --- .../src/share/vm/prims/jvmtiRedefineClasses.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index dd1553af46c..803cf9a7545 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -1554,18 +1554,22 @@ bool VM_RedefineClasses::rewrite_cp_refs(instanceKlassHandle scratch_class, return false; } - // rewrite sourc file name index: + // rewrite source file name index: u2 source_file_name_idx = scratch_class->source_file_name_index(); if (source_file_name_idx != 0) { u2 new_source_file_name_idx = find_new_index(source_file_name_idx); - scratch_class->set_source_file_name_index(new_source_file_name_idx); + if (new_source_file_name_idx != 0) { + scratch_class->set_source_file_name_index(new_source_file_name_idx); + } } // rewrite class generic signature index: u2 generic_signature_index = scratch_class->generic_signature_index(); if (generic_signature_index != 0) { u2 new_generic_signature_index = find_new_index(generic_signature_index); - scratch_class->set_generic_signature_index(new_generic_signature_index); + if (new_generic_signature_index != 0) { + scratch_class->set_generic_signature_index(new_generic_signature_index); + } } return true; @@ -1737,7 +1741,10 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method, for (int i = 0; i < len; i++) { const u2 cp_index = elem[i].name_cp_index; - elem[i].name_cp_index = find_new_index(cp_index); + const u2 new_cp_index = find_new_index(cp_index); + if (new_cp_index != 0) { + elem[i].name_cp_index = new_cp_index; + } } } } // end rewrite_cp_refs_in_method() From ea17b8decf3f892b7d15750ef466e162abb717d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Fri, 23 Aug 2013 10:36:34 +0200 Subject: [PATCH 064/117] 8023457: Event based tracing framework needs a mutex for thread groups Reviewed-by: acorn, sla --- hotspot/src/share/vm/runtime/mutexLocker.cpp | 16 +++++++++++----- hotspot/src/share/vm/runtime/mutexLocker.hpp | 8 +++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/runtime/mutexLocker.cpp b/hotspot/src/share/vm/runtime/mutexLocker.cpp index 14e65081d62..f513b7b376c 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.cpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp @@ -124,13 +124,15 @@ Monitor* GCTaskManager_lock = NULL; Mutex* Management_lock = NULL; Monitor* Service_lock = NULL; -Mutex* Stacktrace_lock = NULL; +Monitor* PeriodicTask_lock = NULL; -Monitor* JfrQuery_lock = NULL; +#ifdef INCLUDE_TRACE +Mutex* JfrStacktrace_lock = NULL; Monitor* JfrMsg_lock = NULL; Mutex* JfrBuffer_lock = NULL; Mutex* JfrStream_lock = NULL; -Monitor* PeriodicTask_lock = NULL; +Mutex* JfrThreadGroups_lock = NULL; +#endif #define MAX_NUM_MUTEX 128 static Monitor * _mutex_array[MAX_NUM_MUTEX]; @@ -206,7 +208,6 @@ void mutex_init() { 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 @@ -272,11 +273,16 @@ void mutex_init() { def(Debug3_lock , Mutex , nonleaf+4, true ); def(ProfileVM_lock , Monitor, special, false); // used for profiling of the VMThread def(CompileThread_lock , Monitor, nonleaf+5, false ); + def(PeriodicTask_lock , Monitor, nonleaf+5, true); +#ifdef INCLUDE_TRACE def(JfrMsg_lock , Monitor, leaf, true); def(JfrBuffer_lock , Mutex, nonleaf+1, true); + def(JfrThreadGroups_lock , Mutex, nonleaf+1, true); def(JfrStream_lock , Mutex, nonleaf+2, true); - def(PeriodicTask_lock , Monitor, nonleaf+5, true); + def(JfrStacktrace_lock , Mutex, special, true ); +#endif + } GCMutexLocker::GCMutexLocker(Monitor * mutex) { diff --git a/hotspot/src/share/vm/runtime/mutexLocker.hpp b/hotspot/src/share/vm/runtime/mutexLocker.hpp index 7a2e240bd4f..d98b8d890fd 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.hpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.hpp @@ -137,13 +137,15 @@ extern Mutex* HotCardCache_lock; // protects the hot card cache 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 -extern Monitor* JfrQuery_lock; // protects JFR use +#ifdef INCLUDE_TRACE +extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table extern Monitor* JfrMsg_lock; // protects JFR messaging extern Mutex* JfrBuffer_lock; // protects JFR buffer operations extern Mutex* JfrStream_lock; // protects JFR stream access -extern Monitor* PeriodicTask_lock; // protects the periodic task structure +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 From e8f5679bc5d4eb1ea82bd51e664d1aa75a92100d Mon Sep 17 00:00:00 2001 From: Miroslav Kos Date: Fri, 23 Aug 2013 09:57:21 +0100 Subject: [PATCH 065/117] 8022885: Update JAX-WS RI integration to 2.2.9-b14140 8013016: Rebase 8009009 against the latest jdk8/jaxws Reviewed-by: alanb, chegar --- .../tools/ParallelWorldClassLoader.java | 3 +- .../probe/provider/annotations/Probe.java | 7 +- .../impl/AverageRangeStatisticImpl.java | 6 +- .../impl/BoundaryStatisticImpl.java | 6 +- .../impl/BoundedRangeStatisticImpl.java | 7 +- .../statistics/impl/CountStatisticImpl.java | 6 +- .../statistics/impl/RangeStatisticImpl.java | 6 +- .../statistics/impl/StatisticImpl.java | 15 +- .../statistics/impl/StringStatisticImpl.java | 5 +- .../statistics/impl/TimeStatisticImpl.java | 6 +- .../internal/jxc/MessageBundle.properties | 4 +- .../internal/jxc/MessageBundle_de.properties | 4 +- .../internal/jxc/MessageBundle_es.properties | 4 +- .../internal/jxc/MessageBundle_fr.properties | 4 +- .../internal/jxc/MessageBundle_it.properties | 4 +- .../internal/jxc/MessageBundle_ja.properties | 4 +- .../internal/jxc/MessageBundle_ko.properties | 4 +- .../jxc/MessageBundle_pt_BR.properties | 4 +- .../jxc/MessageBundle_zh_CN.properties | 4 +- .../jxc/MessageBundle_zh_TW.properties | 4 +- .../jxc/gen/config/AttributesImpl.java | 3 + .../internal/jxc/gen/config/Classes.java | 148 +- .../tools/internal/jxc/gen/config/Config.java | 80 +- .../jxc/gen/config/NGCCEventReceiver.java | 4 +- .../jxc/gen/config/NGCCEventSource.java | 4 +- .../internal/jxc/gen/config/NGCCHandler.java | 4 +- .../jxc/gen/config/NGCCInterleaveFilter.java | 3 + .../internal/jxc/gen/config/NGCCRuntime.java | 4 +- .../tools/internal/jxc/gen/config/Schema.java | 152 +- .../sun/tools/internal/ws/version.properties | 8 +- .../internal/xjc/MessageBundle.properties | 12 +- .../internal/xjc/MessageBundle_de.properties | 12 +- .../internal/xjc/MessageBundle_es.properties | 12 +- .../internal/xjc/MessageBundle_fr.properties | 12 +- .../internal/xjc/MessageBundle_it.properties | 12 +- .../internal/xjc/MessageBundle_ja.properties | 12 +- .../internal/xjc/MessageBundle_ko.properties | 12 +- .../xjc/MessageBundle_pt_BR.properties | 12 +- .../xjc/MessageBundle_zh_CN.properties | 12 +- .../xjc/MessageBundle_zh_TW.properties | 12 +- .../sun/tools/internal/xjc/SchemaCache.java | 6 +- .../spec/XmlAccessorOrderWriter.java | 5 + .../spec/XmlAccessorTypeWriter.java | 5 + .../spec/XmlAnyAttributeWriter.java | 5 + .../annotation/spec/XmlAnyElementWriter.java | 5 + .../spec/XmlAttachmentRefWriter.java | 5 + .../annotation/spec/XmlAttributeWriter.java | 5 + .../annotation/spec/XmlElementDeclWriter.java | 5 + .../annotation/spec/XmlElementRefWriter.java | 5 + .../annotation/spec/XmlElementRefsWriter.java | 5 + .../spec/XmlElementWrapperWriter.java | 5 + .../annotation/spec/XmlElementWriter.java | 5 + .../annotation/spec/XmlElementsWriter.java | 5 + .../annotation/spec/XmlEnumValueWriter.java | 5 + .../annotation/spec/XmlEnumWriter.java | 5 + .../annotation/spec/XmlIDREFWriter.java | 5 + .../annotation/spec/XmlIDWriter.java | 5 + .../spec/XmlInlineBinaryDataWriter.java | 5 + .../spec/XmlJavaTypeAdapterWriter.java | 5 + .../annotation/spec/XmlListWriter.java | 5 + .../annotation/spec/XmlMimeTypeWriter.java | 5 + .../annotation/spec/XmlMixedWriter.java | 5 + .../annotation/spec/XmlNsWriter.java | 5 + .../annotation/spec/XmlRegistryWriter.java | 5 + .../annotation/spec/XmlRootElementWriter.java | 5 + .../annotation/spec/XmlSchemaTypeWriter.java | 5 + .../annotation/spec/XmlSchemaTypesWriter.java | 5 + .../annotation/spec/XmlSchemaWriter.java | 5 + .../annotation/spec/XmlSeeAlsoWriter.java | 5 + .../annotation/spec/XmlTransientWriter.java | 5 + .../annotation/spec/XmlTypeWriter.java | 5 + .../annotation/spec/XmlValueWriter.java | 5 + .../generator/bean/MessageBundle.properties | 2 +- .../internal/xjc/model/CPropertyInfo.java | 3 +- .../tools/internal/xjc/model/CTypeRef.java | 35 +- .../internal/xjc/model/package-info.java | 6 +- .../AbstractReferenceFinderImpl.java | 49 +- .../xjc/reader/internalizer/DOMForest.java | 53 +- .../com/sun/xml/internal/bind/Util.java | 2 +- .../sun/xml/internal/bind/v2/Messages.java | 4 +- .../xml/internal/bind/v2/Messages.properties | 8 +- .../bind/v2/model/annotation/Init.java | 5 +- .../model/annotation/XmlAttributeQuick.java | 5 + .../model/annotation/XmlElementDeclQuick.java | 5 + .../v2/model/annotation/XmlElementQuick.java | 5 + .../model/annotation/XmlElementRefQuick.java | 5 + .../model/annotation/XmlElementRefsQuick.java | 5 + .../v2/model/annotation/XmlEnumQuick.java | 5 + .../model/annotation/XmlRootElementQuick.java | 5 + .../v2/model/annotation/XmlSchemaQuick.java | 5 + .../model/annotation/XmlSchemaTypeQuick.java | 5 + .../model/annotation/XmlTransientQuick.java | 5 + .../v2/model/annotation/XmlTypeQuick.java | 5 + .../v2/model/annotation/XmlValueQuick.java | 5 + .../bind/v2/model/core/package-info.java | 6 +- .../impl/RuntimeBuiltinLeafInfoImpl.java | 15 +- .../xml/internal/bind/v2/package-info.java | 4 - .../bind/v2/runtime/BridgeAdapter.java | 4 - .../internal/bind/v2/runtime/Coordinator.java | 69 +- .../bind/v2/runtime/XMLSerializer.java | 2 - .../reflect/PrimitiveArrayListerBoolean.java | 9 +- .../PrimitiveArrayListerCharacter.java | 9 +- .../reflect/PrimitiveArrayListerDouble.java | 9 +- .../reflect/PrimitiveArrayListerFloat.java | 9 +- .../reflect/PrimitiveArrayListerInteger.java | 9 +- .../reflect/PrimitiveArrayListerLong.java | 9 +- .../reflect/PrimitiveArrayListerShort.java | 9 +- .../reflect/opt/FieldAccessor_Boolean.java | 8 +- .../reflect/opt/FieldAccessor_Character.java | 8 +- .../reflect/opt/FieldAccessor_Double.java | 8 +- .../reflect/opt/FieldAccessor_Float.java | 8 +- .../reflect/opt/FieldAccessor_Integer.java | 8 +- .../reflect/opt/FieldAccessor_Long.java | 8 +- .../reflect/opt/FieldAccessor_Short.java | 8 +- .../reflect/opt/MethodAccessor_Boolean.java | 8 +- .../reflect/opt/MethodAccessor_Character.java | 8 +- .../reflect/opt/MethodAccessor_Double.java | 8 +- .../reflect/opt/MethodAccessor_Float.java | 8 +- .../reflect/opt/MethodAccessor_Integer.java | 8 +- .../reflect/opt/MethodAccessor_Long.java | 8 +- .../reflect/opt/MethodAccessor_Short.java | 8 +- .../opt/TransducedAccessor_field_Double.java | 8 +- .../opt/TransducedAccessor_field_Float.java | 8 +- .../opt/TransducedAccessor_field_Long.java | 8 +- .../opt/TransducedAccessor_field_Short.java | 8 +- .../TransducedAccessor_method_Boolean.java | 8 +- .../opt/TransducedAccessor_method_Double.java | 8 +- .../opt/TransducedAccessor_method_Float.java | 8 +- .../opt/TransducedAccessor_method_Long.java | 8 +- .../opt/TransducedAccessor_method_Short.java | 8 +- .../bind/v2/runtime/unmarshaller/Loader.java | 8 +- .../v2/runtime/unmarshaller/Messages.java | 1 + .../runtime/unmarshaller/Messages.properties | 4 + .../v2/runtime/unmarshaller/SAXConnector.java | 44 +- .../unmarshaller/UnmarshallingContext.java | 79 +- .../runtime/unmarshaller/XsiTypeLoader.java | 15 +- .../v2/schemagen/xmlschema/Annotated.java | 5 + .../v2/schemagen/xmlschema/Annotation.java | 5 + .../bind/v2/schemagen/xmlschema/Any.java | 5 + .../bind/v2/schemagen/xmlschema/Appinfo.java | 5 + .../v2/schemagen/xmlschema/AttrDecls.java | 5 + .../v2/schemagen/xmlschema/AttributeType.java | 5 + .../schemagen/xmlschema/ComplexContent.java | 5 + .../schemagen/xmlschema/ComplexExtension.java | 5 + .../xmlschema/ComplexRestriction.java | 5 + .../v2/schemagen/xmlschema/ComplexType.java | 15 +- .../schemagen/xmlschema/ComplexTypeHost.java | 5 + .../schemagen/xmlschema/ComplexTypeModel.java | 5 + .../v2/schemagen/xmlschema/Documentation.java | 5 + .../bind/v2/schemagen/xmlschema/Element.java | 9 +- .../v2/schemagen/xmlschema/ExplicitGroup.java | 5 + .../v2/schemagen/xmlschema/ExtensionType.java | 5 + .../schemagen/xmlschema/FixedOrDefault.java | 5 + .../bind/v2/schemagen/xmlschema/Import.java | 5 + .../bind/v2/schemagen/xmlschema/List.java | 5 + .../schemagen/xmlschema/LocalAttribute.java | 5 + .../v2/schemagen/xmlschema/LocalElement.java | 5 + .../schemagen/xmlschema/NestedParticle.java | 5 + .../v2/schemagen/xmlschema/NoFixedFacet.java | 5 + .../bind/v2/schemagen/xmlschema/Occurs.java | 11 +- .../v2/schemagen/xmlschema/Redefinable.java | 5 + .../bind/v2/schemagen/xmlschema/Schema.java | 13 +- .../v2/schemagen/xmlschema/SchemaTop.java | 5 + .../v2/schemagen/xmlschema/SimpleContent.java | 5 + .../schemagen/xmlschema/SimpleDerivation.java | 5 + .../schemagen/xmlschema/SimpleExtension.java | 5 + .../xmlschema/SimpleRestriction.java | 5 + .../xmlschema/SimpleRestrictionModel.java | 5 + .../v2/schemagen/xmlschema/SimpleType.java | 5 + .../schemagen/xmlschema/SimpleTypeHost.java | 5 + .../xmlschema/TopLevelAttribute.java | 5 + .../schemagen/xmlschema/TopLevelElement.java | 9 +- .../schemagen/xmlschema/TypeDefParticle.java | 5 + .../bind/v2/schemagen/xmlschema/TypeHost.java | 5 + .../bind/v2/schemagen/xmlschema/Union.java | 5 + .../bind/v2/schemagen/xmlschema/Wildcard.java | 5 + .../internal/bind/v2/util/EditDistance.java | 22 +- .../xml/internal/bind/v2/util/XmlFactory.java | 25 +- .../internal/dtdparser/DTDEventListener.java | 2 +- .../internal/dtdparser/DTDHandlerBase.java | 2 +- .../sun/xml/internal/dtdparser/DTDParser.java | 18 +- .../dtdparser/EndOfInputException.java | 2 +- .../xml/internal/dtdparser/EntityDecl.java | 2 +- .../internal/dtdparser/ExternalEntity.java | 2 +- .../xml/internal/dtdparser/InputEntity.java | 2 +- .../internal/dtdparser/InternalEntity.java | 2 +- .../internal/dtdparser/MessageCatalog.java | 2 +- .../sun/xml/internal/dtdparser/Resolver.java | 2 +- .../internal/dtdparser/SimpleHashtable.java | 2 +- .../sun/xml/internal/dtdparser/XmlChars.java | 2 +- .../sun/xml/internal/dtdparser/XmlNames.java | 2 +- .../sun/xml/internal/dtdparser/XmlReader.java | 6 +- .../sun/xml/internal/dtdparser/package.html | 2 +- .../dtdparser/resources/Messages.properties | 2 +- .../buffer/AbstractCreatorProcessor.java | 3 +- .../stream/buffer/AbstractProcessor.java | 2 +- .../stream/buffer/AttributesHolder.java | 22 +- .../stream/buffer/FragmentedArray.java | 10 +- .../stream/buffer/MutableXMLStreamBuffer.java | 2 +- .../stream/buffer/XMLStreamBuffer.java | 2 +- .../buffer/XMLStreamBufferException.java | 2 +- .../stream/buffer/XMLStreamBufferMark.java | 2 +- .../stream/buffer/XMLStreamBufferResult.java | 2 +- .../stream/buffer/XMLStreamBufferSource.java | 2 +- .../buffer/sax/DefaultWithLexicalHandler.java | 2 +- .../internal/stream/buffer/sax/Features.java | 2 +- .../stream/buffer/sax/Properties.java | 2 +- .../stream/buffer/sax/SAXBufferCreator.java | 2 +- .../buffer/stax/StreamBufferCreator.java | 2 +- .../stax/StreamReaderBufferCreator.java | 5 +- .../stax/StreamReaderBufferProcessor.java | 2 +- .../stax/StreamWriterBufferCreator.java | 2 +- .../xml/internal/txw2/output/XMLWriter.java | 2 +- .../xml/internal/ws/api/message/Packet.java | 3 + .../xml/internal/ws/api/server/Container.java | 4 +- .../server/ThreadLocalContainerResolver.java | 12 +- .../api/streaming/XMLStreamReaderFactory.java | 189 +- .../wsdl/writer/WSDLGeneratorExtension.java | 4 +- .../ws/commons/xmlutil/Converter.java | 21 +- .../xml/internal/ws/encoding/MtomCodec.java | 40 +- .../ws/encoding/StreamSOAP11Codec.java | 6 - .../ws/encoding/StreamSOAP12Codec.java | 6 - .../internal/ws/encoding/StreamSOAPCodec.java | 110 +- .../xml/internal/ws/encoding/TagInfoset.java | 35 +- .../ws/message/AbstractMessageImpl.java | 42 +- .../internal/ws/message/jaxb/JAXBHeader.java | 17 +- .../internal/ws/message/jaxb/JAXBMessage.java | 79 +- .../internal/ws/message/saaj/SAAJMessage.java | 96 +- .../ws/message/stream/StreamMessage.java | 250 +- .../ws/resources/StreamingMessages.java | 36 + .../ws/resources/streaming.properties | 7 +- .../internal/ws/server/SDDocumentImpl.java | 4 +- .../internal/ws/spi/db/BindingContext.java | 32 +- .../pipe/AbstractSchemaValidationTube.java | 6 +- .../ws/util/resources/Messages_en.properties | 2 +- .../xml/internal/ws/util/version.properties | 8 +- .../sun/xml/internal/ws/util/xml/XmlUtil.java | 22 + .../ws/wsdl/writer/WSDLGenerator.java | 2 +- .../internal/xsom/impl/parser/Messages.java | 8 +- .../xsom/impl/parser/Messages.properties | 8 +- .../impl/parser/SAXParserFactoryAdaptor.java | 6 +- .../xsom/impl/parser/state/Schema.java | 1378 +++++------ .../impl/parser/state/SimpleType_List.java | 192 +- .../parser/state/SimpleType_Restriction.java | 292 +-- .../impl/parser/state/SimpleType_Union.java | 166 +- .../xsom/impl/parser/state/annotation.java | 10 +- .../impl/parser/state/attributeDeclBody.java | 328 +-- .../impl/parser/state/attributeGroupDecl.java | 250 +- .../xsom/impl/parser/state/attributeUses.java | 924 ++++---- .../xsom/impl/parser/state/complexType.java | 2098 ++++++++--------- .../complexType_complexContent_body.java | 80 +- .../impl/parser/state/elementDeclBody.java | 1048 ++++---- .../xsom/impl/parser/state/erSet.java | 10 +- .../xsom/impl/parser/state/ersSet.java | 10 +- .../xsom/impl/parser/state/facet.java | 246 +- .../xsom/impl/parser/state/group.java | 244 +- .../impl/parser/state/identityConstraint.java | 428 ++-- .../xsom/impl/parser/state/importDecl.java | 134 +- .../xsom/impl/parser/state/includeDecl.java | 114 +- .../impl/parser/state/modelGroupBody.java | 220 +- .../xsom/impl/parser/state/notation.java | 298 +-- .../xsom/impl/parser/state/occurs.java | 152 +- .../xsom/impl/parser/state/particle.java | 876 +++---- .../xsom/impl/parser/state/qname.java | 10 +- .../xsom/impl/parser/state/redefine.java | 210 +- .../xsom/impl/parser/state/simpleType.java | 242 +- .../xsom/impl/parser/state/wildcardBody.java | 248 +- .../xsom/impl/parser/state/xpath.java | 162 +- .../xml/internal/xsom/parser/JAXPParser.java | 46 +- .../xml/internal/xsom/parser/XSOMParser.java | 5 +- .../xsom/util/DomAnnotationParserFactory.java | 13 +- .../jaxws_classes/javax/xml/bind/Binder.java | 2 +- .../javax/xml/bind/ContextFinder.java | 59 +- .../javax/xml/bind/DataBindingException.java | 2 +- .../javax/xml/bind/DatatypeConverter.java | 4 +- .../javax/xml/bind/DatatypeConverterImpl.java | 2 +- .../xml/bind/DatatypeConverterInterface.java | 2 +- .../jaxws_classes/javax/xml/bind/Element.java | 2 +- .../javax/xml/bind/GetPropertyAction.java | 2 +- .../jaxws_classes/javax/xml/bind/JAXB.java | 2 +- .../javax/xml/bind/JAXBContext.java | 2 +- .../javax/xml/bind/JAXBElement.java | 2 +- .../javax/xml/bind/JAXBException.java | 2 +- .../javax/xml/bind/JAXBIntrospector.java | 2 +- .../javax/xml/bind/JAXBPermission.java | 2 +- .../javax/xml/bind/MarshalException.java | 2 +- .../javax/xml/bind/Messages.java | 2 +- .../javax/xml/bind/Messages.properties | 2 +- .../javax/xml/bind/NotIdentifiableEvent.java | 2 +- .../javax/xml/bind/ParseConversionEvent.java | 2 +- .../javax/xml/bind/PrintConversionEvent.java | 2 +- .../javax/xml/bind/PropertyException.java | 2 +- .../javax/xml/bind/SchemaOutputResolver.java | 2 +- .../xml/bind/TypeConstraintException.java | 2 +- .../javax/xml/bind/UnmarshalException.java | 2 +- .../javax/xml/bind/Unmarshaller.java | 2 +- .../javax/xml/bind/UnmarshallerHandler.java | 2 +- .../javax/xml/bind/ValidationEvent.java | 2 +- .../xml/bind/ValidationEventHandler.java | 2 +- .../xml/bind/ValidationEventLocator.java | 2 +- .../javax/xml/bind/ValidationException.java | 2 +- .../javax/xml/bind/Validator.java | 2 +- .../javax/xml/bind/WhiteSpaceProcessor.java | 2 +- .../javax/xml/bind/annotation/DomHandler.java | 2 +- .../xml/bind/annotation/W3CDomHandler.java | 2 +- .../xml/bind/annotation/XmlAccessOrder.java | 2 +- .../xml/bind/annotation/XmlAccessType.java | 2 +- .../xml/bind/annotation/XmlAccessorOrder.java | 2 +- .../xml/bind/annotation/XmlAccessorType.java | 2 +- .../xml/bind/annotation/XmlAnyAttribute.java | 2 +- .../xml/bind/annotation/XmlAnyElement.java | 2 +- .../xml/bind/annotation/XmlAttachmentRef.java | 2 +- .../xml/bind/annotation/XmlAttribute.java | 2 +- .../javax/xml/bind/annotation/XmlElement.java | 2 +- .../xml/bind/annotation/XmlElementDecl.java | 2 +- .../xml/bind/annotation/XmlElementRef.java | 2 +- .../xml/bind/annotation/XmlElementRefs.java | 2 +- .../bind/annotation/XmlElementWrapper.java | 2 +- .../xml/bind/annotation/XmlElements.java | 2 +- .../javax/xml/bind/annotation/XmlEnum.java | 2 +- .../xml/bind/annotation/XmlEnumValue.java | 2 +- .../javax/xml/bind/annotation/XmlID.java | 2 +- .../javax/xml/bind/annotation/XmlIDREF.java | 2 +- .../javax/xml/bind/annotation/XmlList.java | 2 +- .../javax/xml/bind/annotation/XmlMixed.java | 2 +- .../javax/xml/bind/annotation/XmlNs.java | 2 +- .../javax/xml/bind/annotation/XmlNsForm.java | 2 +- .../xml/bind/annotation/XmlRegistry.java | 2 +- .../xml/bind/annotation/XmlRootElement.java | 2 +- .../javax/xml/bind/annotation/XmlSchema.java | 2 +- .../xml/bind/annotation/XmlSchemaType.java | 2 +- .../xml/bind/annotation/XmlSchemaTypes.java | 2 +- .../javax/xml/bind/annotation/XmlSeeAlso.java | 2 +- .../xml/bind/annotation/XmlTransient.java | 2 +- .../javax/xml/bind/annotation/XmlType.java | 2 +- .../javax/xml/bind/annotation/XmlValue.java | 2 +- .../adapters/CollapsedStringAdapter.java | 4 +- .../annotation/adapters/HexBinaryAdapter.java | 2 +- .../adapters/NormalizedStringAdapter.java | 2 +- .../adapters/XmlJavaTypeAdapter.java | 2 +- .../adapters/XmlJavaTypeAdapters.java | 2 +- .../xml/bind/annotation/adapters/package.html | 2 +- .../javax/xml/bind/annotation/package.html | 2 +- .../bind/attachment/AttachmentMarshaller.java | 2 +- .../attachment/AttachmentUnmarshaller.java | 2 +- .../javax/xml/bind/attachment/package.html | 2 +- .../bind/helpers/AbstractMarshallerImpl.java | 2 +- .../helpers/AbstractUnmarshallerImpl.java | 2 +- .../DefaultValidationEventHandler.java | 2 +- .../javax/xml/bind/helpers/Messages.java | 2 +- .../xml/bind/helpers/Messages.properties | 2 +- .../helpers/NotIdentifiableEventImpl.java | 2 +- .../helpers/ParseConversionEventImpl.java | 2 +- .../helpers/PrintConversionEventImpl.java | 2 +- .../xml/bind/helpers/ValidationEventImpl.java | 2 +- .../helpers/ValidationEventLocatorImpl.java | 2 +- .../javax/xml/bind/helpers/package.html | 2 +- .../jaxws_classes/javax/xml/bind/package.html | 2 +- .../javax/xml/bind/util/JAXBResult.java | 2 +- .../javax/xml/bind/util/JAXBSource.java | 7 +- .../javax/xml/bind/util/Messages.java | 2 +- .../javax/xml/bind/util/Messages.properties | 2 +- .../bind/util/ValidationEventCollector.java | 2 +- .../javax/xml/bind/util/package.html | 2 +- 364 files changed, 7408 insertions(+), 6257 deletions(-) diff --git a/jaxws/src/share/jaxws_classes/com/sun/istack/internal/tools/ParallelWorldClassLoader.java b/jaxws/src/share/jaxws_classes/com/sun/istack/internal/tools/ParallelWorldClassLoader.java index 50cfa7470b8..5ed042edd59 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/istack/internal/tools/ParallelWorldClassLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/istack/internal/tools/ParallelWorldClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -211,6 +211,7 @@ public class ParallelWorldClassLoader extends ClassLoader implements Closeable { throw new ClassNotFoundException("Loaded outside a jar "+url); url = url.substring(4); // cut off jar: url = url.substring(0,url.lastIndexOf('!')); // cut off everything after '!' + url = url.replaceAll(" ", "%20"); // support white spaces in path return new URL(url); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/probe/provider/annotations/Probe.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/probe/provider/annotations/Probe.java index e66c91ace9e..04ff4c485d1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/probe/provider/annotations/Probe.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/probe/provider/annotations/Probe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -47,5 +47,8 @@ public @interface Probe { public boolean self() default false; public String providerName() default ""; public String moduleName() default ""; - + public boolean stateful() default false; + public String profileNames() default ""; + public boolean statefulReturn() default false; + public boolean statefulException() default false; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java index 3f6df88592b..bbba5738ce9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/AverageRangeStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -27,7 +27,6 @@ package com.sun.org.glassfish.external.statistics.impl; -import java.util.concurrent.atomic.AtomicLong; import java.util.Map; import java.lang.reflect.*; import com.sun.org.glassfish.external.statistics.AverageRangeStatistic; @@ -139,6 +138,8 @@ public final class AverageRangeStatisticImpl extends StatisticImpl implements // todo: equals implementation public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + checkMethod(method); + Object result; try { result = method.invoke(this, args); @@ -147,7 +148,6 @@ public final class AverageRangeStatisticImpl extends StatisticImpl implements } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java index 5eeafaf5ae5..633771fa2ce 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundaryStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -27,7 +27,6 @@ package com.sun.org.glassfish.external.statistics.impl; import com.sun.org.glassfish.external.statistics.BoundaryStatistic; -import java.util.concurrent.atomic.AtomicLong; import java.util.Map; import java.lang.reflect.*; @@ -81,6 +80,8 @@ public final class BoundaryStatisticImpl extends StatisticImpl // todo: equals implementation public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + checkMethod(m); + Object result; try { result = m.invoke(this, args); @@ -89,7 +90,6 @@ public final class BoundaryStatisticImpl extends StatisticImpl } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java index 9cbf7b5fa51..52c8479d75a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/BoundedRangeStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -26,8 +26,8 @@ package com.sun.org.glassfish.external.statistics.impl; + import com.sun.org.glassfish.external.statistics.BoundedRangeStatistic; -import java.util.concurrent.atomic.AtomicLong; import java.util.Map; import java.lang.reflect.*; @@ -145,6 +145,8 @@ public final class BoundedRangeStatisticImpl extends StatisticImpl // todo: equals implementation public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + checkMethod(m); + Object result; try { result = m.invoke(this, args); @@ -153,7 +155,6 @@ public final class BoundedRangeStatisticImpl extends StatisticImpl } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java index f593de23e75..351627b6f6a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/CountStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -26,7 +26,6 @@ package com.sun.org.glassfish.external.statistics.impl; import com.sun.org.glassfish.external.statistics.CountStatistic; -import java.util.concurrent.atomic.AtomicLong; import java.util.Map; import java.lang.reflect.*; @@ -103,6 +102,8 @@ public final class CountStatisticImpl extends StatisticImpl // todo: equals implementation public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + checkMethod(m); + Object result; try { result = m.invoke(this, args); @@ -111,7 +112,6 @@ public final class CountStatisticImpl extends StatisticImpl } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java index cfe702a01c6..9f6ec99d89b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/RangeStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -27,7 +27,6 @@ package com.sun.org.glassfish.external.statistics.impl; import com.sun.org.glassfish.external.statistics.RangeStatistic; -import java.util.concurrent.atomic.AtomicLong; import java.util.Map; import java.lang.reflect.*; @@ -125,6 +124,8 @@ public final class RangeStatisticImpl extends StatisticImpl // todo: equals implementation public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + checkMethod(m); + Object result; try { result = m.invoke(this, args); @@ -133,7 +134,6 @@ public final class RangeStatisticImpl extends StatisticImpl } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java index 708f06a5393..d257019a2b6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -26,8 +26,8 @@ package com.sun.org.glassfish.external.statistics.impl; import com.sun.org.glassfish.external.statistics.Statistic; -import java.io.Serializable; -import java.util.concurrent.atomic.AtomicLong; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -133,4 +133,13 @@ public abstract class StatisticImpl implements Statistic { protected static boolean isValidString(String str) { return (str!=null && str.length()>0); } + + protected void checkMethod(Method method) { + if (method == null || method.getDeclaringClass() == null + || !Statistic.class.isAssignableFrom(method.getDeclaringClass()) + || Modifier.isStatic(method.getModifiers())) { + throw new RuntimeException("Invalid method on invoke"); + } + } + } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java index 972f1c175cb..f8486daf7e1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/StringStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -90,6 +90,8 @@ public final class StringStatisticImpl extends StatisticImpl // todo: equals implementation public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + checkMethod(m); + Object result; try { result = m.invoke(this, args); @@ -98,7 +100,6 @@ public final class StringStatisticImpl extends StatisticImpl } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java index 6e6bd723382..27936b7ee46 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/org/glassfish/external/statistics/impl/TimeStatisticImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -28,7 +28,6 @@ package com.sun.org.glassfish.external.statistics.impl; import com.sun.org.glassfish.external.statistics.TimeStatistic; -import java.util.concurrent.atomic.AtomicLong; import java.util.Map; import java.lang.reflect.*; @@ -145,6 +144,8 @@ public final class TimeStatisticImpl extends StatisticImpl // todo: equals implementation public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + checkMethod(m); + Object result; try { result = m.invoke(this, args); @@ -153,7 +154,6 @@ public final class TimeStatisticImpl extends StatisticImpl } catch (Exception e) { throw new RuntimeException("unexpected invocation exception: " + e.getMessage()); - } finally { } return result; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties index c1805f1ff17..430a8d8ef0d 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle.properties @@ -30,10 +30,10 @@ BASEDIR_DOESNT_EXIST = \ Non-existent directory: {0} VERSION = \ - schemagen 2.2.8-b01 + schemagen 2.2.8-b20130806.1801 FULLVERSION = \ - schemagen full version "2.2.8-b01" + schemagen full version "2.2.8-b20130806.1801" USAGE = \ Usage: schemagen [-options ...] \n\ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties index 971c1709e2e..ddf736faf0a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_de.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Nicht erkanntes {0} in Zeile {1} Spalte {2} BASEDIR_DOESNT_EXIST = Nicht vorhandenes Verzeichnis: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.8-b01" +FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.8-b20130806.1801" USAGE = Verwendung: schemagen [-options ...] \nOptionen: \n\\ \\ \\ \\ -d : Gibt an, wo die von Prozessor und javac generierten Klassendateien gespeichert werden sollen\n\\ \\ \\ \\ -cp : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -classpath : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -encoding : Gibt die Codierung f\u00FCr die Annotationsverarbeitung/den javac-Aufruf an \n\\ \\ \\ \\ -episode : Generiert Episodendatei f\u00FCr separate Kompilierung\n\\ \\ \\ \\ -version : Zeigt Versionsinformation an\n\\ \\ \\ \\ -fullversion : Zeigt vollst\u00E4ndige Versionsinformationen an\n\\ \\ \\ \\ -help : Zeigt diese Verwendungsmeldung an diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties index 030047264b7..d9a1b2ee510 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_es.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Aparece un {0} inesperado en la l\u00EDnea {1} y la colu BASEDIR_DOESNT_EXIST = Directorio no existente: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = versi\u00F3n completa de schemagen "2.2.8-b01" +FULLVERSION = versi\u00F3n completa de schemagen "2.2.8-b20130806.1801" USAGE = Sintaxis: schemagen [-options ...] \nOpciones: \n\\ \\ \\ \\ -d : especifique d\u00F3nde se colocan los archivos de clase generados por javac y el procesador\n\\ \\ \\ \\ -cp : especifique d\u00F3nde se encuentran los archivos especificados por el usuario\n\\ \\ \\ \\ -encoding : especifique la codificaci\u00F3n que se va a utilizar para el procesamiento de anotaciones/llamada de javac\n\\ \\ \\ \\ -episode : genera un archivo de episodio para una compilaci\u00F3n diferente\n\\ \\ \\ \\ -version : muestra la informaci\u00F3n de la versi\u00F3n\n\\ \\ \\ \\ -fullversion : muestra la informaci\u00F3n completa de la versi\u00F3n\n\\ \\ \\ \\ -help : muestra este mensaje de sintaxis diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties index b3107ee4418..1ed6126bac8 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = Un \u00E9l\u00E9ment {0} inattendu appara\u00EEt \u00E0 BASEDIR_DOESNT_EXIST = R\u00E9pertoire {0} inexistant -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = version compl\u00E8te de schemagen "2.2.8-b01" +FULLVERSION = version compl\u00E8te de schemagen "2.2.8-b20130806.1801" USAGE = Syntaxe : schemagen [-options ...] \nOptions : \n\ \ \ \ -d : indiquez o\u00F9 placer les fichiers de classe g\u00E9n\u00E9r\u00E9s par le processeur et le compilateur javac\n\ \ \ \ -cp : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -classpath : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -encoding : indiquez l'encodage \u00E0 utiliser pour l'appel de javac/traitement de l'annotation \n\ \ \ \ -episode : g\u00E9n\u00E9rez un fichier d'\u00E9pisode pour la compilation s\u00E9par\u00E9e\n\ \ \ \ -version : affichez les informations de version\n\ \ \ \ -fullversion : affichez les informations compl\u00E8tes de version\n\ \ \ \ -help : affichez ce message de syntaxe diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties index 0aa7cf4c807..0208b66294e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_it.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = {0} imprevisto visualizzato sulla riga {1} colonna {2} BASEDIR_DOESNT_EXIST = Directory non esistente: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = versione completa schemagen "2.2.8-b01" +FULLVERSION = versione completa schemagen "2.2.8-b20130806.1801" USAGE = Uso: schemagen [-options ...] \nOpzioni: \n\ \ \ \ -d : specifica dove posizionare il processore e i file della classe generata javac\n\ \ \ \ -cp : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -classpath : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -encoding : specifica la codifica da usare per l'elaborazione dell'annotazione/richiamo javac \n\ \ \ \ -episode : genera il file di episodio per la compilazione separata\n\ \ \ \ -version : visualizza le informazioni sulla versione\n\ \ \ \ -fullversion : visualizza le informazioni sulla versione completa\n\ \ \ \ -help : visualizza questo messaggio sull'uso diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties index b8889bb6e22..7678e5d8f3b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u4E88\u671F\u3057\u306A\u3044{0}\u304C\u884C{1}\u3001\u BASEDIR_DOESNT_EXIST = \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.8-b01" +FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.8-b20130806.1801" USAGE = \u4F7F\u7528\u65B9\u6CD5: schemagen [-options ...] \n\u30AA\u30D7\u30B7\u30E7\u30F3: \n\ \ \ \ -d : \u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -cp : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -classpath : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -encoding : \u6CE8\u91C8\u51E6\u7406/javac\u547C\u51FA\u3057\u306B\u4F7F\u7528\u3059\u308B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -episode : \u30B3\u30F3\u30D1\u30A4\u30EB\u3054\u3068\u306B\u30A8\u30D4\u30BD\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\n\ \ \ \ -version : \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -fullversion : \u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -help : \u3053\u306E\u4F7F\u7528\u4F8B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u307E\u3059 diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties index b89650bd0ff..cfc4364d80a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \uC608\uC0C1\uCE58 \uC54A\uC740 {0}\uC774(\uAC00) {1}\uD BASEDIR_DOESNT_EXIST = \uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uB514\uB809\uD1A0\uB9AC: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.8-b01" +FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.8-b20130806.1801" USAGE = \uC0AC\uC6A9\uBC95: schemagen [-options ...] \n\uC635\uC158: \n\ \ \ \ -d : \uD504\uB85C\uC138\uC11C \uBC0F javac\uC5D0\uC11C \uC0DD\uC131\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uBC30\uCE58\uD560 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -cp : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -classpath : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -encoding : \uC8FC\uC11D \uCC98\uB9AC/javac \uD638\uCD9C\uC5D0 \uC0AC\uC6A9\uD560 \uC778\uCF54\uB529\uC744 \uC9C0\uC815\uD569\uB2C8\uB2E4. \n\ \ \ \ -episode : \uBCC4\uB3C4 \uCEF4\uD30C\uC77C\uC744 \uC704\uD574 episode \uD30C\uC77C\uC744 \uC0DD\uC131\uD569\uB2C8\uB2E4.\n\ \ \ \ -version : \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -fullversion : \uC815\uC2DD \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -help : \uC774 \uC0AC\uC6A9\uBC95 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties index fc9f8afbc11..318ab2c54f2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = {0} inesperado aparece na linha {1} coluna {2} BASEDIR_DOESNT_EXIST = Diret\u00F3rio n\u00E3o existente: {0} -VERSION = gera\u00E7\u00E3o do esquema 2.2.8-b01 +VERSION = gera\u00E7\u00E3o do esquema 2.2.8-b20130806.1801 -FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.8-b01" +FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.8-b20130806.1801" USAGE = Uso: gera\u00E7\u00E3o do esquema [-options ...] \nOp\u00E7\u00F5es: \n\\ \\ \\ \\ -d : especificar onde colocar o processador e os arquivos da classe gerados por javac\n\\ \\ \\ \\ -cp : especificar onde localizar arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -classpath : especificar onde localizar os arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -encoding : especificar codifica\u00E7\u00E3o a ser usada para processamento de anota\u00E7\u00E3o/chamada javac \n\\ \\ \\ \\ -episode : gerar arquivo do epis\u00F3dio para compila\u00E7\u00E3o separada\n\\ \\ \\ \\ -version : exibir informa\u00E7\u00F5es da vers\u00E3o\n\\ \\ \\ \\ -fullversion : exibir informa\u00E7\u00F5es da vers\u00E3o completa\n\\ \\ \\ \\ -help : exibir esta mensagem de uso diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties index 4493b23dd18..87636c0d3cd 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u5728\u7B2C {1} \u884C, \u7B2C {2} \u5217\u51FA\u73B0\u BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u5F55: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.8-b01" +FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.8-b20130806.1801" USAGE = \u7528\u6CD5: schemagen [-options ...] \n\u9009\u9879: \n\ \ \ \ -d : \u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -cp : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -classpath : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -encoding : \u6307\u5B9A\u7528\u4E8E\u6CE8\u91CA\u5904\u7406/javac \u8C03\u7528\u7684\u7F16\u7801\n\ \ \ \ -episode : \u751F\u6210\u7247\u6BB5\u6587\u4EF6\u4EE5\u4F9B\u5355\u72EC\u7F16\u8BD1\n\ \ \ \ -version : \u663E\u793A\u7248\u672C\u4FE1\u606F\n\ \ \ \ -fullversion : \u663E\u793A\u5B8C\u6574\u7684\u7248\u672C\u4FE1\u606F\n\ \ \ \ -help : \u663E\u793A\u6B64\u7528\u6CD5\u6D88\u606F diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties index 45748f11a28..d828ed5f8e4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties @@ -27,8 +27,8 @@ UNEXPECTED_NGCC_TOKEN = \u672A\u9810\u671F\u7684 {0} \u986F\u793A\u65BC\u884C {1 BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u9304: {0} -VERSION = schemagen 2.2.8-b01 +VERSION = schemagen 2.2.8-b20130806.1801 -FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.8-b01" +FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.8-b20130806.1801" USAGE = \u7528\u6CD5: schemagen [-options ...] \n\u9078\u9805: \n\\ \\ \\ \\ -d : \u6307\u5B9A\u8655\u7406\u5668\u4EE5\u53CA javac \u7522\u751F\u7684\u985E\u5225\u6A94\u6848\u653E\u7F6E\u4F4D\u7F6E\n\\ \\ \\ \\ -cp : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -classpath : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -encoding : \u6307\u5B9A\u8981\u7528\u65BC\u8A3B\u89E3\u8655\u7406/javac \u547C\u53EB\u7684\u7DE8\u78BC \n\\ \\ \\ \\ -episode : \u7522\u751F\u7368\u7ACB\u7DE8\u8B6F\u7684\u4E8B\u4EF6 (episode) \u6A94\u6848\n\\ \\ \\ \\ -version : \u986F\u793A\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -fullversion : \u986F\u793A\u5B8C\u6574\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -help : \u986F\u793A\u6B64\u7528\u6CD5\u8A0A\u606F diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/AttributesImpl.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/AttributesImpl.java index be038f6a6d0..6ad38ce17b9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/AttributesImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/AttributesImpl.java @@ -64,6 +64,9 @@ import org.xml.sax.Attributes; * AttributeList} interface, it also includes a much more efficient * implementation using a single array rather than a set of Vectors.

* + *

+ * Auto-generated, do not edit. + *

* @since SAX 2.0 * @author David Megginson, * sax@megginson.com diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Classes.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Classes.java index 60968c00c56..bbd1ba07b0e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Classes.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Classes.java @@ -33,7 +33,11 @@ import com.sun.tools.internal.jxc.NGCCRuntimeEx; import java.util.List; import java.util.ArrayList; - +/** + *

+ * Auto-generated, do not edit. + *

+ */ public class Classes extends NGCCHandler { private String __text; private String exclude_content; @@ -78,17 +82,11 @@ public class Classes extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { - case 4: + case 12: { - $_ngcc_current_state = 3; - $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); - } - break; - case 11: - { - if(($__uri.equals("") && $__local.equals("includes"))) { + if(($__uri.equals("") && $__local.equals("classes"))) { $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs); - $_ngcc_current_state = 10; + $_ngcc_current_state = 11; } else { unexpectedEnterElement($__qname); @@ -107,22 +105,28 @@ public class Classes extends NGCCHandler { } } break; - case 0: + case 4: { - revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs); + $_ngcc_current_state = 3; + $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); } break; - case 12: + case 11: { - if(($__uri.equals("") && $__local.equals("classes"))) { + if(($__uri.equals("") && $__local.equals("includes"))) { $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs); - $_ngcc_current_state = 11; + $_ngcc_current_state = 10; } else { unexpectedEnterElement($__qname); } } break; + case 0: + { + revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs); + } + break; default: { unexpectedEnterElement($__qname); @@ -137,23 +141,18 @@ public class Classes extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { + case 2: + { + $_ngcc_current_state = 1; + $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); + } + break; case 4: { $_ngcc_current_state = 3; $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); } break; - case 3: - { - if(($__uri.equals("") && $__local.equals("excludes"))) { - $runtime.onLeaveElementConsumed($__uri, $__local, $__qname); - $_ngcc_current_state = 1; - } - else { - unexpectedLeaveElement($__qname); - } - } - break; case 1: { if(($__uri.equals("") && $__local.equals("classes"))) { @@ -165,6 +164,22 @@ public class Classes extends NGCCHandler { } } break; + case 3: + { + if(($__uri.equals("") && $__local.equals("excludes"))) { + $runtime.onLeaveElementConsumed($__uri, $__local, $__qname); + $_ngcc_current_state = 1; + } + else { + unexpectedLeaveElement($__qname); + } + } + break; + case 0: + { + revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname); + } + break; case 8: { if(($__uri.equals("") && $__local.equals("includes"))) { @@ -176,17 +191,6 @@ public class Classes extends NGCCHandler { } } break; - case 2: - { - $_ngcc_current_state = 1; - $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); - } - break; - case 0: - { - revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname); - } - break; default: { unexpectedLeaveElement($__qname); @@ -201,18 +205,18 @@ public class Classes extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { - case 4: - { - $_ngcc_current_state = 3; - $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); - } - break; case 2: { $_ngcc_current_state = 1; $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); } break; + case 4: + { + $_ngcc_current_state = 3; + $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); + } + break; case 0: { revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname); @@ -232,18 +236,18 @@ public class Classes extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { - case 4: - { - $_ngcc_current_state = 3; - $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); - } - break; case 2: { $_ngcc_current_state = 1; $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); } break; + case 4: + { + $_ngcc_current_state = 3; + $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); + } + break; case 0: { revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname); @@ -260,6 +264,12 @@ public class Classes extends NGCCHandler { public void text(String $value) throws SAXException { int $ai; switch($_ngcc_current_state) { + case 2: + { + $_ngcc_current_state = 1; + $runtime.sendText(super._cookie, $value); + } + break; case 4: { exclude_content = $value; @@ -267,20 +277,6 @@ public class Classes extends NGCCHandler { action0(); } break; - case 3: - { - exclude_content = $value; - $_ngcc_current_state = 3; - action0(); - } - break; - case 9: - { - include_content = $value; - $_ngcc_current_state = 8; - action2(); - } - break; case 10: { __text = $value; @@ -288,6 +284,13 @@ public class Classes extends NGCCHandler { action3(); } break; + case 3: + { + exclude_content = $value; + $_ngcc_current_state = 3; + action0(); + } + break; case 6: { __text = $value; @@ -295,22 +298,23 @@ public class Classes extends NGCCHandler { action1(); } break; - case 8: + case 0: + { + revertToParentFromText(this, super._cookie, $value); + } + break; + case 9: { include_content = $value; $_ngcc_current_state = 8; action2(); } break; - case 2: + case 8: { - $_ngcc_current_state = 1; - $runtime.sendText(super._cookie, $value); - } - break; - case 0: - { - revertToParentFromText(this, super._cookie, $value); + include_content = $value; + $_ngcc_current_state = 8; + action2(); } break; } diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Config.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Config.java index f806a817416..60aef42c838 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Config.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Config.java @@ -36,7 +36,11 @@ import java.util.List; import java.util.ArrayList; import java.io.File; - +/** + *

+ * Auto-generated, do not edit. + *

+ */ public class Config extends NGCCHandler { private String bd; private Schema _schema; @@ -74,15 +78,19 @@ public class Config extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { - case 2: + case 0: + { + revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs); + } + break; + case 1: { if(($__uri.equals("") && $__local.equals("schema"))) { - NGCCHandler h = new Schema(this, super._source, $runtime, 16, baseDir); + NGCCHandler h = new Schema(this, super._source, $runtime, 19, baseDir); spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); } else { - $_ngcc_current_state = 1; - $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); + unexpectedEnterElement($__qname); } } break; @@ -100,7 +108,7 @@ public class Config extends NGCCHandler { case 4: { if(($__uri.equals("") && $__local.equals("classes"))) { - NGCCHandler h = new Classes(this, super._source, $runtime, 18); + NGCCHandler h = new Classes(this, super._source, $runtime, 22); spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); } else { @@ -108,19 +116,15 @@ public class Config extends NGCCHandler { } } break; - case 0: - { - revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs); - } - break; - case 1: + case 2: { if(($__uri.equals("") && $__local.equals("schema"))) { - NGCCHandler h = new Schema(this, super._source, $runtime, 15, baseDir); + NGCCHandler h = new Schema(this, super._source, $runtime, 20, baseDir); spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); } else { - unexpectedEnterElement($__qname); + $_ngcc_current_state = 1; + $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); } } break; @@ -149,12 +153,6 @@ public class Config extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { - case 2: - { - $_ngcc_current_state = 1; - $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); - } - break; case 0: { revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname); @@ -171,6 +169,12 @@ public class Config extends NGCCHandler { } } break; + case 2: + { + $_ngcc_current_state = 1; + $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); + } + break; case 7: { if(($ai = $runtime.getAttributeIndex("","baseDir"))>=0) { @@ -196,17 +200,17 @@ public class Config extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { + case 0: + { + revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname); + } + break; case 2: { $_ngcc_current_state = 1; $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); } break; - case 0: - { - revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname); - } - break; case 7: { if(($__uri.equals("") && $__local.equals("baseDir"))) { @@ -231,10 +235,9 @@ public class Config extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { - case 2: + case 0: { - $_ngcc_current_state = 1; - $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); + revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname); } break; case 5: @@ -247,9 +250,10 @@ public class Config extends NGCCHandler { } } break; - case 0: + case 2: { - revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname); + $_ngcc_current_state = 1; + $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); } break; default: @@ -263,10 +267,9 @@ public class Config extends NGCCHandler { public void text(String $value) throws SAXException { int $ai; switch($_ngcc_current_state) { - case 2: + case 0: { - $_ngcc_current_state = 1; - $runtime.sendText(super._cookie, $value); + revertToParentFromText(this, super._cookie, $value); } break; case 6: @@ -276,9 +279,10 @@ public class Config extends NGCCHandler { action1(); } break; - case 0: + case 2: { - revertToParentFromText(this, super._cookie, $value); + $_ngcc_current_state = 1; + $runtime.sendText(super._cookie, $value); } break; case 7: @@ -294,20 +298,20 @@ public class Config extends NGCCHandler { public void onChildCompleted(Object result, int cookie, boolean needAttCheck)throws SAXException { switch(cookie) { - case 16: + case 19: { this._schema = ((Schema)result); action0(); $_ngcc_current_state = 1; } break; - case 18: + case 22: { this.classes = ((Classes)result); $_ngcc_current_state = 2; } break; - case 15: + case 20: { this._schema = ((Schema)result); action0(); diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventReceiver.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventReceiver.java index 15fbe303731..ee80bdf8a10 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventReceiver.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventReceiver.java @@ -29,7 +29,9 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; /** - * + *

+ * Auto-generated, do not edit. + *

* * @author Kohsuke Kawaguchi (kk@kohsuke.org) */ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventSource.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventSource.java index b90624a9648..f1ffb72d635 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventSource.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCEventSource.java @@ -29,7 +29,9 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; /** - * + *

+ * Auto-generated, do not edit. + *

* * @author Kohsuke Kawaguchi (kk@kohsuke.org) */ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCHandler.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCHandler.java index 8fe7a1a84f0..fe4d5e9bcfd 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCHandler.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCHandler.java @@ -29,7 +29,9 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; /** - * + *

+ * Auto-generated, do not edit. + *

* * @version $Id: NGCCHandler.java,v 1.9 2002/09/29 02:55:48 okajima Exp $ * @author Kohsuke Kawaguchi (kk@kohsuke.org) diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCInterleaveFilter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCInterleaveFilter.java index ddb023451ae..702b0bdbedf 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCInterleaveFilter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCInterleaveFilter.java @@ -32,6 +32,9 @@ import org.xml.sax.SAXException; * Dispatches incoming events into sub handlers appropriately * so that the interleaving semantics will be correctly realized. * + *

+ * Auto-generated, do not edit. + *

* @author Kohsuke Kawaguchi (kk@kohsuke.org) */ public abstract class NGCCInterleaveFilter implements NGCCEventSource, NGCCEventReceiver { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCRuntime.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCRuntime.java index 74837e33070..a9184d6f84b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCRuntime.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/NGCCRuntime.java @@ -50,7 +50,9 @@ import org.xml.sax.SAXParseException; *
  • manage mapping between namespace URIs and prefixes. * *
  • TODO: provide support for interleaving. - * + *

    + * Auto-generated, do not edit. + *

    * @version $Id: NGCCRuntime.java,v 1.15 2002/09/29 02:55:48 okajima Exp $ * @author Kohsuke Kawaguchi (kk@kohsuke.org) */ diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Schema.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Schema.java index 18de25f4a88..f238314c0b0 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Schema.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/jxc/gen/config/Schema.java @@ -32,7 +32,11 @@ import com.sun.tools.internal.jxc.NGCCRuntimeEx; import java.io.File; - +/** + *

    + * Auto-generated, do not edit. + *

    + */ public class Schema extends NGCCHandler { private File baseDir; private String loc; @@ -72,18 +76,6 @@ public class Schema extends NGCCHandler { revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs); } break; - case 6: - { - if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) { - $runtime.consumeAttribute($ai); - $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); - } - else { - $_ngcc_current_state = 2; - $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); - } - } - break; case 2: { if(($ai = $runtime.getAttributeIndex("","location"))>=0) { @@ -96,6 +88,18 @@ public class Schema extends NGCCHandler { } } break; + case 6: + { + if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) { + $runtime.consumeAttribute($ai); + $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); + } + else { + $_ngcc_current_state = 2; + $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); + } + } + break; case 10: { if(($__uri.equals("") && $__local.equals("schema"))) { @@ -121,23 +125,22 @@ public class Schema extends NGCCHandler { $localName = $__local; $qname = $__qname; switch($_ngcc_current_state) { + case 1: + { + if(($__uri.equals("") && $__local.equals("schema"))) { + $runtime.onLeaveElementConsumed($__uri, $__local, $__qname); + $_ngcc_current_state = 0; + } + else { + unexpectedLeaveElement($__qname); + } + } + break; case 0: { revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname); } break; - case 6: - { - if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) { - $runtime.consumeAttribute($ai); - $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); - } - else { - $_ngcc_current_state = 2; - $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); - } - } - break; case 2: { if(($ai = $runtime.getAttributeIndex("","location"))>=0) { @@ -150,14 +153,15 @@ public class Schema extends NGCCHandler { } } break; - case 1: + case 6: { - if(($__uri.equals("") && $__local.equals("schema"))) { - $runtime.onLeaveElementConsumed($__uri, $__local, $__qname); - $_ngcc_current_state = 0; + if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) { + $runtime.consumeAttribute($ai); + $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); } else { - unexpectedLeaveElement($__qname); + $_ngcc_current_state = 2; + $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); } } break; @@ -180,17 +184,6 @@ public class Schema extends NGCCHandler { revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname); } break; - case 6: - { - if(($__uri.equals("") && $__local.equals("namespace"))) { - $_ngcc_current_state = 8; - } - else { - $_ngcc_current_state = 2; - $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); - } - } - break; case 2: { if(($__uri.equals("") && $__local.equals("location"))) { @@ -202,6 +195,17 @@ public class Schema extends NGCCHandler { } } break; + case 6: + { + if(($__uri.equals("") && $__local.equals("namespace"))) { + $_ngcc_current_state = 8; + } + else { + $_ngcc_current_state = 2; + $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); + } + } + break; default: { unexpectedEnterAttribute($__qname); @@ -221,22 +225,6 @@ public class Schema extends NGCCHandler { revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname); } break; - case 7: - { - if(($__uri.equals("") && $__local.equals("namespace"))) { - $_ngcc_current_state = 2; - } - else { - unexpectedLeaveAttribute($__qname); - } - } - break; - case 6: - { - $_ngcc_current_state = 2; - $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); - } - break; case 3: { if(($__uri.equals("") && $__local.equals("location"))) { @@ -247,12 +235,28 @@ public class Schema extends NGCCHandler { } } break; + case 7: + { + if(($__uri.equals("") && $__local.equals("namespace"))) { + $_ngcc_current_state = 2; + } + else { + unexpectedLeaveAttribute($__qname); + } + } + break; case 2: { $_ngcc_current_state = 1; $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); } break; + case 6: + { + $_ngcc_current_state = 2; + $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); + } + break; default: { unexpectedLeaveAttribute($__qname); @@ -270,23 +274,6 @@ public class Schema extends NGCCHandler { $_ngcc_current_state = 7; } break; - case 0: - { - revertToParentFromText(this, super._cookie, $value); - } - break; - case 6: - { - if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) { - $runtime.consumeAttribute($ai); - $runtime.sendText(super._cookie, $value); - } - else { - $_ngcc_current_state = 2; - $runtime.sendText(super._cookie, $value); - } - } - break; case 4: { loc = $value; @@ -294,6 +281,11 @@ public class Schema extends NGCCHandler { action0(); } break; + case 0: + { + revertToParentFromText(this, super._cookie, $value); + } + break; case 2: { if(($ai = $runtime.getAttributeIndex("","location"))>=0) { @@ -306,6 +298,18 @@ public class Schema extends NGCCHandler { } } break; + case 6: + { + if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) { + $runtime.consumeAttribute($ai); + $runtime.sendText(super._cookie, $value); + } + else { + $_ngcc_current_state = 2; + $runtime.sendText(super._cookie, $value); + } + } + break; } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties index 5d7ed24b883..9862bdc6bb2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/version.properties @@ -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,7 +23,7 @@ # questions. # -build-id=2.2.9-b14027 -build-version=JAX-WS RI 2.2.9-b14027 +build-id=2.2.9-b14140 +build-version=JAX-WS RI 2.2.9-b14140 major-version=2.2.9 -svn-revision=14027 +svn-revision=14140 diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties index 4e64ca0c717..bf21c1ee0f9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle.properties @@ -171,23 +171,23 @@ Driver.CompilingSchema = \ Driver.FailedToGenerateCode = \ Failed to produce code. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant Driver.FilePrologComment = \ - This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b01 \n\ + This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b20130806.1801 \n\ See http://java.sun.com/xml/jaxb \n\ Any modifications to this file will be lost upon recompilation of the source schema. \n\ Generated on: {0} \n Driver.Version = \ - xjc 2.2.8-b01 + xjc 2.2.8-b20130806.1801 Driver.FullVersion = \ - xjc full version "2.2.8-b01-b28" + xjc full version "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties index 3fee895ed99..560d6b66a90 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_de.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = Ein Schema wird kompiliert ... Driver.FailedToGenerateCode = Code konnte nicht erzeugt werden. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b01 generiert \nSiehe http://java.sun.com/xml/jaxb \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b20130806.1801 generiert \nSiehe http://java.sun.com/xml/jaxb \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = xjc vollst\u00e4ndige Version "2.2.8-b01-b28" +Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties index ee3e09df36a..47a66fc719e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_es.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = Compilando un esquema... Driver.FailedToGenerateCode = Fallo al producir c\u00f3digo. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.8-b01 \nVisite http://java.sun.com/xml/jaxb \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.8-b20130806.1801 \nVisite http://java.sun.com/xml/jaxb \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = versi\u00f3n completa de xjc "2.2.8-b01-b28" +Driver.FullVersion = versi\u00F3n completa de xjc "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties index d5a8fbbacbf..a9dea414d78 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = compilation d'un sch\u00e9ma... Driver.FailedToGenerateCode = Echec de la production du code. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.8-b01 \nVoir http://java.sun.com/xml/jaxb \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.8-b20130806.1801 \nVoir http://java.sun.com/xml/jaxb \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = version compl\u00e8te xjc "2.2.8-b01-b28" +Driver.FullVersion = version compl\u00E8te xjc "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties index 33441891015..b63eb553179 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_it.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = compilazione di uno schema in corso... Driver.FailedToGenerateCode = Produzione del codice non riuscita. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.8-b01 \nVedere http://java.sun.com/xml/jaxb \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.8-b20130806.1801 \nVedere http://java.sun.com/xml/jaxb \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = versione completa xjc "2.2.8-b01-b28" +Driver.FullVersion = versione completa xjc "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties index edd5c648e7c..8dd5b8a84af 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = \u30b9\u30ad\u30fc\u30de\u306e\u30b3\u30f3\u30d1\u30a4\ Driver.FailedToGenerateCode = \u30b3\u30fc\u30c9\u306e\u751f\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002 -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.8-b01\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \nhttp://java.sun.com/xml/jaxb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.8-b20130806.1801\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \nhttp://java.sun.com/xml/jaxb\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = xjc\u30d5\u30eb\u30fb\u30d0\u30fc\u30b8\u30e7\u30f3"2.2.8-b01-b28" +Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties index d493f5bd054..3d0f6b9f369 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = \uc2a4\ud0a4\ub9c8\ub97c \ucef4\ud30c\uc77c\ud558\ub294 Driver.FailedToGenerateCode = \ucf54\ub4dc \uc0dd\uc131\uc744 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.8-b01 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \nhttp://java.sun.com/xml/jaxb\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.8-b20130806.1801 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \nhttp://java.sun.com/xml/jaxb\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n -Driver.Version = XJC 2.2.8-b01 +Driver.Version = XJC 2.2.8-b20130806.1801 -Driver.FullVersion = XJC \uc815\uc2dd \ubc84\uc804 "2.2.8-b01-b28" +Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties index 3ac7a0bf2c3..c7eb0286e2e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = compilando um esquema... Driver.FailedToGenerateCode = Falha ao produzir o c\u00f3digo. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.8-b01 \nConsulte http://java.sun.com/xml/jaxb \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.8-b20130806.1801 \nConsulte http://java.sun.com/xml/jaxb \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = vers\u00e3o completa de xjc "2.2.8-b01-b28" +Driver.FullVersion = vers\u00E3o completa de xjc "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties index 610bb1e3cc7..748aab67e38 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = \u6b63\u5728\u7f16\u8bd1\u6a21\u5f0f... Driver.FailedToGenerateCode = \u65e0\u6cd5\u751f\u6210\u4ee3\u7801\u3002 -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.8-b01 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee http://java.sun.com/xml/jaxb \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.8-b20130806.1801 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee http://java.sun.com/xml/jaxb \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = xjc \u5b8c\u6574\u7248\u672c "2.2.8-b01-b28" +Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties index 3ed7786c9ec..a305e7e7445 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties @@ -96,17 +96,17 @@ Driver.CompilingSchema = \u6b63\u5728\u7de8\u8b6f\u7db1\u8981... Driver.FailedToGenerateCode = \u7121\u6cd5\u7522\u751f\u7a0b\u5f0f\u78bc. -# DO NOT localize the 2.2.8-b01 string - it is a token for an ant -Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b01 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 http://java.sun.com/xml/jaxb \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n +# DO NOT localize the 2.2.8-b20130806.1801 string - it is a token for an ant +Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b20130806.1801 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 http://java.sun.com/xml/jaxb \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n -Driver.Version = xjc 2.2.8-b01 +Driver.Version = xjc 2.2.8-b20130806.1801 -Driver.FullVersion = xjc \u5b8c\u6574\u7248\u672c "2.2.8-b01-b28" +Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.8-b20130806.1801" -Driver.BuildID = 2.2.8-b01 +Driver.BuildID = 2.2.8-b20130806.1801 # for JDK integration - include version in source zip -jaxb.jdk.version=2.2.8-b01 +jaxb.jdk.version=@@JAXB_JDK_VERSION@@ # see java.text.SimpleDateFormat for format syntax # DO NOT LOCALIZE, Format should not be changed, English locale is used to transform this string into a real date. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/SchemaCache.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/SchemaCache.java index ca8302358fc..c28fd50db86 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/SchemaCache.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/SchemaCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,8 @@ import com.sun.xml.internal.bind.v2.util.XmlFactory; import javax.xml.XMLConstants; import org.xml.sax.SAXException; +import static com.sun.xml.internal.bind.v2.util.XmlFactory.allowFileAccess; + /** * Wraps a JAXP {@link Schema} object and lazily instantiate it. * @@ -59,7 +61,7 @@ public final class SchemaCache { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); - schema = sf.newSchema(source); + schema = allowFileAccess(sf, false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorOrderWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorOrderWriter.java index e394a36c4c4..e5e8ecb8225 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorOrderWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorOrderWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlAccessOrder; import javax.xml.bind.annotation.XmlAccessorOrder; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlAccessorOrderWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorTypeWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorTypeWriter.java index 307991c2a9b..ae7c008d461 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorTypeWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAccessorTypeWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlAccessorTypeWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyAttributeWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyAttributeWriter.java index c17df86b4b3..22d5b3d6475 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyAttributeWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyAttributeWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlAnyAttribute; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlAnyAttributeWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyElementWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyElementWriter.java index 14a96fe355a..139a665d523 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyElementWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAnyElementWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlAnyElement; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlAnyElementWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttachmentRefWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttachmentRefWriter.java index be5262b135c..b9c8db4857a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttachmentRefWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttachmentRefWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlAttachmentRef; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlAttachmentRefWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttributeWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttributeWriter.java index 6596c951619..fc32e7b84b4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttributeWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlAttributeWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlAttribute; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlAttributeWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementDeclWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementDeclWriter.java index 6954df88959..91981dfc1d9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementDeclWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementDeclWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlElementDecl; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlElementDeclWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefWriter.java index abbd33fe09e..ebd9f434d4e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlElementRef; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlElementRefWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefsWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefsWriter.java index c6f3a214e6a..a7276b0078d 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefsWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementRefsWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlElementRefs; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlElementRefsWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWrapperWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWrapperWriter.java index 36808950d90..bd604e3c55e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWrapperWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWrapperWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlElementWrapper; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlElementWrapperWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWriter.java index c89073be8dc..f78d0c8eba1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlElement; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlElementWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementsWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementsWriter.java index 204c1eb6e89..d7e165bcb03 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementsWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlElementsWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlElements; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlElementsWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumValueWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumValueWriter.java index cc2e79259a9..5f22405a47c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumValueWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumValueWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlEnumValue; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlEnumValueWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumWriter.java index 93da5e0689d..814110e35a5 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlEnumWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlEnum; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlEnumWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDREFWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDREFWriter.java index ec5055dd65d..213d0b8bc99 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDREFWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDREFWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlIDREF; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlIDREFWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDWriter.java index 1046aa6b449..e6a0a74ad8c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlIDWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlID; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlIDWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlInlineBinaryDataWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlInlineBinaryDataWriter.java index 2bd4cc10fe8..d82eee23695 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlInlineBinaryDataWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlInlineBinaryDataWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlInlineBinaryData; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlInlineBinaryDataWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlJavaTypeAdapterWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlJavaTypeAdapterWriter.java index 05fc8f78c53..f749545771f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlJavaTypeAdapterWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlJavaTypeAdapterWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlJavaTypeAdapterWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlListWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlListWriter.java index 46a88b80b57..5444bd858c5 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlListWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlListWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlList; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlListWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMimeTypeWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMimeTypeWriter.java index e8b7b16ce40..2bf6dbbad95 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMimeTypeWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMimeTypeWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlMimeType; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlMimeTypeWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMixedWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMixedWriter.java index 43e9268fae7..9fb7ab246a8 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMixedWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlMixedWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlMixed; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlMixedWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlNsWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlNsWriter.java index f5892f33be6..e8d33c4b14a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlNsWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlNsWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlNs; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlNsWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRegistryWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRegistryWriter.java index 9be6184d2de..b964e91a41a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRegistryWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRegistryWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlRegistry; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlRegistryWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRootElementWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRootElementWriter.java index 743f979cfb6..1071c904f6a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRootElementWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlRootElementWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlRootElement; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlRootElementWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypeWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypeWriter.java index af4c9b962fe..7601f031b6c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypeWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypeWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlSchemaType; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlSchemaTypeWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypesWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypesWriter.java index d682b572084..2f0957eaa9b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypesWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaTypesWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlSchemaTypes; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlSchemaTypesWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaWriter.java index 5eaa83dcda6..05849e6532a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSchemaWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlSchema; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlSchemaWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSeeAlsoWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSeeAlsoWriter.java index 908f9d8c951..6b2037991d2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSeeAlsoWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlSeeAlsoWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlSeeAlso; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlSeeAlsoWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTransientWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTransientWriter.java index e3836020952..61bfb4dd5d3 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTransientWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTransientWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlTransient; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlTransientWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTypeWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTypeWriter.java index 8f252dec97f..05172dbd1a9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTypeWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlTypeWriter.java @@ -29,6 +29,11 @@ import javax.xml.bind.annotation.XmlType; import com.sun.codemodel.internal.JAnnotationWriter; import com.sun.codemodel.internal.JType; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlTypeWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlValueWriter.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlValueWriter.java index 3e43d63b53b..308b93c6003 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlValueWriter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/annotation/spec/XmlValueWriter.java @@ -28,6 +28,11 @@ package com.sun.tools.internal.xjc.generator.annotation.spec; import javax.xml.bind.annotation.XmlValue; import com.sun.codemodel.internal.JAnnotationWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface XmlValueWriter extends JAnnotationWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/bean/MessageBundle.properties b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/bean/MessageBundle.properties index aa1a7266ba8..abcc8c55853 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/bean/MessageBundle.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/generator/bean/MessageBundle.properties @@ -26,7 +26,7 @@ METHOD_COLLISION = \ The "{0}" method is defined on both "{1}" and "{2}" and is causing a collision. -# {0} - enumeration constant value (but something that couldn?t be translated to a valid java identifier e.g. starting special character, number, ..) e.g. Cannot derive a valid Java identifier from "5.6.0". Specify a customization to change the name. +# {0} - enumeration constant value (but something that couldn�t be translated to a valid java identifier e.g. starting special character, number, ..) e.g. Cannot derive a valid Java identifier from "5.6.0". Specify a customization to change the name. ERR_UNUSABLE_NAME = \ Cannot derive a valid Java identifier from "{0}". Specify a customization to change the name. diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CPropertyInfo.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CPropertyInfo.java index 53326ac1f64..9910526253b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CPropertyInfo.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CPropertyInfo.java @@ -29,6 +29,7 @@ import java.lang.annotation.Annotation; import java.util.Collection; import java.util.Map; +import javax.xml.XMLConstants; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; @@ -298,7 +299,7 @@ public abstract class CPropertyInfo implements PropertyInfo, CCust // this is anonymous type. can't have @XmlSchemaType return false; - if(!typeName.getNamespaceURI().equals(WellKnownNamespace.XML_SCHEMA)) + if(!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(typeName.getNamespaceURI())) // if we put application-defined type name, it will be undefined // by the time we generate a schema. return false; diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java index 4a622ae132b..62416b0d28d 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java @@ -25,6 +25,7 @@ package com.sun.tools.internal.xjc.model; +import javax.xml.XMLConstants; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; @@ -34,6 +35,7 @@ import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder; import com.sun.xml.internal.bind.v2.model.core.PropertyInfo; import com.sun.xml.internal.bind.v2.model.core.TypeRef; import com.sun.xml.internal.bind.v2.runtime.RuntimeUtil; +import com.sun.xml.internal.xsom.XSType; import com.sun.xml.internal.xsom.XmlString; import com.sun.xml.internal.xsom.XSElementDecl; import com.sun.istack.internal.Nullable; @@ -74,11 +76,34 @@ public final class CTypeRef implements TypeRef { } public static QName getSimpleTypeName(XSElementDecl decl) { - if(decl==null) return null; - QName typeName = null; - if(decl.getType().isSimpleType()) - typeName = BGMBuilder.getName(decl.getType()); - return typeName; + if(decl==null || !decl.getType().isSimpleType()) + return null; // null if not simple type + return resolveSimpleTypeName(decl.getType()); + } + + /** + * Recursively search for type name. + * + * This is needed to find correct type for refs like: + * + * + * + * + * + * + * + * + * + * + * @param declType given type + * @return simpleTypeName or null + */ + private static QName resolveSimpleTypeName(XSType declType) { + QName name = BGMBuilder.getName(declType); + if (name != null && !XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(name.getNamespaceURI())) + return resolveSimpleTypeName(declType.getBaseType()); + else + return name; } public CTypeRef(CNonElement type, QName elementName, QName typeName, boolean nillable, XmlString defaultValue) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/package-info.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/package-info.java index a9f9a24a46f..22bfb767745 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/package-info.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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 @@ -55,7 +55,3 @@ * */ package com.sun.tools.internal.xjc.model; - -import com.sun.xml.internal.xsom.XSComponent; - -import org.xml.sax.Locator; diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/AbstractReferenceFinderImpl.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/AbstractReferenceFinderImpl.java index 8155ffc56ca..f0ec687b927 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/AbstractReferenceFinderImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/AbstractReferenceFinderImpl.java @@ -25,29 +25,27 @@ package com.sun.tools.internal.xjc.reader.internalizer; -import java.io.IOException; -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; - import com.sun.istack.internal.SAXParseException2; - import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.XMLFilterImpl; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + /** * XMLFilter that finds references to other schema files from * SAX events. - * + *

    * This implementation is a base implementation for typical case * where we just need to look for a particular attribute which * contains an URL to another schema file. * - * @author - * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) + * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl { @@ -61,12 +59,9 @@ public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl { * IF the given element contains a reference to an external resource, * return its URL. * - * @param nsURI - * Namespace URI of the current element - * @param localName - * Local name of the current element - * @return - * It's OK to return a relative URL. + * @param nsURI Namespace URI of the current element + * @param localName Local name of the current element + * @return It's OK to return a relative URL. */ protected abstract String findExternalResource(String nsURI, String localName, Attributes atts); @@ -83,16 +78,21 @@ public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl { // absolutize URL. String lsi = locator.getSystemId(); String ref; - if (lsi.startsWith("jar:")) { - int bangIdx = lsi.indexOf('!'); - if (bangIdx > 0) { - ref = lsi.substring(0, bangIdx + 1) - + new URI(lsi.substring(bangIdx + 1)).resolve(new URI(relativeRef)).toString(); + URI relRefURI = new URI(relativeRef); + if (relRefURI.isAbsolute()) + ref = relativeRef; + else { + if (lsi.startsWith("jar:")) { + int bangIdx = lsi.indexOf('!'); + if (bangIdx > 0) { + ref = lsi.substring(0, bangIdx + 1) + + new URI(lsi.substring(bangIdx + 1)).resolve(new URI(relativeRef)).toString(); + } else { + ref = relativeRef; + } } else { - ref = relativeRef; + ref = new URI(lsi).resolve(new URI(relativeRef)).toString(); } - } else { - ref = new URI(lsi).resolve(new URI(relativeRef)).toString(); } // then parse this schema as well, @@ -121,6 +121,7 @@ public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl { throw spe; } } + private Locator locator; @Override @@ -128,4 +129,4 @@ public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl { super.setDocumentLocator(locator); this.locator = locator; } -}; +} diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/DOMForest.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/DOMForest.java index cdb3360a902..b31ae389454 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/DOMForest.java +++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/DOMForest.java @@ -25,18 +25,21 @@ package com.sun.tools.internal.xjc.reader.internalizer; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.sun.istack.internal.NotNull; +import com.sun.istack.internal.XMLStreamReaderToContentHandler; +import com.sun.tools.internal.xjc.ErrorReceiver; +import com.sun.tools.internal.xjc.Options; +import com.sun.tools.internal.xjc.reader.Const; +import com.sun.tools.internal.xjc.util.ErrorReceiverFilter; +import com.sun.xml.internal.bind.marshaller.DataWriter; +import com.sun.xml.internal.bind.v2.util.XmlFactory; +import com.sun.xml.internal.xsom.parser.JAXPParser; +import com.sun.xml.internal.xsom.parser.XMLParser; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.*; +import org.xml.sax.helpers.XMLFilterImpl; -import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -51,27 +54,13 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXSource; import javax.xml.validation.SchemaFactory; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.*; -import com.sun.istack.internal.NotNull; -import com.sun.istack.internal.XMLStreamReaderToContentHandler; -import com.sun.tools.internal.xjc.ErrorReceiver; -import com.sun.tools.internal.xjc.Options; -import com.sun.tools.internal.xjc.reader.Const; -import com.sun.tools.internal.xjc.util.ErrorReceiverFilter; -import com.sun.xml.internal.bind.marshaller.DataWriter; -import com.sun.xml.internal.bind.v2.util.XmlFactory; -import com.sun.xml.internal.xsom.parser.JAXPParser; -import com.sun.xml.internal.xsom.parser.XMLParser; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.ContentHandler; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLFilterImpl; +import static com.sun.xml.internal.bind.v2.util.XmlFactory.allowFileAccess; +import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; /** @@ -471,7 +460,7 @@ public final class DOMForest { } try { - sf.newSchema(sources.toArray(new SAXSource[0])); + allowFileAccess(sf, options.disableXmlSecurity).newSchema(sources.toArray(new SAXSource[0])); } catch (SAXException e) { // error should have been reported. } catch (RuntimeException re) { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Util.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Util.java index 3f98a6a821f..c6a077ebf42 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Util.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Util.java @@ -30,7 +30,7 @@ import java.util.logging.Logger; /** * @author Kohsuke Kawaguchi */ -public abstract class Util { +public final class Util { private Util() {} // no instanciation /** diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.java index 0632d97f6aa..17bcfdea789 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,8 @@ public enum Messages { NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS, // 1 arg INVALID_TYPE_IN_MAP, // 0args INVALID_JAXP_IMPLEMENTATION, // 1 arg + JAXP_SUPPORTED_PROPERTY, // 1 arg + JAXP_UNSUPPORTED_PROPERTY, // 1 arg ; private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName()); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.properties index d4043dd228b..98e2c8ab576 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/Messages.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -50,3 +50,9 @@ INVALID_TYPE_IN_MAP = \ INVALID_JAXP_IMPLEMENTATION = \ You are running with invalid JAXP api or implementation. JAXP api/implementation of version 1.3.1 (included in JDK6) or higher is required. In case you are using ant, make sure ant 1.7.0 or higher is used - older versions of ant contain JAXP api/impl version 1.2 (in xml-apis.jar). If you want to keep using older ant versions, you have to configure it to use higher the JAXP api/impl versions. + +JAXP_SUPPORTED_PROPERTY =\ + Property "{0}" is supported and has been successfully set by used JAXP implementation. + +JAXP_UNSUPPORTED_PROPERTY =\ + Property "{0}" is not supported by used JAXP implementation. diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/Init.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/Init.java index d0796ec997b..fd53efd4438 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/Init.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/Init.java @@ -25,7 +25,10 @@ package com.sun.xml.internal.bind.v2.model.annotation; - +/** + *

    Auto-generated, do not edit.

    + * + */ class Init { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlAttributeQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlAttributeQuick.java index 4caf7b2aa2d..a7dee028a92 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlAttributeQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlAttributeQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlAttribute; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlAttributeQuick extends Quick implements XmlAttribute diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementDeclQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementDeclQuick.java index 008fbf907a8..1bd5e5688a7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementDeclQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementDeclQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlElementDecl; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlElementDeclQuick extends Quick implements XmlElementDecl diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementQuick.java index 7db0a4b1368..b745944de1c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlElement; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlElementQuick extends Quick implements XmlElement diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefQuick.java index 5756f2fd2bf..dffbe66cc5e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlElementRef; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlElementRefQuick extends Quick implements XmlElementRef diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefsQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefsQuick.java index 294a233f34b..a5ef63bd1ea 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefsQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlElementRefsQuick.java @@ -29,6 +29,11 @@ import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRefs; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlElementRefsQuick extends Quick implements XmlElementRefs diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlEnumQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlEnumQuick.java index d2c7698af9a..540ce654498 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlEnumQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlEnumQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlEnum; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlEnumQuick extends Quick implements XmlEnum diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlRootElementQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlRootElementQuick.java index e52cfcc9fbe..fcf5eda3ee7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlRootElementQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlRootElementQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlRootElement; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlRootElementQuick extends Quick implements XmlRootElement diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaQuick.java index 1c4b782f922..f1862ba9eb1 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaQuick.java @@ -30,6 +30,11 @@ import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlSchema; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlSchemaQuick extends Quick implements XmlSchema diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaTypeQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaTypeQuick.java index ad513f2f897..58f6ecda4f0 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaTypeQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlSchemaTypeQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlSchemaType; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlSchemaTypeQuick extends Quick implements XmlSchemaType diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTransientQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTransientQuick.java index b0bf8f52411..0200bad8e26 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTransientQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTransientQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlTransient; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlTransientQuick extends Quick implements XmlTransient diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTypeQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTypeQuick.java index 3e33cd54878..abb8541bed9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTypeQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlTypeQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlType; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlTypeQuick extends Quick implements XmlType diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlValueQuick.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlValueQuick.java index a6b391911b4..fdc0cb24da4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlValueQuick.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/annotation/XmlValueQuick.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.model.annotation; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlValue; + +/** + *

    Auto-generated, do not edit.

    + * + */ final class XmlValueQuick extends Quick implements XmlValue diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/core/package-info.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/core/package-info.java index 1b6ad95b223..1ac8d1eb48c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/core/package-info.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/core/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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 @@ -59,10 +59,6 @@ @XmlSchema(namespace="http://jaxb.dev.java.net/xjc/model",elementFormDefault=QUALIFIED) package com.sun.xml.internal.bind.v2.model.core; -import java.lang.reflect.Type; -import java.lang.reflect.Method; -import java.lang.reflect.Field; - import javax.xml.bind.annotation.XmlSchema; import static javax.xml.bind.annotation.XmlNsForm.QUALIFIED; diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java index f1a28b6a729..4a2c160fa8b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java @@ -91,6 +91,9 @@ import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext; import com.sun.xml.internal.bind.v2.util.ByteArrayOutputStreamEx; import com.sun.xml.internal.bind.v2.util.DataSourceSource; +import java.util.logging.Logger; +import com.sun.xml.internal.bind.Util; +import java.util.logging.Level; import org.xml.sax.SAXException; @@ -105,6 +108,8 @@ import org.xml.sax.SAXException; public abstract class RuntimeBuiltinLeafInfoImpl extends BuiltinLeafInfoImpl implements RuntimeBuiltinLeafInfo, Transducer { + private static final Logger logger = Util.getClassLogger(); + private RuntimeBuiltinLeafInfoImpl(Class type, QName... typeNames) { super(type, typeNames); LEAVES.put(type,this); @@ -196,6 +201,7 @@ public abstract class RuntimeBuiltinLeafInfoImpl extends BuiltinLeafInfoImpl< public static final List> builtinBeanInfos; public static final String MAP_ANYURI_TO_URI = "mapAnyUriToUri"; + public static final String USE_OLD_GMONTH_MAPPING = "jaxb.ri.useOldGmonthMapping"; static { @@ -960,7 +966,14 @@ public abstract class RuntimeBuiltinLeafInfoImpl extends BuiltinLeafInfoImpl< m.put(DatatypeConstants.DATETIME, "%Y-%M-%DT%h:%m:%s"+ "%z"); m.put(DatatypeConstants.DATE, "%Y-%M-%D" +"%z"); m.put(DatatypeConstants.TIME, "%h:%m:%s"+ "%z"); - m.put(DatatypeConstants.GMONTH, "--%M--%z"); + if (System.getProperty(USE_OLD_GMONTH_MAPPING) == null) { + m.put(DatatypeConstants.GMONTH, "--%M%z"); // E2-12 Error. http://www.w3.org/2001/05/xmlschema-errata#e2-12 + } else { // backw. compatibility + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, "Old GMonth mapping used."); + } + m.put(DatatypeConstants.GMONTH, "--%M--%z"); + } m.put(DatatypeConstants.GDAY, "---%D" + "%z"); m.put(DatatypeConstants.GYEAR, "%Y" + "%z"); m.put(DatatypeConstants.GYEARMONTH, "%Y-%M" + "%z"); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/package-info.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/package-info.java index bc2975af1e8..b52f12cca07 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/package-info.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/package-info.java @@ -180,7 +180,3 @@ * @ArchitectureDocument */ package com.sun.xml.internal.bind.v2; - -import javax.xml.bind.JAXBContext; - -import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeAdapter.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeAdapter.java index d3afb47615c..252f0ea6abd 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeAdapter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/BridgeAdapter.java @@ -88,13 +88,11 @@ final class BridgeAdapter extends InternalBridge { private OnWire adaptM(Marshaller m,InMemory v) throws JAXBException { XMLSerializer serializer = ((MarshallerImpl)m).serializer; - serializer.setThreadAffinity(); serializer.pushCoordinator(); try { return _adaptM(serializer, v); } finally { serializer.popCoordinator(); - serializer.resetThreadAffinity(); } } @@ -132,7 +130,6 @@ final class BridgeAdapter extends InternalBridge { private @NotNull InMemory adaptU(Unmarshaller _u, OnWire v) throws JAXBException { UnmarshallerImpl u = (UnmarshallerImpl) _u; XmlAdapter a = u.coordinator.getAdapter(adapter); - u.coordinator.setThreadAffinity(); u.coordinator.pushCoordinator(); try { return a.unmarshal(v); @@ -140,7 +137,6 @@ final class BridgeAdapter extends InternalBridge { throw new UnmarshalException(e); } finally { u.coordinator.popCoordinator(); - u.coordinator.resetThreadAffinity(); } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Coordinator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Coordinator.java index a76532ad7d0..6e66188b9f3 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Coordinator.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Coordinator.java @@ -94,75 +94,37 @@ public abstract class Coordinator implements ErrorHandler, ValidationEventHandle return adapters.containsKey(type); } + // this much is necessary to avoid calling get and set twice when we push. + private static final ThreadLocal activeTable = new ThreadLocal(); + /** * The {@link Coordinator} in charge before this {@link Coordinator}. */ - private Object old; - - /** - * A 'pointer' to a {@link Coordinator} that keeps track of the currently active {@link Coordinator}. - * Having this improves the runtime performance. - */ - private Object[] table; - - /** - * When we set {@link #table} to null, record who did it. - * This is for trouble-shooting a possible concurrency issue reported at: - * http://forums.java.net/jive/thread.jspa?threadID=15132 - */ - public Exception guyWhoSetTheTableToNull; - - /** - * Associates this {@link Coordinator} with the current thread. - * Should be called at the very beginning of the episode. - */ - protected final void setThreadAffinity() { - table = activeTable.get(); - assert table!=null; - } - - /** - * Dis-associate this {@link Coordinator} with the current thread. - * Sohuld be called at the end of the episode to avoid memory leak. - */ - protected final void resetThreadAffinity() { - if (activeTable != null) { - activeTable.remove(); - } - if(debugTableNPE) - guyWhoSetTheTableToNull = new Exception(); // remember that we set it to null - table = null; - } + private Coordinator old; /** * Called whenever an execution flow enters the realm of this {@link Coordinator}. */ protected final void pushCoordinator() { - old = table[0]; - table[0] = this; + old = activeTable.get(); + activeTable.set(this); } /** * Called whenever an execution flow exits the realm of this {@link Coordinator}. */ protected final void popCoordinator() { - assert table[0]==this; - table[0] = old; + if (old != null) + activeTable.set(old); + else + activeTable.remove(); old = null; // avoid memory leak } public static Coordinator _getInstance() { - return (Coordinator) activeTable.get()[0]; + return activeTable.get(); } - // this much is necessary to avoid calling get and set twice when we push. - private static final ThreadLocal activeTable = new ThreadLocal() { - @Override - public Object[] initialValue() { - return new Object[1]; - } - }; - // // // ErrorHandler implementation @@ -207,13 +169,4 @@ public abstract class Coordinator implements ErrorHandler, ValidationEventHandle throw saxException; } } - - public static boolean debugTableNPE; - - static { - try { - debugTableNPE = Boolean.getBoolean(Coordinator.class.getName()+".debugTableNPE"); - } catch (SecurityException t) { - } - } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/XMLSerializer.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/XMLSerializer.java index 4c14187a7ff..941b5684275 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/XMLSerializer.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/XMLSerializer.java @@ -812,7 +812,6 @@ public final class XMLSerializer extends Coordinator { * Similar to 'schemaLocation' but this one works for xsi:noNamespaceSchemaLocation */ public void startDocument(XmlOutput out,boolean fragment,String schemaLocation,String noNsSchemaLocation) throws IOException, SAXException, XMLStreamException { - setThreadAffinity(); pushCoordinator(); nsContext.reset(); nse = nsContext.getCurrent(); @@ -841,7 +840,6 @@ public final class XMLSerializer extends Coordinator { out = null; clearCurrentProperty(); popCoordinator(); - resetThreadAffinity(); } /** diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerBoolean.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerBoolean.java index f0a0b4e475c..853b2373298 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerBoolean.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerBoolean.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerBoolean extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerCharacter.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerCharacter.java index 3a0ab85c3c1..c50f53b0251 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerCharacter.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerCharacter.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerCharacter extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerDouble.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerDouble.java index c85a92672a7..bd6e03cdc5c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerDouble.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerDouble.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerDouble extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerFloat.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerFloat.java index b5bd7e4eec3..5ced3035d6b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerFloat.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerFloat.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerFloat extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerInteger.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerInteger.java index cdb8e58c4cd..98a075461ed 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerInteger.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerInteger.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerInteger extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerLong.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerLong.java index 5598ca66bb2..4412b7ed9d6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerLong.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerLong.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerLong extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerShort.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerShort.java index ddc61a7856d..8493f8465ba 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerShort.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/PrimitiveArrayListerShort.java @@ -30,10 +30,13 @@ import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; /** * {@link Lister} for primitive type arrays. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * B y t e ArrayLister is used as the master to generate the rest of the - * lister classes. Do not modify the generated copies. + * B y t e ArrayLister is used as the master to generate the rest of the + * lister classes. Do not modify the generated copies. + *

    */ final class PrimitiveArrayListerShort extends Lister { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Boolean.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Boolean.java index 28cdee67715..e1e36db9561 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Boolean.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Boolean.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Boolean extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Character.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Character.java index 3ec52cf0063..171b42f772a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Character.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Character.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for char fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Character extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Double.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Double.java index 9ef4c1f41bd..be024e9a4d7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Double.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Double.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for double fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Double extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Float.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Float.java index a7651a646b3..d5e1af13623 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Float.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Float.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for float fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Float extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Integer.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Integer.java index db6cb8eb0dc..467fa79ae81 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Integer.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Integer.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for int fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Integer extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Long.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Long.java index 60adf9d4c4b..1980cb33c0d 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Long.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Long.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for long fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Long extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Short.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Short.java index 84315f634e4..49a000aea49 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Short.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/FieldAccessor_Short.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for short fields. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the FieldAccessors are generated from FieldAccessor_B y t e - * + * All the FieldAccessors are generated from FieldAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class FieldAccessor_Short extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Boolean.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Boolean.java index 8176a657c41..07fde9b0938 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Boolean.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Boolean.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Boolean extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Character.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Character.java index 92c94901f7e..856d35508ad 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Character.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Character.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Character extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Double.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Double.java index f7d9d873231..4b12972bee9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Double.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Double.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Double extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Float.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Float.java index 9b6f0f2142a..54d9af2cf78 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Float.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Float.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Float extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Integer.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Integer.java index 54462b3e3d6..8b5ea50f39c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Integer.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Integer.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Integer extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Long.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Long.java index 82beed25f98..f7d2c2617b4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Long.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Long.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Long extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Short.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Short.java index 5828e099759..f91bc0b75a6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Short.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/MethodAccessor_Short.java @@ -29,10 +29,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; /** * Template {@link Accessor} for boolean getter/setter. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the MethodAccessors are generated from MethodAccessor_B y t e - * + * All the MethodAccessors are generated from MethodAccessor_B y t e + *

    * @author Kohsuke Kawaguchi */ public class MethodAccessor_Short extends Accessor { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java index 38242c9f9fe..54f7dbe6c87 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Double.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a double field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java index 5bd8d6281f8..6b67f61e5c2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Float.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a float field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java index 367510fcaac..beb68e56668 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Long.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a long field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java index 3713627f988..437f91175ba 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_field_Short.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a short field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java index c9fb036d79c..f7cd6ccdda7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Boolean.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a boolean field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java index 958d998c0b1..fe87c4bb000 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Double.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a double field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java index 9ca22b97171..16a51cfddb8 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Float.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a float field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java index 2a25f304674..3ca907058a9 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Long.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a long field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java index b4b567ad09b..f4a50ef1dfe 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/TransducedAccessor_method_Short.java @@ -31,10 +31,12 @@ import com.sun.xml.internal.bind.v2.runtime.reflect.DefaultTransducedAccessor; /** * Template {@link TransducedAccessor} for a short field. - * + *

    + * Auto-generated, do not edit. + *

    *

    - * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e - * + * All the TransducedAccessor_field are generated from TransducedAccessor_field_B y t e + *

    * @author Kohsuke Kawaguchi * * @see TransducedAccessor#get diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java index ef75619f986..9c9ccea3ffc 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Loader.java @@ -94,11 +94,15 @@ public abstract class Loader { @SuppressWarnings({"StringEquality"}) protected final void reportUnexpectedChildElement(TagName ea, boolean canRecover) throws SAXException { - if(canRecover && !UnmarshallingContext.getInstance().parent.hasEventHandler()) + if (canRecover) { // this error happens particurly often (when input documents contain a lot of unexpected elements to be ignored), // so don't bother computing all the messages and etc if we know that // there's no event handler to receive the error in the end. See #286 - return; + UnmarshallingContext context = UnmarshallingContext.getInstance(); + if (!context.parent.hasEventHandler() // is somebody listening? + || !context.shouldErrorBeReported()) // should we report error? + return; + } if(ea.uri!=ea.uri.intern() || ea.local!=ea.local.intern()) reportError(Messages.UNINTERNED_STRINGS.format(), canRecover ); else diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.java index f37be69b4b9..2390f67fcdd 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.java @@ -40,6 +40,7 @@ enum Messages { UNRECOGNIZED_TYPE_NAME_MAYBE, // 2 args UNABLE_TO_CREATE_MAP, // 1 arg UNINTERNED_STRINGS, // no args + ERRORS_LIMIT_EXCEEDED, // no arg ; private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName()); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.properties b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.properties index e6d4960f657..b4eb4cc5097 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.properties +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/Messages.properties @@ -50,3 +50,7 @@ UNABLE_TO_CREATE_MAP = \ UNINTERNED_STRINGS = \ Namespace URIs and local names to the unmarshaller needs to be interned. + +# user have to set Logger.getLogger("com.sun.xml.internal.bind").setLevel(Level.FINEST) +ERRORS_LIMIT_EXCEEDED = \ + Errors limit exceeded. To receive all errors set 'com.sun.xml.internal.bind' logger to FINEST level. diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java index 7695de9ee1f..44998166542 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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 @@ -25,11 +25,14 @@ package com.sun.xml.internal.bind.v2.runtime.unmarshaller; +import com.sun.xml.internal.bind.Util; import javax.xml.bind.JAXBException; import javax.xml.bind.UnmarshallerHandler; import com.sun.xml.internal.bind.WhiteSpaceProcessor; import com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl; +import java.util.logging.Level; +import java.util.logging.Logger; import org.xml.sax.Attributes; import org.xml.sax.Locator; @@ -44,6 +47,8 @@ public final class SAXConnector implements UnmarshallerHandler { private LocatorEx loc; + private static final Logger logger = Util.getClassLogger(); + /** * SAX may fire consecutive characters event, but we don't allow it. * so use this buffer to perform buffering. @@ -56,6 +61,7 @@ public final class SAXConnector implements UnmarshallerHandler { private static final class TagNameImpl extends TagName { String qname; + @Override public String getQname() { return qname; } @@ -76,6 +82,7 @@ public final class SAXConnector implements UnmarshallerHandler { this.loc = externalLocator; } + @Override public Object getResult() throws JAXBException, IllegalStateException { return context.getResult(); } @@ -84,6 +91,7 @@ public final class SAXConnector implements UnmarshallerHandler { return context; } + @Override public void setDocumentLocator(final Locator locator) { if(loc!=null) return; // we already have an external locator. ignore. @@ -91,23 +99,43 @@ public final class SAXConnector implements UnmarshallerHandler { this.loc = new LocatorExWrapper(locator); } + @Override public void startDocument() throws SAXException { + if (logger.isLoggable(Level.FINER)) { + logger.log(Level.FINER, "SAXConnector.startDocument"); + } next.startDocument(loc,null); } + @Override public void endDocument() throws SAXException { + if (logger.isLoggable(Level.FINER)) { + logger.log(Level.FINER, "SAXConnector.endDocument"); + } next.endDocument(); } + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { + if (logger.isLoggable(Level.FINER)) { + logger.log(Level.FINER, "SAXConnector.startPrefixMapping: {0}:{1}", new Object[]{prefix, uri}); + } next.startPrefixMapping(prefix,uri); } + @Override public void endPrefixMapping(String prefix) throws SAXException { + if (logger.isLoggable(Level.FINER)) { + logger.log(Level.FINER, "SAXConnector.endPrefixMapping: {0}", new Object[]{prefix}); + } next.endPrefixMapping(prefix); } + @Override public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException { + if (logger.isLoggable(Level.FINER)) { + logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}, attrs: {3}", new Object[]{uri, local, qname, atts}); + } // work gracefully with misconfigured parsers that don't support namespaces if( uri==null || uri.length()==0 ) uri=""; @@ -135,7 +163,11 @@ public final class SAXConnector implements UnmarshallerHandler { next.startElement(tagName); } + @Override public void endElement(String uri, String localName, String qName) throws SAXException { + if (logger.isLoggable(Level.FINER)) { + logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}", new Object[]{uri, localName, qName}); + } processText(false); tagName.uri = uri; tagName.local = localName; @@ -144,19 +176,29 @@ public final class SAXConnector implements UnmarshallerHandler { } + @Override public final void characters( char[] buf, int start, int len ) { + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "SAXConnector.characters: {0}", buf); + } if( predictor.expectText() ) buffer.append(buf,start,len); } + @Override public final void ignorableWhitespace( char[] buf, int start, int len ) { + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "SAXConnector.characters{0}", buf); + } characters(buf,start,len); } + @Override public void processingInstruction(String target, String data) { // nop } + @Override public void skippedEntity(String name) { // nop } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java index 7362acc68c0..35519196193 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, 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 @@ -35,6 +35,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.xml.XMLConstants; import javax.xml.bind.JAXBElement; @@ -51,6 +53,7 @@ import com.sun.istack.internal.NotNull; import com.sun.istack.internal.Nullable; import com.sun.istack.internal.SAXParseException2; import com.sun.xml.internal.bind.IDResolver; +import com.sun.xml.internal.bind.Util; import com.sun.xml.internal.bind.api.AccessorException; import com.sun.xml.internal.bind.api.ClassResolver; import com.sun.xml.internal.bind.unmarshaller.InfosetScanner; @@ -59,6 +62,8 @@ import com.sun.xml.internal.bind.v2.runtime.AssociationMap; import com.sun.xml.internal.bind.v2.runtime.Coordinator; import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo; +import java.util.logging.Level; +import java.util.logging.Logger; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; @@ -76,6 +81,8 @@ import org.xml.sax.helpers.LocatorImpl; public final class UnmarshallingContext extends Coordinator implements NamespaceContext, ValidationEventHandler, ErrorHandler, XmlVisitor, XmlVisitor.TextPredictor { + private static final Logger logger = Logger.getLogger(UnmarshallingContext.class.getName()); + /** * Root state. */ @@ -176,6 +183,14 @@ public final class UnmarshallingContext extends Coordinator */ public @Nullable ClassLoader classLoader; + /** + * The variable introduced to avoid reporting n^10 similar errors. + * After error is reported counter is decremented. When it became 0 - errors should not be reported any more. + * + * volatile is required to ensure that concurrent threads will see changed value + */ + private static volatile int errorsCounter = 10; + /** * State information for each element. */ @@ -260,21 +275,32 @@ public final class UnmarshallingContext extends Coordinator return UnmarshallingContext.this; } + @SuppressWarnings("LeakingThisInConstructor") private State(State prev) { this.prev = prev; - if(prev!=null) + if (prev!=null) { prev.next = this; + } } private void push() { - if(next==null) + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "State.push"); + } + if (next==null) { + assert current == this; allocateMoreStates(); + } + nil = false; State n = next; n.numNsDecl = nsLen; current = n; } private void pop() { + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "State.pop"); + } assert prev!=null; loader = null; nil = false; @@ -381,8 +407,9 @@ public final class UnmarshallingContext extends Coordinator assert current.next==null; State s = current; - for( int i=0; i<8; i++ ) + for (int i=0; i<8; i++) { s = new State(s); + } } public void clearStates() { @@ -436,6 +463,7 @@ public final class UnmarshallingContext extends Coordinator } } + @Override public void startDocument(LocatorEx locator, NamespaceContext nsContext) throws SAXException { if(locator!=null) this.locator = locator; @@ -449,8 +477,6 @@ public final class UnmarshallingContext extends Coordinator isUnmarshalInProgress = true; nsLen=0; - setThreadAffinity(); - if(expectedType!=null) root.loader = EXPECTED_TYPE_ROOT_LOADER; else @@ -459,6 +485,7 @@ public final class UnmarshallingContext extends Coordinator idResolver.startDocument(this); } + @Override public void startElement(TagName tagName) throws SAXException { pushCoordinator(); try { @@ -486,6 +513,7 @@ public final class UnmarshallingContext extends Coordinator current.loader.startElement(current,tagName); } + @Override public void text(CharSequence pcdata) throws SAXException { State cur = current; pushCoordinator(); @@ -502,6 +530,7 @@ public final class UnmarshallingContext extends Coordinator } } + @Override public final void endElement(TagName tagName) throws SAXException { pushCoordinator(); try { @@ -526,6 +555,7 @@ public final class UnmarshallingContext extends Coordinator } } + @Override public void endDocument() throws SAXException { runPatchers(); idResolver.endDocument(); @@ -537,14 +567,13 @@ public final class UnmarshallingContext extends Coordinator // at the successful completion, scope must be all closed assert root==current; - - resetThreadAffinity(); } /** * You should be always calling this through {@link TextPredictor}. */ @Deprecated + @Override public boolean expectText() { return current.loader.expectText; } @@ -553,10 +582,12 @@ public final class UnmarshallingContext extends Coordinator * You should be always getting {@link TextPredictor} from {@link XmlVisitor}. */ @Deprecated + @Override public TextPredictor getPredictor() { return this; } + @Override public UnmarshallingContext getContext() { return this; } @@ -650,6 +681,7 @@ public final class UnmarshallingContext extends Coordinator event.getLinkedException() ) ); } + @Override public boolean handleEvent(ValidationEvent event) { try { // if the handler says "abort", we will not return the object. @@ -680,6 +712,7 @@ public final class UnmarshallingContext extends Coordinator handleEvent(new ValidationEventImpl(ValidationEvent.ERROR,msg,locator.getLocation())); } + @Override protected ValidationEventLocator getLocation() { return locator.getLocation(); } @@ -801,6 +834,7 @@ public final class UnmarshallingContext extends Coordinator private String[] nsBind = new String[16]; private int nsLen=0; + @Override public void startPrefixMapping( String prefix, String uri ) { if(nsBind.length==nsLen) { // expand the buffer @@ -811,6 +845,7 @@ public final class UnmarshallingContext extends Coordinator nsBind[nsLen++] = prefix; nsBind[nsLen++] = uri; } + @Override public void endPrefixMapping( String prefix ) { nsLen-=2; } @@ -868,6 +903,7 @@ public final class UnmarshallingContext extends Coordinator // NamespaceContext2 implementation // + @Override public Iterator getPrefixes(String uri) { // TODO: could be implemented much faster // wrap it into unmodifiable list so that the remove method @@ -899,6 +935,7 @@ public final class UnmarshallingContext extends Coordinator return a; } + @Override public String getPrefix(String uri) { if( uri==null ) throw new IllegalArgumentException(); @@ -919,6 +956,7 @@ public final class UnmarshallingContext extends Coordinator return null; } + @Override public String getNamespaceURI(String prefix) { if (prefix == null) throw new IllegalArgumentException(); @@ -1059,6 +1097,7 @@ public final class UnmarshallingContext extends Coordinator return getInstance().getJAXBContext().getValidRootNames(); } + @Override public void receive(State state, Object o) { if(state.backup!=null) { ((JAXBElement)state.backup).setValue(o); @@ -1095,6 +1134,7 @@ public final class UnmarshallingContext extends Coordinator state.loader = new XsiNilLoader(context.expectedType.getLoader(null,true)); } + @Override public void receive(State state, Object o) { JAXBElement e = (JAXBElement)state.target; e.setValue(o); @@ -1233,4 +1273,27 @@ public final class UnmarshallingContext extends Coordinator return null; } + /** + * Based on current {@link Logger} {@link Level} and errorCounter value determines if error should be reported. + * + * If the method called and return true it is expected that error will be reported. And that's why + * errorCounter is automatically decremented during the check. + * + * NOT THREAD SAFE!!! In case of heave concurrency access several additional errors could be reported. It's not expected to be the + * problem. Otherwise add synchronization here. + * + * @return true in case if {@link Level#FINEST} is set OR we haven't exceed errors reporting limit. + */ + public boolean shouldErrorBeReported() throws SAXException { + if (logger.isLoggable(Level.FINEST)) + return true; + + if (errorsCounter >= 0) { + --errorsCounter; + if (errorsCounter == 0) // it's possible to miss this because of concurrency. If required add synchronization here + handleEvent(new ValidationEventImpl(ValidationEvent.WARNING, Messages.ERRORS_LIMIT_EXCEEDED.format(), + getLocator().getLocation(), null), true); + } + return errorsCounter >= 0; + } } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java index b577c3c498f..f35a3f521ea 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/XsiTypeLoader.java @@ -92,12 +92,15 @@ public class XsiTypeLoader extends Loader { return defaultBeanInfo; beanInfo = context.getJAXBContext().getGlobalType(type); - if(beanInfo==null) { - String nearest = context.getJAXBContext().getNearestTypeName(type); - if(nearest!=null) - reportError(Messages.UNRECOGNIZED_TYPE_NAME_MAYBE.format(type,nearest),true); - else - reportError(Messages.UNRECOGNIZED_TYPE_NAME.format(type),true); + if(beanInfo==null) { // let's report an error + if (context.parent.hasEventHandler() // is somebody listening? + && context.shouldErrorBeReported()) { // should we report error? + String nearest = context.getJAXBContext().getNearestTypeName(type); + if(nearest!=null) + reportError(Messages.UNRECOGNIZED_TYPE_NAME_MAYBE.format(type,nearest),true); + else + reportError(Messages.UNRECOGNIZED_TYPE_NAME.format(type),true); + } } // TODO: resurrect the following check // else diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotated.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotated.java index 4b9165cd9b1..c60dde2d321 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotated.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotated.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface Annotated extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotation.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotation.java index 75c93a82f1b..795f12573f6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotation.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Annotation.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("annotation") public interface Annotation extends TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Any.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Any.java index 6765b2d61c5..7df5329c0cb 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Any.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Any.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("any") public interface Any extends Occurs, Wildcard, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Appinfo.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Appinfo.java index 028d505219b..b31d3092b37 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Appinfo.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Appinfo.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("appinfo") public interface Appinfo extends TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttrDecls.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttrDecls.java index 633ccad8c78..53c7ec260bb 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttrDecls.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttrDecls.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface AttrDecls extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttributeType.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttributeType.java index 1a0169d70e2..4e0e2f6ce75 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttributeType.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/AttributeType.java @@ -29,6 +29,11 @@ import javax.xml.namespace.QName; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface AttributeType extends SimpleTypeHost, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexContent.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexContent.java index 27e826e0f71..33eddd83397 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexContent.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexContent.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("complexContent") public interface ComplexContent extends Annotated, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexExtension.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexExtension.java index c80b11ce90e..b141601dd0c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexExtension.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexExtension.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("extension") public interface ComplexExtension extends AttrDecls, ExtensionType, TypeDefParticle, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexRestriction.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexRestriction.java index d08f1157c6e..7919fc43885 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexRestriction.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexRestriction.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("restriction") public interface ComplexRestriction extends Annotated, AttrDecls, TypeDefParticle, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexType.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexType.java index 23b7a2802c2..cda5e014879 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexType.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexType.java @@ -29,24 +29,29 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("complexType") public interface ComplexType extends Annotated, ComplexTypeModel, TypedXmlWriter { - @XmlAttribute("final") - public ComplexType _final(String value); - @XmlAttribute("final") public ComplexType _final(String[] value); - @XmlAttribute - public ComplexType block(String value); + @XmlAttribute("final") + public ComplexType _final(String value); @XmlAttribute public ComplexType block(String[] value); + @XmlAttribute + public ComplexType block(String value); + @XmlAttribute("abstract") public ComplexType _abstract(boolean value); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeHost.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeHost.java index 3ac98c52239..e0d02068e77 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeHost.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeHost.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface ComplexTypeHost extends TypeHost, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeModel.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeModel.java index afdcf0da125..dc8493ca6c5 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeModel.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ComplexTypeModel.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface ComplexTypeModel extends AttrDecls, TypeDefParticle, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Documentation.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Documentation.java index 7661cc53b6c..f8abb212326 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Documentation.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Documentation.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("documentation") public interface Documentation extends TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Element.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Element.java index 20e2e91bb41..29ea473a34b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Element.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Element.java @@ -29,6 +29,11 @@ import javax.xml.namespace.QName; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface Element extends Annotated, ComplexTypeHost, FixedOrDefault, SimpleTypeHost, TypedXmlWriter { @@ -38,10 +43,10 @@ public interface Element public Element type(QName value); @XmlAttribute - public Element block(String value); + public Element block(String[] value); @XmlAttribute - public Element block(String[] value); + public Element block(String value); @XmlAttribute public Element nillable(boolean value); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExplicitGroup.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExplicitGroup.java index b8a83d574ff..60b324a9655 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExplicitGroup.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExplicitGroup.java @@ -27,6 +27,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface ExplicitGroup extends Annotated, NestedParticle, Occurs, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExtensionType.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExtensionType.java index 13da8c041a1..145fcb6f55f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExtensionType.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/ExtensionType.java @@ -29,6 +29,11 @@ import javax.xml.namespace.QName; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface ExtensionType extends Annotated, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/FixedOrDefault.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/FixedOrDefault.java index 74a2007f767..5e47900a3c4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/FixedOrDefault.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/FixedOrDefault.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface FixedOrDefault extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Import.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Import.java index ac5a24ca9e1..d842c031d10 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Import.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Import.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("import") public interface Import extends Annotated, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/List.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/List.java index 93517581d48..8cf2dafb1f2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/List.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/List.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("list") public interface List extends Annotated, SimpleTypeHost, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalAttribute.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalAttribute.java index 4cde3d0f4e2..6aab764d384 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalAttribute.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalAttribute.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("attribute") public interface LocalAttribute extends Annotated, AttributeType, FixedOrDefault, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalElement.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalElement.java index ef28b4539e5..277b127f7ab 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalElement.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/LocalElement.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("element") public interface LocalElement extends Element, Occurs, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NestedParticle.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NestedParticle.java index f3a467279f3..3a03e478558 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NestedParticle.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NestedParticle.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface NestedParticle extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NoFixedFacet.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NoFixedFacet.java index 8e4f91a22d7..0f357fa431b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NoFixedFacet.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/NoFixedFacet.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface NoFixedFacet extends Annotated, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Occurs.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Occurs.java index eab4228a471..a1a06dca0f4 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Occurs.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Occurs.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface Occurs extends TypedXmlWriter { @@ -36,10 +41,10 @@ public interface Occurs @XmlAttribute public Occurs minOccurs(int value); - @XmlAttribute - public Occurs maxOccurs(int value); - @XmlAttribute public Occurs maxOccurs(String value); + @XmlAttribute + public Occurs maxOccurs(int value); + } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Redefinable.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Redefinable.java index 0b1e3795512..6f1efab7180 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Redefinable.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Redefinable.java @@ -27,6 +27,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface Redefinable extends ComplexTypeHost, SimpleTypeHost, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Schema.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Schema.java index f5dd58071c0..d69edfffe8b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Schema.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Schema.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("schema") public interface Schema extends SchemaTop, TypedXmlWriter @@ -56,18 +61,18 @@ public interface Schema @XmlAttribute public Schema attributeFormDefault(String value); - @XmlAttribute - public Schema blockDefault(String value); - @XmlAttribute public Schema blockDefault(String[] value); @XmlAttribute - public Schema finalDefault(String value); + public Schema blockDefault(String value); @XmlAttribute public Schema finalDefault(String[] value); + @XmlAttribute + public Schema finalDefault(String value); + @XmlAttribute public Schema version(String value); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SchemaTop.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SchemaTop.java index 4f081655d28..636aa26964b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SchemaTop.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SchemaTop.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface SchemaTop extends Redefinable, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleContent.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleContent.java index aa97834c847..b8c4d680f0c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleContent.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleContent.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("simpleContent") public interface SimpleContent extends Annotated, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleDerivation.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleDerivation.java index 6750c8ba937..9f5eed6d56b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleDerivation.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleDerivation.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface SimpleDerivation extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleExtension.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleExtension.java index aad7b63beaf..5ee557f699b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleExtension.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleExtension.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("extension") public interface SimpleExtension extends AttrDecls, ExtensionType, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestriction.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestriction.java index 4350e0f1513..84027ac24ec 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestriction.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestriction.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("restriction") public interface SimpleRestriction extends Annotated, AttrDecls, SimpleRestrictionModel, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestrictionModel.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestrictionModel.java index cbcaa7ba32a..04c2d42cf79 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestrictionModel.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleRestrictionModel.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface SimpleRestrictionModel extends SimpleTypeHost, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleType.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleType.java index 676aa6c68bc..2fed7d4ef6c 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleType.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleType.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("simpleType") public interface SimpleType extends Annotated, SimpleDerivation, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleTypeHost.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleTypeHost.java index b1db7aedc5f..1957ec4aa3f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleTypeHost.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/SimpleTypeHost.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface SimpleTypeHost extends TypeHost, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelAttribute.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelAttribute.java index 18a0d59ade4..324029f3386 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelAttribute.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelAttribute.java @@ -29,6 +29,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("attribute") public interface TopLevelAttribute extends Annotated, AttributeType, FixedOrDefault, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelElement.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelElement.java index 86af9f71f95..ad737c6224f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelElement.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TopLevelElement.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("element") public interface TopLevelElement extends Element, TypedXmlWriter @@ -37,10 +42,10 @@ public interface TopLevelElement @XmlAttribute("final") - public TopLevelElement _final(String value); + public TopLevelElement _final(String[] value); @XmlAttribute("final") - public TopLevelElement _final(String[] value); + public TopLevelElement _final(String value); @XmlAttribute("abstract") public TopLevelElement _abstract(boolean value); diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeDefParticle.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeDefParticle.java index 10b2486fc84..9b826fb075a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeDefParticle.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeDefParticle.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface TypeDefParticle extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeHost.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeHost.java index 3cbe692627b..a3443ac859b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeHost.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/TypeHost.java @@ -27,6 +27,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface TypeHost extends TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Union.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Union.java index 5878c937266..077895db2d6 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Union.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Union.java @@ -30,6 +30,11 @@ import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; import com.sun.xml.internal.txw2.annotation.XmlElement; +/** + *

    + * Auto-generated, do not edit. + *

    + */ @XmlElement("union") public interface Union extends Annotated, SimpleTypeHost, TypedXmlWriter diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Wildcard.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Wildcard.java index 1aa7c49837d..37a49e07532 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Wildcard.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/xmlschema/Wildcard.java @@ -28,6 +28,11 @@ package com.sun.xml.internal.bind.v2.schemagen.xmlschema; import com.sun.xml.internal.txw2.TypedXmlWriter; import com.sun.xml.internal.txw2.annotation.XmlAttribute; +/** + *

    + * Auto-generated, do not edit. + *

    + */ public interface Wildcard extends Annotated, TypedXmlWriter { diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/EditDistance.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/EditDistance.java index 36eba4d00ed..b2c82b5cd07 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/EditDistance.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/EditDistance.java @@ -25,8 +25,10 @@ package com.sun.xml.internal.bind.v2.util; -import java.util.Collection; +import java.util.AbstractMap; import java.util.Arrays; +import java.util.Collection; +import java.util.WeakHashMap; /** * Computes the string edit distance. @@ -40,6 +42,12 @@ import java.util.Arrays; */ public class EditDistance { + /** + * Weak results cache to avoid additional computations. + * Because of high complexity caching is required. + */ + private static final WeakHashMap, Integer> CACHE = new WeakHashMap, Integer>(); + /** * Computes the edit distance between two strings. * @@ -47,7 +55,17 @@ public class EditDistance { * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { - return new EditDistance(a,b).calc(); + // let's check cache + AbstractMap.SimpleEntry entry = new AbstractMap.SimpleEntry(a, b); // using this class to avoid creation of my own which will handle PAIR of values + Integer result = null; + if (CACHE.containsKey(entry)) + result = CACHE.get(entry); // looks like we have it + + if (result == null) { + result = new EditDistance(a, b).calc(); + CACHE.put(entry, result); // cache the result + } + return result; } /** diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java index d64a689f73f..969cf451649 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -38,6 +38,8 @@ import javax.xml.transform.TransformerFactory; import javax.xml.validation.SchemaFactory; import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactoryConfigurationException; + +import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; @@ -49,6 +51,9 @@ import org.xml.sax.SAXNotSupportedException; */ public class XmlFactory { + // not in older JDK, so must be duplicated here, otherwise javax.xml.XMLConstants should be used + public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema"; + private static final Logger LOGGER = Logger.getLogger(XmlFactory.class.getName()); /** @@ -186,4 +191,22 @@ public class XmlFactory { } } + public static SchemaFactory allowFileAccess(SchemaFactory sf, boolean disableSecureProcessing) { + + // if feature secure processing enabled, nothing to do, file is allowed, + // or user is able to control access by standard JAXP mechanisms + if (disableSecureProcessing) { + return sf; + } + + try { + sf.setProperty(ACCESS_EXTERNAL_SCHEMA, "file"); + LOGGER.log(Level.FINE, Messages.JAXP_SUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_SCHEMA)); + } catch (SAXException ignored) { + // nothing to do; support depends on version JDK or SAX implementation + LOGGER.log(Level.CONFIG, Messages.JAXP_UNSUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_SCHEMA), ignored); + } + return sf; + } + } diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDEventListener.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDEventListener.java index 9a94f862b68..a5f64014099 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDEventListener.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDEventListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDHandlerBase.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDHandlerBase.java index 9d24fbcd957..2e7801a1685 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDHandlerBase.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDHandlerBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDParser.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDParser.java index e296ef54828..68b7f6df1b7 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDParser.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -57,7 +57,7 @@ import java.util.Vector; * @author David Brownell * @author Janet Koenig * @author Kohsuke KAWAGUCHI - * @version $Id: DTDParser.java,v 1.2 2009-04-16 15:25:49 snajper Exp $ + * @version $Id: DTDParser.java,v 1.2 2009/04/16 15:25:49 snajper Exp $ */ public class DTDParser { public final static String TYPE_CDATA = "CDATA"; @@ -215,25 +215,25 @@ public class DTDParser { */ public void parse(String uri) throws IOException, SAXException { - InputSource inSource; + InputSource in; init(); // System.out.println ("parse (\"" + uri + "\")"); - inSource = resolver.resolveEntity(null, uri); + in = resolver.resolveEntity(null, uri); // If custom resolver punts resolution to parser, handle it ... - if (inSource == null) { - inSource = Resolver.createInputSource(new java.net.URL(uri), false); + if (in == null) { + in = Resolver.createInputSource(new java.net.URL(uri), false); // ... or if custom resolver doesn't correctly construct the // input entity, patch it up enough so relative URIs work, and // issue a warning to minimize later confusion. - } else if (inSource.getSystemId() == null) { + } else if (in.getSystemId() == null) { warning("P-065", null); - inSource.setSystemId(uri); + in.setSystemId(uri); } - parseInternal(inSource); + parseInternal(in); } // makes sure the parser is reset to "before a document" diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EndOfInputException.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EndOfInputException.java index aa7eeae0271..a7cc5224bfa 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EndOfInputException.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EndOfInputException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EntityDecl.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EntityDecl.java index 6c735929868..9db54f6821a 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EntityDecl.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/EntityDecl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/ExternalEntity.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/ExternalEntity.java index 4ab87249c73..aa396902206 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/ExternalEntity.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/ExternalEntity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InputEntity.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InputEntity.java index c296f367c56..65a0b7bfa80 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InputEntity.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InputEntity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InternalEntity.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InternalEntity.java index 1509693010f..00e125a190f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InternalEntity.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/InternalEntity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/MessageCatalog.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/MessageCatalog.java index 5f4e8238844..7ad1e12146e 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/MessageCatalog.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/MessageCatalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/Resolver.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/Resolver.java index 90b2ec3e851..ed8cbfe0134 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/Resolver.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/Resolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/SimpleHashtable.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/SimpleHashtable.java index 1cf1939776b..bbe4e5fc14f 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/SimpleHashtable.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/SimpleHashtable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlChars.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlChars.java index 90d400b82ee..848ad1dd289 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlChars.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlChars.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlNames.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlNames.java index 2f13e882fdf..5ba9f15b2b2 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlNames.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlReader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlReader.java index 88bfeb2e144..37b6ecfefc5 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlReader.java +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/XmlReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -86,7 +86,7 @@ final class XmlReader extends Reader { // /** - * Constructs the reader from an input stream, auto-detecting + * Constructs the reader from an input stream, autodetecting * the encoding to use according to the heuristic specified * in the XML 1.0 recommendation. * @@ -104,7 +104,7 @@ final class XmlReader extends Reader { * * @param in the input stream from which the reader is constructed * @param encoding the IETF standard name of the encoding to use; - * if null, auto-detection is used. + * if null, autodetection is used. * @throws IOException on error, including unrecognized encoding */ public static Reader createReader(InputStream in, String encoding) diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/package.html b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/package.html index 5a61d1d361c..950d8da179b 100644 --- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/package.html +++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/package.html @@ -1,5 +1,5 @@