Merge
This commit is contained in:
commit
4c565a7708
1
.hgtags
1
.hgtags
@ -260,3 +260,4 @@ efe7dbc6088691757404e0c8745f894e3ca9c022 jdk9-b09
|
||||
74eb0778e4f2dbff6628e718378449fba27c4265 jdk9-b15
|
||||
4a09f5d30be844ac6f714bdb0f63d8c3c08b9a98 jdk9-b16
|
||||
410bccbded9e9cce80f1e13ad221e37ae97a3986 jdk9-b17
|
||||
c5495e25c7258ab5f96a1ae14610887d76d2be63 jdk9-b18
|
||||
|
@ -260,3 +260,4 @@ ab55a18a95e1990a588929d5d29db3eb9985fea0 jdk9-b11
|
||||
b114474fb25af4e73cb7219f7c04bd8994da03a5 jdk9-b15
|
||||
cf22a728521f91a4692b433d39d730a0a1b23155 jdk9-b16
|
||||
24152ee0ee1abef54a8bab04c099261dba7bcca5 jdk9-b17
|
||||
65abab59f783fcf02ff8e133431c252f9e5f07d5 jdk9-b18
|
||||
|
@ -260,3 +260,4 @@ a2b82f863ba95a596da555a4c1b871c404863e7e jdk9-b14
|
||||
e54022d0dd92106fff7f7fe670010cd7e6517ee3 jdk9-b15
|
||||
422ef9d29d84f571453f015c4cb8713c3af70ee4 jdk9-b16
|
||||
4c75c2ca7cf3e0618315879acf17f42c8fcd0c09 jdk9-b17
|
||||
77565aaaa2bb814e94817e92d680168052a25395 jdk9-b18
|
||||
|
@ -420,3 +420,4 @@ bd333491bb6c012d7b606939406d0fa9a5ac7ffd jdk9-b14
|
||||
170f6d733d7aec062f743a6b8c1cce940a7a984a jdk9-b15
|
||||
b14e7c0b7d3ec04127f565cda1d84122e205680c jdk9-b16
|
||||
14b656df31c2cb09c505921061e79977823de71a jdk9-b17
|
||||
871fd128548480095e0dc3fc34c422666baeec75 jdk9-b18
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.gc_interface;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot
|
||||
//code.
|
||||
|
||||
public enum G1YCType {
|
||||
Normal ("Normal"),
|
||||
InitialMark ("Initial Mark"),
|
||||
DuringMark ("During Mark"),
|
||||
Mixed ("Mixed"),
|
||||
G1YCTypeEndSentinel ("Unknown");
|
||||
|
||||
private final String value;
|
||||
|
||||
G1YCType(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.gc_interface;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum GCCause {
|
||||
_java_lang_system_gc ("System.gc()"),
|
||||
_full_gc_alot ("FullGCAlot"),
|
||||
_scavenge_alot ("ScavengeAlot"),
|
||||
_allocation_profiler ("Allocation Profiler"),
|
||||
_jvmti_force_gc ("JvmtiEnv ForceGarbageCollection"),
|
||||
_gc_locker ("GCLocker Initiated GC"),
|
||||
_heap_inspection ("Heap Inspection Initiated GC"),
|
||||
_heap_dump ("Heap Dump Initiated GC"),
|
||||
|
||||
_no_gc ("No GC"),
|
||||
_no_cause_specified ("Unknown GCCause"),
|
||||
_allocation_failure ("Allocation Failure"),
|
||||
|
||||
_tenured_generation_full ("Tenured Generation Full"),
|
||||
_metadata_GC_threshold ("Metadata GC Threshold"),
|
||||
|
||||
_cms_generation_full ("CMS Generation Full"),
|
||||
_cms_initial_mark ("CMS Initial Mark"),
|
||||
_cms_final_remark ("CMS Final Remark"),
|
||||
_cms_concurrent_mark ("CMS Concurrent Mark"),
|
||||
|
||||
_old_generation_expanded_on_last_scavenge ("Old Generation Expanded On Last Scavenge"),
|
||||
_old_generation_too_full_to_scavenge ("Old Generation Too Full To Scavenge"),
|
||||
_adaptive_size_policy ("Ergonomics"),
|
||||
|
||||
_g1_inc_collection_pause ("G1 Evacuation Pause"),
|
||||
_g1_humongous_allocation ("G1 Humongous Allocation"),
|
||||
|
||||
_last_ditch_collection ("Last ditch collection"),
|
||||
_last_gc_cause ("ILLEGAL VALUE - last gc cause - ILLEGAL VALUE");
|
||||
|
||||
private final String value;
|
||||
|
||||
GCCause(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.gc_interface;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum GCName {
|
||||
ParallelOld ("ParallelOld"),
|
||||
SerialOld ("SerialOld"),
|
||||
PSMarkSweep ("PSMarkSweep"),
|
||||
ParallelScavenge ("ParallelScavenge"),
|
||||
DefNew ("DefNew"),
|
||||
ParNew ("ParNew"),
|
||||
G1New ("G1New"),
|
||||
ConcurrentMarkSweep ("ConcurrentMarkSweep"),
|
||||
G1Old ("G1Old"),
|
||||
GCNameEndSentinel ("GCNameEndSentinel");
|
||||
|
||||
private final String value;
|
||||
|
||||
GCName(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.gc_interface;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum GCWhen {
|
||||
BeforeGC ("Before GC"),
|
||||
AfterGC ("After GC"),
|
||||
GCWhenEndSentinel ("GCWhenEndSentinel");
|
||||
|
||||
private final String value;
|
||||
|
||||
GCWhen(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.gc_interface;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum ReferenceType {
|
||||
REF_NONE ("None reference"), // Regular class
|
||||
REF_OTHER ("Other reference"), // Subclass of java/lang/ref/Reference, but not subclass of one of the classes below
|
||||
REF_SOFT ("Soft reference"), // Subclass of java/lang/ref/SoftReference
|
||||
REF_WEAK ("Weak reference"), // Subclass of java/lang/ref/WeakReference
|
||||
REF_FINAL ("Final reference"), // Subclass of java/lang/ref/FinalReference
|
||||
REF_PHANTOM ("Phantom reference"); // Subclass of java/lang/ref/PhantomReference
|
||||
|
||||
private final String value;
|
||||
|
||||
ReferenceType(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -56,6 +56,12 @@ public class Universe {
|
||||
private static AddressField narrowKlassBaseField;
|
||||
private static CIntegerField narrowKlassShiftField;
|
||||
|
||||
public enum NARROW_OOP_MODE {
|
||||
UnscaledNarrowOop,
|
||||
ZeroBasedNarrowOop,
|
||||
HeapBasedNarrowOop
|
||||
}
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
@ -94,7 +100,17 @@ public class Universe {
|
||||
|
||||
public Universe() {
|
||||
}
|
||||
|
||||
public static String narrowOopModeToString(NARROW_OOP_MODE mode) {
|
||||
switch (mode) {
|
||||
case UnscaledNarrowOop:
|
||||
return "32-bits Oops";
|
||||
case ZeroBasedNarrowOop:
|
||||
return "zero based Compressed Oops";
|
||||
case HeapBasedNarrowOop:
|
||||
return "Compressed Oops with base";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public CollectedHeap heap() {
|
||||
try {
|
||||
return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());
|
||||
|
@ -55,6 +55,7 @@ public class Klass extends Metadata implements ClassConstants {
|
||||
layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0);
|
||||
name = type.getAddressField("_name");
|
||||
accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
|
||||
traceIDField = type.getField("_trace_id");
|
||||
subklass = new MetadataField(type.getAddressField("_subklass"), 0);
|
||||
nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0);
|
||||
|
||||
@ -86,6 +87,7 @@ public class Klass extends Metadata implements ClassConstants {
|
||||
private static CIntField accessFlags;
|
||||
private static MetadataField subklass;
|
||||
private static MetadataField nextSibling;
|
||||
private static sun.jvm.hotspot.types.Field traceIDField;
|
||||
|
||||
private Address getValue(AddressField field) {
|
||||
return addr.getAddressAt(field.getOffset());
|
||||
@ -106,6 +108,7 @@ public class Klass extends Metadata implements ClassConstants {
|
||||
public AccessFlags getAccessFlagsObj(){ return new AccessFlags(getAccessFlags()); }
|
||||
public Klass getSubklassKlass() { return (Klass) subklass.getValue(this); }
|
||||
public Klass getNextSiblingKlass() { return (Klass) nextSibling.getValue(this); }
|
||||
public long traceID() { return traceIDField.getJLong(addr); }
|
||||
|
||||
// computed access flags - takes care of inner classes etc.
|
||||
// This is closer to actual source level than getAccessFlags() etc.
|
||||
|
@ -54,6 +54,8 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
|
||||
private static OopField threadNameField;
|
||||
private static OopField threadGroupField;
|
||||
private static LongField threadEETopField;
|
||||
//tid field is new since 1.5
|
||||
private static LongField threadTIDField;
|
||||
// threadStatus field is new since 1.5
|
||||
private static IntField threadStatusField;
|
||||
// parkBlocker field is new since 1.6
|
||||
@ -220,6 +222,7 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
|
||||
threadNameField = (OopField) k.findField("name", "[C");
|
||||
threadGroupField = (OopField) k.findField("group", "Ljava/lang/ThreadGroup;");
|
||||
threadEETopField = (LongField) k.findField("eetop", "J");
|
||||
threadTIDField = (LongField) k.findField("tid", "J");
|
||||
threadStatusField = (IntField) k.findField("threadStatus", "I");
|
||||
threadParkBlockerField = (OopField) k.findField("parkBlocker",
|
||||
"Ljava/lang/Object;");
|
||||
@ -268,6 +271,15 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
|
||||
return VM.getVM().getThreads().createJavaThreadWrapper(addr);
|
||||
}
|
||||
|
||||
public static long threadOopGetTID(Oop threadOop) {
|
||||
initThreadFields();
|
||||
if (threadTIDField != null) {
|
||||
return threadTIDField.getValue(threadOop);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** returns value of java.lang.Thread.threadStatus field */
|
||||
public static int threadOopGetThreadStatus(Oop threadOop) {
|
||||
initThreadFields();
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.opto;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum CompilerPhaseType {
|
||||
PHASE_BEFORE_STRINGOPTS ("Before StringOpts"),
|
||||
PHASE_AFTER_STRINGOPTS ("After StringOpts"),
|
||||
PHASE_BEFORE_REMOVEUSELESS ("Before RemoveUseless"),
|
||||
PHASE_AFTER_PARSING ("After Parsing"),
|
||||
PHASE_ITER_GVN1 ("Iter GVN 1"),
|
||||
PHASE_PHASEIDEAL_BEFORE_EA ("PhaseIdealLoop before EA"),
|
||||
PHASE_ITER_GVN_AFTER_EA ("Iter GVN after EA"),
|
||||
PHASE_ITER_GVN_AFTER_ELIMINATION ("Iter GVN after eliminating allocations and locks"),
|
||||
PHASE_PHASEIDEALLOOP1 ("PhaseIdealLoop 1"),
|
||||
PHASE_PHASEIDEALLOOP2 ("PhaseIdealLoop 2"),
|
||||
PHASE_PHASEIDEALLOOP3 ("PhaseIdealLoop 3"),
|
||||
PHASE_CPP1 ("PhaseCPP 1"),
|
||||
PHASE_ITER_GVN2 ("Iter GVN 2"),
|
||||
PHASE_PHASEIDEALLOOP_ITERATIONS ("PhaseIdealLoop iterations"),
|
||||
PHASE_OPTIMIZE_FINISHED ("Optimize finished"),
|
||||
PHASE_GLOBAL_CODE_MOTION ("Global code motion"),
|
||||
PHASE_FINAL_CODE ("Final Code"),
|
||||
PHASE_AFTER_EA ("After Escape Analysis"),
|
||||
PHASE_BEFORE_CLOOPS ("Before CountedLoop"),
|
||||
PHASE_AFTER_CLOOPS ("After CountedLoop"),
|
||||
PHASE_BEFORE_BEAUTIFY_LOOPS ("Before beautify loops"),
|
||||
PHASE_AFTER_BEAUTIFY_LOOPS ("After beautify loops"),
|
||||
PHASE_BEFORE_MATCHING ("Before Matching"),
|
||||
PHASE_INCREMENTAL_INLINE ("Incremental Inline"),
|
||||
PHASE_INCREMENTAL_BOXING_INLINE ("Incremental Boxing Inline"),
|
||||
PHASE_END ("End"),
|
||||
PHASE_FAILURE ("Failure"),
|
||||
PHASE_NUM_TYPES ("Number of Phase Types");
|
||||
|
||||
private final String value;
|
||||
|
||||
CompilerPhaseType(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.runtime;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum Flags {
|
||||
// value origin
|
||||
DEFAULT ("Default"),
|
||||
COMMAND_LINE ("Command line"),
|
||||
ENVIRON_VAR ("Environment variable"),
|
||||
CONFIG_FILE ("Config file"),
|
||||
MANAGEMENT ("Management"),
|
||||
ERGONOMIC ("Ergonomic"),
|
||||
ATTACH_ON_DEMAND ("Attach on demand"),
|
||||
INTERNAL ("Internal");
|
||||
|
||||
private final String value;
|
||||
|
||||
Flags(String val) {
|
||||
this.value = val;
|
||||
}
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -41,6 +41,8 @@ public class Thread extends VMObject {
|
||||
private static AddressField currentPendingMonitorField;
|
||||
private static AddressField currentWaitingMonitorField;
|
||||
|
||||
private static JLongField allocatedBytesField;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
@ -61,6 +63,7 @@ public class Thread extends VMObject {
|
||||
activeHandlesField = type.getAddressField("_active_handles");
|
||||
currentPendingMonitorField = type.getAddressField("_current_pending_monitor");
|
||||
currentWaitingMonitorField = type.getAddressField("_current_waiting_monitor");
|
||||
allocatedBytesField = type.getJLongField("_allocated_bytes");
|
||||
}
|
||||
|
||||
public Thread(Address addr) {
|
||||
@ -104,6 +107,10 @@ public class Thread extends VMObject {
|
||||
return new JNIHandleBlock(a);
|
||||
}
|
||||
|
||||
public long allocatedBytes() {
|
||||
return allocatedBytesField.getValue(addr);
|
||||
}
|
||||
|
||||
public boolean isVMThread() { return false; }
|
||||
public boolean isJavaThread() { return false; }
|
||||
public boolean isCompilerThread() { return false; }
|
||||
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 sun.jvm.hotspot.runtime;
|
||||
|
||||
//These definitions should be kept in sync with the definitions in the HotSpot code.
|
||||
|
||||
public enum VMOps {
|
||||
Dummy,
|
||||
ThreadStop,
|
||||
ThreadDump,
|
||||
PrintThreads,
|
||||
FindDeadlocks,
|
||||
ForceSafepoint,
|
||||
ForceAsyncSafepoint,
|
||||
Deoptimize,
|
||||
DeoptimizeFrame,
|
||||
DeoptimizeAll,
|
||||
ZombieAll,
|
||||
UnlinkSymbols,
|
||||
Verify,
|
||||
PrintJNI,
|
||||
HeapDumper,
|
||||
DeoptimizeTheWorld,
|
||||
CollectForMetadataAllocation,
|
||||
GC_HeapInspection,
|
||||
GenCollectFull,
|
||||
GenCollectFullConcurrent,
|
||||
GenCollectForAllocation,
|
||||
ParallelGCFailedAllocation,
|
||||
ParallelGCSystemGC,
|
||||
CGC_Operation,
|
||||
CMS_Initial_Mark,
|
||||
CMS_Final_Remark,
|
||||
G1CollectFull,
|
||||
G1CollectForAllocation,
|
||||
G1IncCollectionPause,
|
||||
EnableBiasedLocking,
|
||||
RevokeBias,
|
||||
BulkRevokeBias,
|
||||
PopulateDumpSharedSpace,
|
||||
JNIFunctionTableCopier,
|
||||
RedefineClasses,
|
||||
GetOwnedMonitorInfo,
|
||||
GetObjectMonitorUsage,
|
||||
GetCurrentContendedMonitor,
|
||||
GetStackTrace,
|
||||
GetMultipleStackTraces,
|
||||
GetAllStackTraces,
|
||||
GetThreadListStackTraces,
|
||||
GetFrameCount,
|
||||
GetFrameLocation,
|
||||
ChangeBreakpoints,
|
||||
GetOrSetLocal,
|
||||
GetCurrentLocation,
|
||||
EnterInterpOnlyMode,
|
||||
ChangeSingleStep,
|
||||
HeapWalkOperation,
|
||||
HeapIterateOperation,
|
||||
ReportJavaOutOfMemory,
|
||||
JFRCheckpoint,
|
||||
Exit,
|
||||
LinuxDllLoad,
|
||||
Terminating
|
||||
}
|
@ -82,14 +82,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
|
||||
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
|
||||
$(JDK_VER_DEFS)
|
||||
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
|
||||
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
|
||||
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
|
||||
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
|
||||
|
||||
CXXFLAGS = \
|
||||
${SYSDEFS} \
|
||||
${INCLUDES} \
|
||||
${BUILD_TARGET} \
|
||||
${BUILD_USER} \
|
||||
${HS_LIB_ARCH} \
|
||||
${VM_DISTRO}
|
||||
|
@ -81,14 +81,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
|
||||
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
|
||||
$(JDK_VER_DEFS)
|
||||
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
|
||||
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
|
||||
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
|
||||
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
|
||||
|
||||
CXXFLAGS = \
|
||||
${SYSDEFS} \
|
||||
${INCLUDES} \
|
||||
${BUILD_TARGET} \
|
||||
${BUILD_USER} \
|
||||
${HS_LIB_ARCH} \
|
||||
${VM_DISTRO}
|
||||
|
@ -135,8 +135,12 @@ endif
|
||||
ifeq ($(JDK_MKTG_VERSION),)
|
||||
JDK_MKTG_VERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
|
||||
endif
|
||||
ifeq ($(JDK_VERSION),)
|
||||
JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
|
||||
ifeq ($(JDK_VERSION),)
|
||||
ifeq ($(BUILD_FLAVOR), product)
|
||||
JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
|
||||
else
|
||||
JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)-$(BUILD_FLAVOR)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(FULL_VERSION),)
|
||||
FULL_VERSION="$(JDK_VERSION)"
|
||||
|
@ -69,7 +69,7 @@ ifeq ($(ARCH), ia64)
|
||||
endif
|
||||
|
||||
# sparc
|
||||
ifeq ($(ARCH), sparc64)
|
||||
ifneq (,$(findstring $(ARCH), sparc))
|
||||
ifeq ($(ARCH_DATA_MODEL), 64)
|
||||
ARCH_DATA_MODEL = 64
|
||||
MAKE_ARGS += LP64=1
|
||||
@ -83,30 +83,20 @@ ifeq ($(ARCH), sparc64)
|
||||
HS_ARCH = sparc
|
||||
endif
|
||||
|
||||
# amd64/x86_64
|
||||
ifneq (,$(findstring $(ARCH), amd64 x86_64))
|
||||
# i686/i586 and amd64/x86_64
|
||||
ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586))
|
||||
ifeq ($(ARCH_DATA_MODEL), 64)
|
||||
ARCH_DATA_MODEL = 64
|
||||
MAKE_ARGS += LP64=1
|
||||
PLATFORM = linux-amd64
|
||||
VM_PLATFORM = linux_amd64
|
||||
HS_ARCH = x86
|
||||
else
|
||||
ARCH_DATA_MODEL = 32
|
||||
PLATFORM = linux-i586
|
||||
VM_PLATFORM = linux_i486
|
||||
HS_ARCH = x86
|
||||
# We have to reset ARCH to i686 since SRCARCH relies on it
|
||||
ARCH = i686
|
||||
endif
|
||||
endif
|
||||
|
||||
# i686/i586 ie 32-bit x86
|
||||
ifneq (,$(findstring $(ARCH), i686 i586))
|
||||
ARCH_DATA_MODEL = 32
|
||||
PLATFORM = linux-i586
|
||||
VM_PLATFORM = linux_i486
|
||||
HS_ARCH = x86
|
||||
HS_ARCH = x86
|
||||
endif
|
||||
|
||||
# ARM
|
||||
@ -118,20 +108,18 @@ ifeq ($(ARCH), arm)
|
||||
endif
|
||||
|
||||
# PPC
|
||||
ifeq ($(ARCH), ppc)
|
||||
ARCH_DATA_MODEL = 32
|
||||
PLATFORM = linux-ppc
|
||||
VM_PLATFORM = linux_ppc
|
||||
HS_ARCH = ppc
|
||||
endif
|
||||
ifneq (,$(findstring $(ARCH), ppc))
|
||||
ifeq ($(ARCH_DATA_MODEL), 64)
|
||||
MAKE_ARGS += LP64=1
|
||||
PLATFORM = linux-ppc64
|
||||
VM_PLATFORM = linux_ppc64
|
||||
else
|
||||
ARCH_DATA_MODEL = 32
|
||||
PLATFORM = linux-ppc
|
||||
VM_PLATFORM = linux_ppc
|
||||
endif
|
||||
|
||||
# PPC64
|
||||
ifeq ($(ARCH), ppc64)
|
||||
ARCH_DATA_MODEL = 64
|
||||
MAKE_ARGS += LP64=1
|
||||
PLATFORM = linux-ppc64
|
||||
VM_PLATFORM = linux_ppc64
|
||||
HS_ARCH = ppc
|
||||
HS_ARCH = ppc
|
||||
endif
|
||||
|
||||
# On 32 bit linux we build server and client, on 64 bit just server.
|
||||
|
@ -82,14 +82,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
|
||||
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
|
||||
$(JDK_VER_DEFS)
|
||||
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
|
||||
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
|
||||
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
|
||||
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
|
||||
|
||||
CXXFLAGS = \
|
||||
${SYSDEFS} \
|
||||
${INCLUDES} \
|
||||
${BUILD_TARGET} \
|
||||
${BUILD_USER} \
|
||||
${HS_LIB_ARCH} \
|
||||
${VM_DISTRO}
|
||||
|
@ -29,8 +29,12 @@
|
||||
# and generate JNI header file for native methods.
|
||||
|
||||
include $(GAMMADIR)/make/solaris/makefiles/rules.make
|
||||
include $(GAMMADIR)/make/defs.make
|
||||
AGENT_DIR = $(GAMMADIR)/agent
|
||||
include $(GAMMADIR)/make/sa.files
|
||||
|
||||
-include $(HS_ALT_MAKE)/solaris/makefiles/sa.make
|
||||
|
||||
GENERATED = ../generated
|
||||
|
||||
# tools.jar is needed by the JDI - SA binding
|
||||
|
@ -77,14 +77,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
|
||||
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
|
||||
$(JDK_VER_DEFS)
|
||||
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
|
||||
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
|
||||
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
|
||||
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
|
||||
|
||||
CXXFLAGS = \
|
||||
${SYSDEFS} \
|
||||
${INCLUDES} \
|
||||
${BUILD_TARGET} \
|
||||
${BUILD_USER} \
|
||||
${HS_LIB_ARCH} \
|
||||
${VM_DISTRO}
|
||||
|
@ -38,6 +38,22 @@ checkAndBuildSA::
|
||||
|
||||
GENERATED = ../generated
|
||||
|
||||
HS_COMMON_SRC_REL = src
|
||||
|
||||
!if "$(OPENJDK)" != "true"
|
||||
HS_ALT_SRC_REL=src/closed
|
||||
HS_ALT_SRC = $(WorkSpace)/$(HS_ALT_SRC_REL)
|
||||
!ifndef HS_ALT_MAKE
|
||||
HS_ALT_MAKE=$(WorkSpace)/make/closed
|
||||
!endif
|
||||
!endif
|
||||
|
||||
HS_COMMON_SRC = $(WorkSpace)/$(HS_COMMON_SRC_REL)
|
||||
|
||||
!ifdef HS_ALT_MAKE
|
||||
!include $(HS_ALT_MAKE)/windows/makefiles/sa.make
|
||||
!endif
|
||||
|
||||
# tools.jar is needed by the JDI - SA binding
|
||||
SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar
|
||||
|
||||
|
@ -116,7 +116,7 @@ JDK_MAJOR_VERSION="\\\"$(JDK_MAJOR_VER)\\\""
|
||||
JDK_MINOR_VERSION="\\\"$(JDK_MINOR_VER)\\\""
|
||||
JDK_MICRO_VERSION="\\\"$(JDK_MICRO_VER)\\\""
|
||||
|
||||
ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -define JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) -define JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) -define JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) -define JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER)
|
||||
ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -define JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) -define JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) -define JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) -define JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER) -define VISUAL_STUDIO_BUILD=true
|
||||
ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) $(ReleaseOptions)
|
||||
|
||||
$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class
|
||||
|
@ -436,32 +436,6 @@ void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
|
||||
}
|
||||
#endif // CC_INTERP
|
||||
|
||||
|
||||
#ifdef ASSERT
|
||||
// Debugging aid
|
||||
static frame nth_sender(int n) {
|
||||
frame f = JavaThread::current()->last_frame();
|
||||
|
||||
for(int i = 0; i < n; ++i)
|
||||
f = f.sender((RegisterMap*)NULL);
|
||||
|
||||
printf("first frame %d\n", f.is_first_frame() ? 1 : 0);
|
||||
printf("interpreted frame %d\n", f.is_interpreted_frame() ? 1 : 0);
|
||||
printf("java frame %d\n", f.is_java_frame() ? 1 : 0);
|
||||
printf("entry frame %d\n", f.is_entry_frame() ? 1 : 0);
|
||||
printf("native frame %d\n", f.is_native_frame() ? 1 : 0);
|
||||
if (f.is_compiled_frame()) {
|
||||
if (f.is_deoptimized_frame())
|
||||
printf("deoptimized frame 1\n");
|
||||
else
|
||||
printf("compiled frame 1\n");
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
frame frame::sender_for_entry_frame(RegisterMap *map) const {
|
||||
assert(map != NULL, "map must be set");
|
||||
// Java frame called from C; skip all C frames and return top C
|
||||
|
@ -2812,13 +2812,6 @@ void os::yield() {
|
||||
|
||||
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
|
||||
|
||||
void os::yield_all() {
|
||||
// Yields to all threads, including threads with lower priorities
|
||||
// Threads on Linux are all with same priority. The Solaris style
|
||||
// os::yield_all() with nanosleep(1ms) is not necessary.
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread priority support
|
||||
|
||||
@ -3075,7 +3068,7 @@ static bool do_suspend(OSThread* osthread) {
|
||||
|
||||
for (int n = 0; !osthread->sr.is_suspended(); n++) {
|
||||
for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
|
||||
os::yield_all();
|
||||
os::yield();
|
||||
}
|
||||
|
||||
// timeout, try to cancel the request
|
||||
@ -3109,7 +3102,7 @@ static void do_resume(OSThread* osthread) {
|
||||
if (sr_notify(osthread) == 0) {
|
||||
for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
|
||||
for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
|
||||
os::yield_all();
|
||||
os::yield();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2600,13 +2600,6 @@ void os::yield() {
|
||||
|
||||
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
|
||||
|
||||
void os::yield_all() {
|
||||
// Yields to all threads, including threads with lower priorities
|
||||
// Threads on Bsd are all with same priority. The Solaris style
|
||||
// os::yield_all() with nanosleep(1ms) is not necessary.
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread priority support
|
||||
|
||||
|
@ -3795,13 +3795,6 @@ void os::yield() {
|
||||
|
||||
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
|
||||
|
||||
void os::yield_all() {
|
||||
// Yields to all threads, including threads with lower priorities
|
||||
// Threads on Linux are all with same priority. The Solaris style
|
||||
// os::yield_all() with nanosleep(1ms) is not necessary.
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// thread priority support
|
||||
|
||||
|
@ -3186,11 +3186,6 @@ void os::yield() {
|
||||
|
||||
os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; }
|
||||
|
||||
void os::yield_all() {
|
||||
// Yields to all threads, including threads with lower priorities
|
||||
os::sleep(Thread::current(), 1, false);
|
||||
}
|
||||
|
||||
// Interface for setting lwp priorities. If we are using T2 libthread,
|
||||
// which forces the use of BoundThreads or we manually set UseBoundThreads,
|
||||
// all of our threads will be assigned to real lwp's. Using the thr_setprio
|
||||
|
@ -3526,11 +3526,6 @@ os::YieldResult os::NakedYield() {
|
||||
|
||||
void os::yield() { os::NakedYield(); }
|
||||
|
||||
void os::yield_all() {
|
||||
// Yields to all threads, including threads with lower priorities
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
// Win32 only gives you access to seven real priorities at a time,
|
||||
// so we compress Java's ten down to seven. It would be better
|
||||
// if we dynamically adjusted relative priorities.
|
||||
|
@ -512,24 +512,9 @@ ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
|
||||
} else {
|
||||
// Check if it's resolved if it's not a symbol constant pool entry.
|
||||
klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index));
|
||||
|
||||
if (klass.is_null()) {
|
||||
// The klass has not been inserted into the constant pool.
|
||||
// Try to look it up by name.
|
||||
{
|
||||
// We have to lock the cpool to keep the oop from being resolved
|
||||
// while we are accessing it.
|
||||
MonitorLockerEx ml(cpool->lock());
|
||||
constantTag tag = cpool->tag_at(index);
|
||||
if (tag.is_klass()) {
|
||||
// The klass has been inserted into the constant pool
|
||||
// very recently.
|
||||
klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
|
||||
} else {
|
||||
assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
|
||||
klass_name = cpool->unresolved_klass_at(index);
|
||||
}
|
||||
}
|
||||
if (klass.is_null()) {
|
||||
klass_name = cpool->klass_name_at(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2013, 2014, 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
|
||||
@ -686,7 +686,7 @@ class CompileReplay : public StackObj {
|
||||
switch (cp->tag_at(i).value()) {
|
||||
case JVM_CONSTANT_UnresolvedClass: {
|
||||
if (tag == JVM_CONSTANT_Class) {
|
||||
tty->print_cr("Resolving klass %s at %d", cp->unresolved_klass_at(i)->as_utf8(), i);
|
||||
tty->print_cr("Resolving klass %s at %d", cp->klass_name_at(i)->as_utf8(), i);
|
||||
Klass* k = cp->klass_at(i, CHECK);
|
||||
}
|
||||
break;
|
||||
|
@ -510,7 +510,7 @@ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
|
||||
jbyte tag = cp->tag_at(index).value();
|
||||
switch (tag) {
|
||||
case JVM_CONSTANT_UnresolvedClass: {
|
||||
Symbol* class_name = cp->unresolved_klass_at(index);
|
||||
Symbol* class_name = cp->klass_name_at(index);
|
||||
// check the name, even if _cp_patches will overwrite it
|
||||
verify_legal_class_name(class_name, CHECK_(nullHandle));
|
||||
break;
|
||||
@ -3161,7 +3161,7 @@ instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index,
|
||||
if (_need_verify)
|
||||
is_array = super_klass->oop_is_array();
|
||||
} else if (_need_verify) {
|
||||
is_array = (_cp->unresolved_klass_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
|
||||
is_array = (_cp->klass_name_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
|
||||
}
|
||||
if (_need_verify) {
|
||||
guarantee_property(!is_array,
|
||||
@ -3855,7 +3855,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
|
||||
"Invalid this class index %u in constant pool in class file %s",
|
||||
this_class_index, CHECK_(nullHandle));
|
||||
|
||||
Symbol* class_name = cp->unresolved_klass_at(this_class_index);
|
||||
Symbol* class_name = cp->klass_name_at(this_class_index);
|
||||
assert(class_name != NULL, "class_name can't be null");
|
||||
|
||||
// It's important to set parsed_name *before* resolving the super class.
|
||||
@ -4139,8 +4139,8 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
|
||||
}
|
||||
|
||||
// Allocate mirror and initialize static fields
|
||||
java_lang_Class::create_mirror(this_klass, protection_domain, CHECK_(nullHandle));
|
||||
|
||||
java_lang_Class::create_mirror(this_klass, class_loader, protection_domain,
|
||||
CHECK_(nullHandle));
|
||||
|
||||
// Generate any default methods - default methods are interface methods
|
||||
// that have a default implementation. This is new with Lambda project.
|
||||
|
@ -187,8 +187,6 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
JNIHandleBlock* handles() const;
|
||||
void set_handles(JNIHandleBlock* handles);
|
||||
|
||||
Mutex* metaspace_lock() const { return _metaspace_lock; }
|
||||
|
||||
// GC interface.
|
||||
void clear_claimed() { _claimed = 0; }
|
||||
bool claimed() const { return _claimed == 1; }
|
||||
@ -216,6 +214,8 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
return _the_null_class_loader_data;
|
||||
}
|
||||
|
||||
Mutex* metaspace_lock() const { return _metaspace_lock; }
|
||||
|
||||
bool is_anonymous() const { return _is_anonymous; }
|
||||
|
||||
static void init_null_class_loader_data() {
|
||||
|
@ -558,7 +558,7 @@ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
|
||||
}
|
||||
}
|
||||
}
|
||||
create_mirror(k, Handle(NULL), CHECK);
|
||||
create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
|
||||
}
|
||||
|
||||
void java_lang_Class::initialize_mirror_fields(KlassHandle k,
|
||||
@ -578,7 +578,8 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k,
|
||||
InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
|
||||
}
|
||||
|
||||
void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) {
|
||||
void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
|
||||
Handle protection_domain, TRAPS) {
|
||||
assert(k->java_mirror() == NULL, "should only assign mirror once");
|
||||
// Use this moment of initialization to cache modifier_flags also,
|
||||
// to support Class.getModifiers(). Instance classes recalculate
|
||||
@ -633,6 +634,9 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRA
|
||||
}
|
||||
}
|
||||
|
||||
// set the classLoader field in the java_lang_Class instance
|
||||
set_class_loader(mirror(), class_loader());
|
||||
|
||||
// Setup indirection from klass->mirror last
|
||||
// after any exceptions can happen during allocations.
|
||||
if (!k.is_null()) {
|
||||
@ -694,6 +698,18 @@ void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
|
||||
}
|
||||
|
||||
|
||||
void java_lang_Class::set_class_loader(oop java_class, oop loader) {
|
||||
// jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet.
|
||||
if (_class_loader_offset != 0) {
|
||||
java_class->obj_field_put(_class_loader_offset, loader);
|
||||
}
|
||||
}
|
||||
|
||||
oop java_lang_Class::class_loader(oop java_class) {
|
||||
assert(_class_loader_offset != 0, "must be set");
|
||||
return java_class->obj_field(_class_loader_offset);
|
||||
}
|
||||
|
||||
oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
|
||||
// This should be improved by adding a field at the Java level or by
|
||||
// introducing a new VM klass (see comment in ClassFileParser)
|
||||
@ -853,6 +869,12 @@ void java_lang_Class::compute_offsets() {
|
||||
compute_optional_offset(classRedefinedCount_offset,
|
||||
klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
|
||||
|
||||
// Needs to be optional because the old build runs Queens during bootstrapping
|
||||
// and jdk8-9 doesn't have coordinated pushes yet.
|
||||
compute_optional_offset(_class_loader_offset,
|
||||
klass_oop, vmSymbols::classLoader_name(),
|
||||
vmSymbols::classloader_signature());
|
||||
|
||||
CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
||||
}
|
||||
|
||||
@ -3073,6 +3095,7 @@ int java_lang_Class::_klass_offset;
|
||||
int java_lang_Class::_array_klass_offset;
|
||||
int java_lang_Class::_oop_size_offset;
|
||||
int java_lang_Class::_static_oop_field_count_offset;
|
||||
int java_lang_Class::_class_loader_offset;
|
||||
int java_lang_Class::_protection_domain_offset;
|
||||
int java_lang_Class::_init_lock_offset;
|
||||
int java_lang_Class::_signers_offset;
|
||||
|
@ -240,19 +240,23 @@ class java_lang_Class : AllStatic {
|
||||
static int _protection_domain_offset;
|
||||
static int _init_lock_offset;
|
||||
static int _signers_offset;
|
||||
static int _class_loader_offset;
|
||||
|
||||
static bool offsets_computed;
|
||||
static int classRedefinedCount_offset;
|
||||
|
||||
static GrowableArray<Klass*>* _fixup_mirror_list;
|
||||
|
||||
static void set_init_lock(oop java_class, oop init_lock);
|
||||
static void set_protection_domain(oop java_class, oop protection_domain);
|
||||
static void set_class_loader(oop java_class, oop class_loader);
|
||||
static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS);
|
||||
public:
|
||||
static void compute_offsets();
|
||||
|
||||
// Instance creation
|
||||
static void create_mirror(KlassHandle k, Handle protection_domain, TRAPS);
|
||||
static void create_mirror(KlassHandle k, Handle class_loader,
|
||||
Handle protection_domain, TRAPS);
|
||||
static void fixup_mirror(KlassHandle k, TRAPS);
|
||||
static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
|
||||
// Conversion
|
||||
@ -290,6 +294,8 @@ class java_lang_Class : AllStatic {
|
||||
static objArrayOop signers(oop java_class);
|
||||
static void set_signers(oop java_class, objArrayOop signers);
|
||||
|
||||
static oop class_loader(oop java_class);
|
||||
|
||||
static int oop_size(oop java_class);
|
||||
static void set_oop_size(oop java_class, int size);
|
||||
static int static_oop_field_count(oop java_class);
|
||||
|
@ -572,6 +572,7 @@
|
||||
template(serializePropertiesToByteArray_signature, "()[B") \
|
||||
template(serializeAgentPropertiesToByteArray_name, "serializeAgentPropertiesToByteArray") \
|
||||
template(classRedefinedCount_name, "classRedefinedCount") \
|
||||
template(classLoader_name, "classLoader") \
|
||||
\
|
||||
/* trace signatures */ \
|
||||
TRACE_TEMPLATES(template) \
|
||||
|
@ -93,7 +93,7 @@ void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_kl
|
||||
ResourceMark rm(THREAD);
|
||||
k->initialize_supers(super_klass(), CHECK);
|
||||
k->vtable()->initialize_vtable(false, CHECK);
|
||||
java_lang_Class::create_mirror(k, Handle(NULL), CHECK);
|
||||
java_lang_Class::create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
|
||||
}
|
||||
|
||||
GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) {
|
||||
|
@ -71,7 +71,6 @@ ConstantPool::ConstantPool(Array<u1>* tags) {
|
||||
|
||||
// only set to non-zero if constant pool is merged by RedefineClasses
|
||||
set_version(0);
|
||||
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
|
||||
|
||||
// initialize tag array
|
||||
int length = tags->length();
|
||||
@ -100,9 +99,6 @@ void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
|
||||
void ConstantPool::release_C_heap_structures() {
|
||||
// walk constant pool and decrement symbol reference counts
|
||||
unreference_symbols();
|
||||
|
||||
delete _lock;
|
||||
set_lock(NULL);
|
||||
}
|
||||
|
||||
objArrayOop ConstantPool::resolved_references() const {
|
||||
@ -146,8 +142,7 @@ void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
|
||||
// CDS support. Create a new resolved_references array.
|
||||
void ConstantPool::restore_unshareable_info(TRAPS) {
|
||||
|
||||
// Only create the new resolved references array and lock if it hasn't been
|
||||
// attempted before
|
||||
// Only create the new resolved references array if it hasn't been attempted before
|
||||
if (resolved_references() != NULL) return;
|
||||
|
||||
// restore the C++ vtable from the shared archive
|
||||
@ -163,9 +158,6 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
|
||||
ClassLoaderData* loader_data = pool_holder()->class_loader_data();
|
||||
set_resolved_references(loader_data->add_handle(refs_handle));
|
||||
}
|
||||
|
||||
// Also need to recreate the mutex. Make sure this matches the constructor
|
||||
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +168,6 @@ void ConstantPool::remove_unshareable_info() {
|
||||
set_resolved_reference_length(
|
||||
resolved_references() != NULL ? resolved_references()->length() : 0);
|
||||
set_resolved_references(NULL);
|
||||
set_lock(NULL);
|
||||
}
|
||||
|
||||
int ConstantPool::cp_to_object_index(int cp_index) {
|
||||
@ -186,11 +177,41 @@ int ConstantPool::cp_to_object_index(int cp_index) {
|
||||
return (i < 0) ? _no_index_sentinel : i;
|
||||
}
|
||||
|
||||
Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) {
|
||||
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
|
||||
// It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
|
||||
// tag is not updated atomicly.
|
||||
void ConstantPool::trace_class_resolution(constantPoolHandle this_cp, KlassHandle k) {
|
||||
ResourceMark rm;
|
||||
int line_number = -1;
|
||||
const char * source_file = NULL;
|
||||
if (JavaThread::current()->has_last_Java_frame()) {
|
||||
// try to identify the method which called this function.
|
||||
vframeStream vfst(JavaThread::current());
|
||||
if (!vfst.at_end()) {
|
||||
line_number = vfst.method()->line_number_from_bci(vfst.bci());
|
||||
Symbol* s = vfst.method()->method_holder()->source_file_name();
|
||||
if (s != NULL) {
|
||||
source_file = s->as_C_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k() != this_cp->pool_holder()) {
|
||||
// only print something if the classes are different
|
||||
if (source_file != NULL) {
|
||||
tty->print("RESOLVE %s %s %s:%d\n",
|
||||
this_cp->pool_holder()->external_name(),
|
||||
InstanceKlass::cast(k())->external_name(), source_file, line_number);
|
||||
} else {
|
||||
tty->print("RESOLVE %s %s\n",
|
||||
this_cp->pool_holder()->external_name(),
|
||||
InstanceKlass::cast(k())->external_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) {
|
||||
assert(THREAD->is_Java_thread(), "must be a Java thread");
|
||||
|
||||
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
|
||||
// It is not safe to rely on the tag bit's here, since we don't have a lock, and
|
||||
// the entry and tag is not updated atomicly.
|
||||
CPSlot entry = this_cp->slot_at(which);
|
||||
if (entry.is_resolved()) {
|
||||
assert(entry.get_klass()->is_klass(), "must be");
|
||||
@ -198,115 +219,51 @@ Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS)
|
||||
return entry.get_klass();
|
||||
}
|
||||
|
||||
// Acquire lock on constant oop while doing update. After we get the lock, we check if another object
|
||||
// already has updated the object
|
||||
assert(THREAD->is_Java_thread(), "must be a Java thread");
|
||||
bool do_resolve = false;
|
||||
bool in_error = false;
|
||||
|
||||
// Create a handle for the mirror. This will preserve the resolved class
|
||||
// until the loader_data is registered.
|
||||
Handle mirror_handle;
|
||||
|
||||
Symbol* name = NULL;
|
||||
Handle loader;
|
||||
{ MonitorLockerEx ml(this_cp->lock());
|
||||
|
||||
if (this_cp->tag_at(which).is_unresolved_klass()) {
|
||||
if (this_cp->tag_at(which).is_unresolved_klass_in_error()) {
|
||||
in_error = true;
|
||||
} else {
|
||||
do_resolve = true;
|
||||
name = this_cp->unresolved_klass_at(which);
|
||||
loader = Handle(THREAD, this_cp->pool_holder()->class_loader());
|
||||
}
|
||||
}
|
||||
} // unlocking constantPool
|
||||
|
||||
|
||||
// The original attempt to resolve this constant pool entry failed so find the
|
||||
// class of the original error and throw another error of the same class (JVMS 5.4.3).
|
||||
// If there is a detail message, pass that detail message to the error constructor.
|
||||
// The JVMS does not strictly require us to duplicate the same detail message,
|
||||
// or any internal exception fields such as cause or stacktrace. But since the
|
||||
// detail message is often a class name or other literal string, we will repeat it if
|
||||
// we can find it in the symbol table.
|
||||
if (in_error) {
|
||||
// This tag doesn't change back to unresolved class unless at a safepoint.
|
||||
if (this_cp->tag_at(which).is_unresolved_klass_in_error()) {
|
||||
// The original attempt to resolve this constant pool entry failed so find the
|
||||
// class of the original error and throw another error of the same class
|
||||
// (JVMS 5.4.3).
|
||||
// If there is a detail message, pass that detail message to the error.
|
||||
// The JVMS does not strictly require us to duplicate the same detail message,
|
||||
// or any internal exception fields such as cause or stacktrace. But since the
|
||||
// detail message is often a class name or other literal string, we will repeat it
|
||||
// if we can find it in the symbol table.
|
||||
throw_resolution_error(this_cp, which, CHECK_0);
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
if (do_resolve) {
|
||||
// this_cp must be unlocked during resolve_or_fail
|
||||
oop protection_domain = this_cp->pool_holder()->protection_domain();
|
||||
Handle h_prot (THREAD, protection_domain);
|
||||
Klass* kk = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD);
|
||||
KlassHandle k;
|
||||
if (!HAS_PENDING_EXCEPTION) {
|
||||
k = KlassHandle(THREAD, kk);
|
||||
// preserve the resolved klass.
|
||||
mirror_handle = Handle(THREAD, kk->java_mirror());
|
||||
// Do access check for klasses
|
||||
verify_constant_pool_resolve(this_cp, k, THREAD);
|
||||
}
|
||||
Handle mirror_handle;
|
||||
Symbol* name = entry.get_symbol();
|
||||
Handle loader (THREAD, this_cp->pool_holder()->class_loader());
|
||||
Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain());
|
||||
Klass* kk = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD);
|
||||
KlassHandle k (THREAD, kk);
|
||||
if (!HAS_PENDING_EXCEPTION) {
|
||||
// preserve the resolved klass from unloading
|
||||
mirror_handle = Handle(THREAD, kk->java_mirror());
|
||||
// Do access check for klasses
|
||||
verify_constant_pool_resolve(this_cp, k, THREAD);
|
||||
}
|
||||
|
||||
// Failed to resolve class. We must record the errors so that subsequent attempts
|
||||
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
MonitorLockerEx ml(this_cp->lock());
|
||||
// Failed to resolve class. We must record the errors so that subsequent attempts
|
||||
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_0);
|
||||
}
|
||||
|
||||
// some other thread has beaten us and has resolved the class.
|
||||
if (this_cp->tag_at(which).is_klass()) {
|
||||
CLEAR_PENDING_EXCEPTION;
|
||||
entry = this_cp->resolved_klass_at(which);
|
||||
return entry.get_klass();
|
||||
}
|
||||
// Make this class loader depend upon the class loader owning the class reference
|
||||
ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
|
||||
this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
|
||||
|
||||
// The tag could have changed to in-error before the lock but we have to
|
||||
// handle that here for the class case.
|
||||
save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_0);
|
||||
}
|
||||
|
||||
if (TraceClassResolution && !k()->oop_is_array()) {
|
||||
// skip resolving the constant pool so that this code get's
|
||||
// called the next time some bytecodes refer to this class.
|
||||
ResourceMark rm;
|
||||
int line_number = -1;
|
||||
const char * source_file = NULL;
|
||||
if (JavaThread::current()->has_last_Java_frame()) {
|
||||
// try to identify the method which called this function.
|
||||
vframeStream vfst(JavaThread::current());
|
||||
if (!vfst.at_end()) {
|
||||
line_number = vfst.method()->line_number_from_bci(vfst.bci());
|
||||
Symbol* s = vfst.method()->method_holder()->source_file_name();
|
||||
if (s != NULL) {
|
||||
source_file = s->as_C_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k() != this_cp->pool_holder()) {
|
||||
// only print something if the classes are different
|
||||
if (source_file != NULL) {
|
||||
tty->print("RESOLVE %s %s %s:%d\n",
|
||||
this_cp->pool_holder()->external_name(),
|
||||
InstanceKlass::cast(k())->external_name(), source_file, line_number);
|
||||
} else {
|
||||
tty->print("RESOLVE %s %s\n",
|
||||
this_cp->pool_holder()->external_name(),
|
||||
InstanceKlass::cast(k())->external_name());
|
||||
}
|
||||
}
|
||||
if (TraceClassResolution && !k->oop_is_array()) {
|
||||
// skip resolving the constant pool so that this code gets
|
||||
// called the next time some bytecodes refer to this class.
|
||||
trace_class_resolution(this_cp, k);
|
||||
return k();
|
||||
} else {
|
||||
MonitorLockerEx ml(this_cp->lock());
|
||||
// Only updated constant pool - if it is resolved.
|
||||
do_resolve = this_cp->tag_at(which).is_unresolved_klass();
|
||||
if (do_resolve) {
|
||||
ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
|
||||
this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
|
||||
this_cp->klass_at_put(which, k());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entry = this_cp->resolved_klass_at(which);
|
||||
assert(entry.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point");
|
||||
@ -576,7 +533,7 @@ Symbol* ConstantPool::exception_message(constantPoolHandle this_cp, int which, c
|
||||
switch (tag.value()) {
|
||||
case JVM_CONSTANT_UnresolvedClass:
|
||||
// return the class name in the error message
|
||||
message = this_cp->unresolved_klass_at(which);
|
||||
message = this_cp->klass_name_at(which);
|
||||
break;
|
||||
case JVM_CONSTANT_MethodHandle:
|
||||
// return the method handle name in the error message
|
||||
@ -606,7 +563,6 @@ void ConstantPool::throw_resolution_error(constantPoolHandle this_cp, int which,
|
||||
// in the resolution error table, so that the same exception is thrown again.
|
||||
void ConstantPool::save_and_throw_exception(constantPoolHandle this_cp, int which,
|
||||
constantTag tag, TRAPS) {
|
||||
assert(this_cp->lock()->is_locked(), "constant pool lock should be held");
|
||||
Symbol* error = PENDING_EXCEPTION->klass()->name();
|
||||
|
||||
int error_tag = tag.error_value();
|
||||
@ -620,7 +576,14 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_cp, int whic
|
||||
} else if (this_cp->tag_at(which).value() != error_tag) {
|
||||
Symbol* message = exception_message(this_cp, which, tag, PENDING_EXCEPTION);
|
||||
SystemDictionary::add_resolution_error(this_cp, which, error, message);
|
||||
this_cp->tag_at_put(which, error_tag);
|
||||
// CAS in the tag. If a thread beat us to registering this error that's fine.
|
||||
// If another thread resolved the reference, this is an error. The resolution
|
||||
// must deterministically get an error. So why do we save this?
|
||||
// We save this because jvmti can add classes to the bootclass path after this
|
||||
// error, so it needs to get the same error if the error is first.
|
||||
jbyte old_tag = Atomic::cmpxchg((jbyte)error_tag,
|
||||
(jbyte*)this_cp->tag_addr_at(which), (jbyte)tag.value());
|
||||
assert(old_tag == error_tag || old_tag == tag.value(), "should not be resolved otherwise");
|
||||
} else {
|
||||
// some other thread put this in error state
|
||||
throw_resolution_error(this_cp, which, CHECK);
|
||||
@ -710,7 +673,6 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index
|
||||
THREAD);
|
||||
result_oop = value();
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
MonitorLockerEx ml(this_cp->lock()); // lock cpool to change tag.
|
||||
save_and_throw_exception(this_cp, index, tag, CHECK_NULL);
|
||||
}
|
||||
break;
|
||||
@ -727,7 +689,6 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index
|
||||
Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD);
|
||||
result_oop = value();
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
MonitorLockerEx ml(this_cp->lock()); // lock cpool to change tag.
|
||||
save_and_throw_exception(this_cp, index, tag, CHECK_NULL);
|
||||
}
|
||||
break;
|
||||
@ -765,22 +726,17 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index
|
||||
}
|
||||
|
||||
if (cache_index >= 0) {
|
||||
// Cache the oop here also.
|
||||
Handle result_handle(THREAD, result_oop);
|
||||
MonitorLockerEx ml(this_cp->lock()); // don't know if we really need this
|
||||
oop result = this_cp->resolved_references()->obj_at(cache_index);
|
||||
// Benign race condition: resolved_references may already be filled in while we were trying to lock.
|
||||
// Benign race condition: resolved_references may already be filled in.
|
||||
// The important thing here is that all threads pick up the same result.
|
||||
// It doesn't matter which racing thread wins, as long as only one
|
||||
// result is used by all threads, and all future queries.
|
||||
// That result may be either a resolved constant or a failure exception.
|
||||
if (result == NULL) {
|
||||
this_cp->resolved_references()->obj_at_put(cache_index, result_handle());
|
||||
return result_handle();
|
||||
oop old_result = this_cp->resolved_references()->atomic_compare_exchange_oop(cache_index, result_oop, NULL);
|
||||
if (old_result == NULL) {
|
||||
return result_oop; // was installed
|
||||
} else {
|
||||
// Return the winning thread's result. This can be different than
|
||||
// result_handle() for MethodHandles.
|
||||
return result;
|
||||
// the result here for MethodHandles.
|
||||
return old_result;
|
||||
}
|
||||
} else {
|
||||
return result_oop;
|
||||
@ -853,9 +809,8 @@ bool ConstantPool::klass_name_at_matches(instanceKlassHandle k,
|
||||
}
|
||||
|
||||
|
||||
// Iterate over symbols and decrement ones which are Symbol*s.
|
||||
// This is done during GC so do not need to lock constantPool unless we
|
||||
// have per-thread safepoints.
|
||||
// Iterate over symbols and decrement ones which are Symbol*s
|
||||
// This is done during GC.
|
||||
// Only decrement the UTF8 symbols. Unresolved classes and strings point to
|
||||
// these symbols but didn't increment the reference count.
|
||||
void ConstantPool::unreference_symbols() {
|
||||
@ -987,8 +942,8 @@ bool ConstantPool::compare_entry_to(int index1, constantPoolHandle cp2,
|
||||
|
||||
case JVM_CONSTANT_UnresolvedClass:
|
||||
{
|
||||
Symbol* k1 = unresolved_klass_at(index1);
|
||||
Symbol* k2 = cp2->unresolved_klass_at(index2);
|
||||
Symbol* k1 = klass_name_at(index1);
|
||||
Symbol* k2 = cp2->klass_name_at(index2);
|
||||
if (k1 == k2) {
|
||||
return true;
|
||||
}
|
||||
@ -1970,7 +1925,6 @@ void ConstantPool::print_entry_on(const int index, outputStream* st) {
|
||||
break;
|
||||
case JVM_CONSTANT_UnresolvedClass : // fall-through
|
||||
case JVM_CONSTANT_UnresolvedClassInError: {
|
||||
// unresolved_klass_at requires lock or safe world.
|
||||
CPSlot entry = slot_at(index);
|
||||
if (entry.is_resolved()) {
|
||||
entry.get_klass()->print_value_on(st);
|
||||
|
@ -112,12 +112,12 @@ class ConstantPool : public Metadata {
|
||||
int _version;
|
||||
} _saved;
|
||||
|
||||
Monitor* _lock;
|
||||
|
||||
void set_tags(Array<u1>* tags) { _tags = tags; }
|
||||
void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); }
|
||||
void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); }
|
||||
|
||||
u1* tag_addr_at(int which) const { return tags()->adr_at(which); }
|
||||
|
||||
void set_operands(Array<u2>* operands) { _operands = operands; }
|
||||
|
||||
int flags() const { return _flags; }
|
||||
@ -362,14 +362,6 @@ class ConstantPool : public Metadata {
|
||||
return CPSlot((Klass*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_klass();
|
||||
}
|
||||
|
||||
// This method should only be used with a cpool lock or during parsing or gc
|
||||
Symbol* unresolved_klass_at(int which) { // Temporary until actual use
|
||||
Symbol* s = CPSlot((Symbol*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
|
||||
// check that the klass is still unresolved.
|
||||
assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool");
|
||||
return s;
|
||||
}
|
||||
|
||||
// RedefineClasses() API support:
|
||||
Symbol* klass_at_noresolve(int which) { return klass_name_at(which); }
|
||||
|
||||
@ -818,6 +810,8 @@ class ConstantPool : public Metadata {
|
||||
static Klass* klass_at_impl(constantPoolHandle this_cp, int which, TRAPS);
|
||||
static oop string_at_impl(constantPoolHandle this_cp, int which, int obj_index, TRAPS);
|
||||
|
||||
static void trace_class_resolution(constantPoolHandle this_cp, KlassHandle k);
|
||||
|
||||
// Resolve string constants (to prevent allocation during compilation)
|
||||
static void resolve_string_constants_impl(constantPoolHandle this_cp, TRAPS);
|
||||
|
||||
@ -848,8 +842,6 @@ class ConstantPool : public Metadata {
|
||||
|
||||
void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; }
|
||||
int resolved_reference_length() const { return _saved._resolved_reference_length; }
|
||||
void set_lock(Monitor* lock) { _lock = lock; }
|
||||
Monitor* lock() { return _lock; }
|
||||
|
||||
// Decrease ref counts of symbols that are in the constant pool
|
||||
// when the holder class is unloaded
|
||||
|
@ -286,7 +286,9 @@ void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool,
|
||||
// the lock, so that when the losing writer returns, he can use the linked
|
||||
// cache entry.
|
||||
|
||||
MonitorLockerEx ml(cpool->lock());
|
||||
// Use the lock from the metaspace for this, which cannot stop for safepoint.
|
||||
Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock();
|
||||
MutexLockerEx ml(metaspace_lock, Mutex::_no_safepoint_check_flag);
|
||||
if (!is_f1_null()) {
|
||||
return;
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ void Klass::restore_unshareable_info(TRAPS) {
|
||||
// Only recreate it if not present. A previous attempt to restore may have
|
||||
// gotten an OOM later but keep the mirror if it was created.
|
||||
if (java_mirror() == NULL) {
|
||||
java_lang_Class::create_mirror(this, Handle(NULL), CHECK);
|
||||
java_lang_Class::create_mirror(this, Handle(NULL), Handle(NULL), CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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,22 @@
|
||||
#include "oops/objArrayOop.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
|
||||
oop objArrayOopDesc::atomic_compare_exchange_oop(int index, oop exchange_value,
|
||||
oop compare_value) {
|
||||
volatile HeapWord* dest;
|
||||
if (UseCompressedOops) {
|
||||
dest = (HeapWord*)obj_at_addr<narrowOop>(index);
|
||||
} else {
|
||||
dest = (HeapWord*)obj_at_addr<oop>(index);
|
||||
}
|
||||
oop res = oopDesc::atomic_compare_exchange_oop(exchange_value, dest, compare_value, true);
|
||||
// update card mark if success
|
||||
if (res == compare_value) {
|
||||
update_barrier_set((void*)dest, exchange_value);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#define ObjArrayOop_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
|
||||
\
|
||||
int objArrayOopDesc::oop_iterate_range(OopClosureType* blk, int start, int end) { \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, 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
|
||||
@ -95,6 +95,9 @@ private:
|
||||
oop_store(obj_at_addr<oop>(index), value);
|
||||
}
|
||||
}
|
||||
|
||||
oop atomic_compare_exchange_oop(int index, oop exchange_value, oop compare_value);
|
||||
|
||||
// Sizing
|
||||
static int header_size() { return arrayOopDesc::header_size(T_OBJECT); }
|
||||
int object_size() { return object_size(length()); }
|
||||
|
@ -3336,13 +3336,7 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {
|
||||
directBufferSupportInitializeEnded = 1;
|
||||
} else {
|
||||
while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) {
|
||||
// Set state as yield_all can call os:sleep. On Solaris, yield_all calls
|
||||
// os::sleep which requires the VM state transition. On other platforms, it
|
||||
// is not necessary. The following call to change the VM state is purposely
|
||||
// put inside the loop to avoid potential deadlock when multiple threads
|
||||
// try to call this method. See 6791815 for more details.
|
||||
ThreadInVMfromNative tivn(thread);
|
||||
os::yield_all();
|
||||
os::yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,9 +258,6 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) {
|
||||
// VM representation. We don't attach the reconstituted class
|
||||
// bytes to the InstanceKlass here because they have not been
|
||||
// validated and we're not at a safepoint.
|
||||
constantPoolHandle constants(current_thread, ikh->constants());
|
||||
MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it
|
||||
|
||||
JvmtiClassFileReconstituter reconstituter(ikh);
|
||||
if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
|
||||
return reconstituter.get_error();
|
||||
@ -2445,9 +2442,6 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
|
||||
}
|
||||
|
||||
instanceKlassHandle ikh(thread, k_oop);
|
||||
constantPoolHandle constants(thread, ikh->constants());
|
||||
MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it
|
||||
|
||||
JvmtiConstantPoolReconstituter reconstituter(ikh);
|
||||
if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
|
||||
return reconstituter.get_error();
|
||||
@ -2467,6 +2461,7 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
|
||||
return reconstituter.get_error();
|
||||
}
|
||||
|
||||
constantPoolHandle constants(thread, ikh->constants());
|
||||
*constant_pool_count_ptr = constants->length();
|
||||
*constant_pool_byte_count_ptr = cpool_size;
|
||||
*constant_pool_bytes_ptr = cpool_bytes;
|
||||
|
@ -891,6 +891,14 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring nam
|
||||
}
|
||||
UNSAFE_END
|
||||
|
||||
static jobject get_class_loader(JNIEnv* env, jclass cls) {
|
||||
if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) {
|
||||
return NULL;
|
||||
}
|
||||
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
|
||||
oop loader = k->class_loader();
|
||||
return JNIHandles::make_local(env, loader);
|
||||
}
|
||||
|
||||
UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length))
|
||||
UnsafeWrapper("Unsafe_DefineClass");
|
||||
@ -899,7 +907,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na
|
||||
|
||||
int depthFromDefineClass0 = 1;
|
||||
jclass caller = JVM_GetCallerClass(env, depthFromDefineClass0);
|
||||
jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller);
|
||||
jobject loader = (caller == NULL) ? NULL : get_class_loader(env, caller);
|
||||
jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller);
|
||||
|
||||
return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);
|
||||
|
@ -453,8 +453,6 @@ class os: AllStatic {
|
||||
// yield that can be used in lieu of blocking.
|
||||
} ;
|
||||
static YieldResult NakedYield () ;
|
||||
static void yield_all(); // Yields to all other threads including lower priority
|
||||
// (for the default scheduling policy)
|
||||
static OSReturn set_priority(Thread* thread, ThreadPriority priority);
|
||||
static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);
|
||||
|
||||
|
@ -264,8 +264,8 @@ void SafepointSynchronize::begin() {
|
||||
//
|
||||
// Further complicating matters is that yield() does not work as naively expected
|
||||
// on many platforms -- yield() does not guarantee that any other ready threads
|
||||
// will run. As such we revert yield_all() after some number of iterations.
|
||||
// Yield_all() is implemented as a short unconditional sleep on some platforms.
|
||||
// will run. As such we revert to naked_short_sleep() after some number of iterations.
|
||||
// nakes_short_sleep() is implemented as a short unconditional sleep.
|
||||
// Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping
|
||||
// can actually increase the time it takes the VM thread to detect that a system-wide
|
||||
// stop-the-world safepoint has been reached. In a pathological scenario such as that
|
||||
@ -322,9 +322,7 @@ void SafepointSynchronize::begin() {
|
||||
if (steps < DeferThrSuspendLoopCount) {
|
||||
os::NakedYield() ;
|
||||
} else {
|
||||
os::yield_all() ;
|
||||
// Alternately, the VM thread could transiently depress its scheduling priority or
|
||||
// transiently increase the priority of the tardy mutator(s).
|
||||
os::naked_short_sleep(1);
|
||||
}
|
||||
|
||||
iterations ++ ;
|
||||
@ -744,80 +742,12 @@ void SafepointSynchronize::block(JavaThread *thread) {
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// Exception handlers
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
#ifdef SPARC
|
||||
|
||||
#ifdef _LP64
|
||||
#define PTR_PAD ""
|
||||
#else
|
||||
#define PTR_PAD " "
|
||||
#endif
|
||||
|
||||
static void print_ptrs(intptr_t oldptr, intptr_t newptr, bool wasoop) {
|
||||
bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false;
|
||||
tty->print_cr(PTR_FORMAT PTR_PAD " %s %c " PTR_FORMAT PTR_PAD " %s %s",
|
||||
oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!',
|
||||
newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
|
||||
}
|
||||
|
||||
static void print_longs(jlong oldptr, jlong newptr, bool wasoop) {
|
||||
bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false;
|
||||
tty->print_cr(PTR64_FORMAT " %s %c " PTR64_FORMAT " %s %s",
|
||||
oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!',
|
||||
newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
|
||||
}
|
||||
|
||||
static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) {
|
||||
#ifdef _LP64
|
||||
tty->print_cr("--------+------address-----+------before-----------+-------after----------+");
|
||||
const int incr = 1; // Increment to skip a long, in units of intptr_t
|
||||
#else
|
||||
tty->print_cr("--------+--address-+------before-----------+-------after----------+");
|
||||
const int incr = 2; // Increment to skip a long, in units of intptr_t
|
||||
#endif
|
||||
tty->print_cr("---SP---|");
|
||||
for( int i=0; i<16; i++ ) {
|
||||
tty->print("blob %c%d |"PTR_FORMAT" ","LO"[i>>3],i&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
|
||||
tty->print_cr("--------|");
|
||||
for( int i1=0; i1<frame::memory_parameter_word_sp_offset-16; i1++ ) {
|
||||
tty->print("argv pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
|
||||
tty->print(" pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++);
|
||||
tty->print_cr("--------|");
|
||||
tty->print(" G1 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
|
||||
tty->print(" G3 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
|
||||
tty->print(" G4 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
|
||||
tty->print(" G5 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
|
||||
tty->print_cr(" FSR |"PTR_FORMAT" "PTR64_FORMAT" "PTR64_FORMAT,new_sp,*(jlong*)old_sp,*(jlong*)new_sp);
|
||||
old_sp += incr; new_sp += incr; was_oops += incr;
|
||||
// Skip the floats
|
||||
tty->print_cr("--Float-|"PTR_FORMAT,new_sp);
|
||||
tty->print_cr("---FP---|");
|
||||
old_sp += incr*32; new_sp += incr*32; was_oops += incr*32;
|
||||
for( int i2=0; i2<16; i2++ ) {
|
||||
tty->print("call %c%d |"PTR_FORMAT" ","LI"[i2>>3],i2&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
|
||||
tty->cr();
|
||||
}
|
||||
#endif // SPARC
|
||||
#endif // PRODUCT
|
||||
|
||||
|
||||
void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
|
||||
assert(thread->is_Java_thread(), "polling reference encountered by VM thread");
|
||||
assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
|
||||
assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
|
||||
|
||||
// Uncomment this to get some serious before/after printing of the
|
||||
// Sparc safepoint-blob frame structure.
|
||||
/*
|
||||
intptr_t* sp = thread->last_Java_sp();
|
||||
intptr_t stack_copy[150];
|
||||
for( int i=0; i<150; i++ ) stack_copy[i] = sp[i];
|
||||
bool was_oops[150];
|
||||
for( int i=0; i<150; i++ )
|
||||
was_oops[i] = stack_copy[i] ? ((oop)stack_copy[i])->is_oop() : false;
|
||||
*/
|
||||
|
||||
if (ShowSafepointMsgs) {
|
||||
tty->print("handle_polling_page_exception: ");
|
||||
}
|
||||
@ -829,7 +759,6 @@ void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
|
||||
ThreadSafepointState* state = thread->safepoint_state();
|
||||
|
||||
state->handle_polling_page_exception();
|
||||
// print_me(sp,stack_copy,was_oops);
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,6 +104,7 @@
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/hashtable.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
|
||||
#ifdef TARGET_ARCH_x86
|
||||
# include "vmStructs_x86.hpp"
|
||||
#endif
|
||||
@ -168,6 +169,11 @@
|
||||
#include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
|
||||
#include "gc_implementation/g1/vmStructs_g1.hpp"
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
#include "runtime/vmStructs_trace.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef COMPILER2
|
||||
#include "opto/addnode.hpp"
|
||||
#include "opto/block.hpp"
|
||||
@ -1390,6 +1396,8 @@ typedef TwoOopHashtable<Symbol*, mtClass> SymbolTwoOopHashtable;
|
||||
/* unsigned short on Win32 */ \
|
||||
declare_unsigned_integer_type(u1) \
|
||||
declare_unsigned_integer_type(u2) \
|
||||
declare_unsigned_integer_type(u4) \
|
||||
declare_unsigned_integer_type(u8) \
|
||||
declare_unsigned_integer_type(unsigned) \
|
||||
\
|
||||
/*****************************/ \
|
||||
@ -2923,6 +2931,11 @@ VMStructEntry VMStructs::localHotSpotVMStructs[] = {
|
||||
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
VM_STRUCTS_TRACE(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
||||
#endif
|
||||
|
||||
VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
GENERATE_STATIC_VM_STRUCT_ENTRY,
|
||||
GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
@ -2968,6 +2981,11 @@ VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
|
||||
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
VM_TYPES_TRACE(GENERATE_VM_TYPE_ENTRY,
|
||||
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
||||
#endif
|
||||
|
||||
VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
|
||||
GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
|
||||
GENERATE_OOP_VM_TYPE_ENTRY,
|
||||
@ -3003,6 +3021,10 @@ VMIntConstantEntry VMStructs::localHotSpotVMIntConstants[] = {
|
||||
VM_INT_CONSTANTS_PARNEW(GENERATE_VM_INT_CONSTANT_ENTRY)
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
VM_INT_CONSTANTS_TRACE(GENERATE_VM_INT_CONSTANT_ENTRY)
|
||||
#endif
|
||||
|
||||
VM_INT_CONSTANTS_CPU(GENERATE_VM_INT_CONSTANT_ENTRY,
|
||||
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
|
||||
GENERATE_C1_VM_INT_CONSTANT_ENTRY,
|
||||
@ -3065,8 +3087,14 @@ VMStructs::init() {
|
||||
|
||||
VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_STATIC_VM_STRUCT_ENTRY);
|
||||
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
VM_STRUCTS_TRACE(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_STATIC_VM_STRUCT_ENTRY);
|
||||
#endif
|
||||
|
||||
VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_STATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_NO_OP,
|
||||
@ -3105,8 +3133,14 @@ VMStructs::init() {
|
||||
|
||||
VM_TYPES_G1(CHECK_VM_TYPE_ENTRY,
|
||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
||||
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
VM_TYPES_TRACE(CHECK_VM_TYPE_ENTRY,
|
||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
||||
#endif
|
||||
|
||||
VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
|
||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
|
||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
|
||||
@ -3169,6 +3203,12 @@ VMStructs::init() {
|
||||
debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT,
|
||||
ENSURE_FIELD_TYPE_PRESENT));
|
||||
#endif // INCLUDE_ALL_GCS
|
||||
|
||||
#if INCLUDE_TRACE
|
||||
debug_only(VM_STRUCTS_TRACE(ENSURE_FIELD_TYPE_PRESENT,
|
||||
ENSURE_FIELD_TYPE_PRESENT));
|
||||
#endif
|
||||
|
||||
debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT,
|
||||
ENSURE_FIELD_TYPE_PRESENT,
|
||||
CHECK_NO_OP,
|
||||
|
35
hotspot/src/share/vm/runtime/vmStructs_trace.hpp
Normal file
35
hotspot/src/share/vm/runtime/vmStructs_trace.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP
|
||||
#define SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP
|
||||
|
||||
#define VM_INT_CONSTANTS_TRACE(a)
|
||||
|
||||
#define VM_STRUCTS_TRACE(a, b)
|
||||
|
||||
#define VM_TYPES_TRACE(a, b)
|
||||
|
||||
|
||||
#endif // SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP
|
@ -72,14 +72,16 @@ int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
|
||||
#ifndef JRE_RELEASE_VERSION
|
||||
#error JRE_RELEASE_VERSION must be defined
|
||||
#endif
|
||||
#ifndef HOTSPOT_BUILD_TARGET
|
||||
#error HOTSPOT_BUILD_TARGET must be defined
|
||||
#endif
|
||||
|
||||
#ifdef PRODUCT
|
||||
#define VM_RELEASE HOTSPOT_RELEASE_VERSION
|
||||
#else
|
||||
// NOTE: Builds within Visual Studio do not define the build target in
|
||||
// HOTSPOT_RELEASE_VERSION, so it must be done here
|
||||
#if defined(VISUAL_STUDIO_BUILD) && !defined(PRODUCT)
|
||||
#ifndef HOTSPOT_BUILD_TARGET
|
||||
#error HOTSPOT_BUILD_TARGET must be defined
|
||||
#endif
|
||||
#define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET
|
||||
#else
|
||||
#define VM_RELEASE HOTSPOT_RELEASE_VERSION
|
||||
#endif
|
||||
|
||||
// HOTSPOT_RELEASE_VERSION follows the JDK release version naming convention
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, 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
|
||||
@ -481,17 +481,9 @@ class MemTracker : AllStatic {
|
||||
if (_slowdown_calling_thread && thr != _worker_thread) {
|
||||
#ifdef _WINDOWS
|
||||
// On Windows, os::NakedYield() does not work as well
|
||||
// as os::yield_all()
|
||||
os::yield_all();
|
||||
// as short sleep.
|
||||
os::naked_short_sleep(1);
|
||||
#else
|
||||
// On Solaris, os::yield_all() depends on os::sleep()
|
||||
// which requires JavaTherad in _thread_in_vm state.
|
||||
// Transits thread to _thread_in_vm state can be dangerous
|
||||
// if caller holds lock, as it may deadlock with Threads_lock.
|
||||
// So use NaKedYield instead.
|
||||
//
|
||||
// Linux and BSD, NakedYield() and yield_all() implementations
|
||||
// are the same.
|
||||
os::NakedYield();
|
||||
#endif
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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 8001071
|
||||
## @summary Add simple range check into VM implemenation of Unsafe access methods
|
||||
## @compile Test8001071.java
|
||||
## @run shell Test8001071.sh
|
||||
## @author filipp.zhinkin@oracle.com
|
||||
|
||||
VERSION=`${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1`
|
||||
|
||||
if [ -n "`echo $VERSION | grep debug`" -o -n "`echo $VERSION | grep jvmg`" ]; then
|
||||
echo "Build type check passed"
|
||||
echo "Continue testing"
|
||||
else
|
||||
echo "Fastdebug build is required for this test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${TESTJAVA}/bin/java -cp ${TESTCLASSES} ${TESTVMOPTS} Test8001071 2>&1
|
||||
|
||||
HS_ERR_FILE=hs_err_pid*.log
|
||||
|
||||
if [ ! -f $HS_ERR_FILE ]
|
||||
then
|
||||
echo "hs_err_pid log file was not found"
|
||||
echo "Test failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
grep "assert(byte_offset < p_size) failed: Unsafe access: offset.*> object's size.*" $HS_ERR_FILE
|
||||
|
||||
if [ "0" = "$?" ];
|
||||
then
|
||||
echo "Range check assertion failed as expected"
|
||||
echo "Test passed"
|
||||
exit 0
|
||||
else
|
||||
echo "Range check assertion was not failed"
|
||||
echo "Test failed"
|
||||
exit 1
|
||||
fi
|
@ -44,8 +44,16 @@ public class XShareAuto {
|
||||
"-server", "-XX:+UnlockDiagnosticVMOptions",
|
||||
"-XX:SharedArchiveFile=./sample.jsa", "-version");
|
||||
output = new OutputAnalyzer(pb.start());
|
||||
output.shouldNotContain("sharing");
|
||||
output.shouldHaveExitValue(0);
|
||||
// We asked for server but it could be aliased to something else
|
||||
if (output.getOutput().contains("Server VM")) {
|
||||
// In server case we don't expect to see sharing flag
|
||||
output.shouldNotContain("sharing");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
else {
|
||||
System.out.println("Skipping test - no Server VM available");
|
||||
return;
|
||||
}
|
||||
|
||||
pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions",
|
||||
|
58
hotspot/test/runtime/Unsafe/RangeCheck.java
Normal file
58
hotspot/test/runtime/Unsafe/RangeCheck.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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 8001071
|
||||
* @summary Add simple range check into VM implemenation of Unsafe access methods
|
||||
* @library /testlibrary
|
||||
*/
|
||||
|
||||
import com.oracle.java.testlibrary.*;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public class RangeCheck {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
if (!Platform.isDebugBuild()) {
|
||||
System.out.println("Testing assert which requires a debug build. Passing silently.");
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
true,
|
||||
"-Xmx32m",
|
||||
"-XX:-TransmitErrorReport",
|
||||
DummyClassWithMainRangeCheck.class.getName());
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldMatch("assert\\(byte_offset < p_size\\) failed: Unsafe access: offset \\d+ > object's size \\d+");
|
||||
}
|
||||
|
||||
public static class DummyClassWithMainRangeCheck {
|
||||
public static void main(String args[]) throws Exception {
|
||||
Unsafe unsafe = Utils.getUnsafe();
|
||||
unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ public class ReadFromNoaccessArea {
|
||||
"-XX:+WhiteBoxAPI",
|
||||
"-XX:+UseCompressedOops",
|
||||
"-XX:HeapBaseMinAddress=33G",
|
||||
"-Xmx32m",
|
||||
DummyClassWithMainTryingToReadFromNoaccessArea.class.getName());
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
|
@ -57,6 +57,7 @@ public class ReserveMemory {
|
||||
"-XX:+UnlockDiagnosticVMOptions",
|
||||
"-XX:+WhiteBoxAPI",
|
||||
"-XX:-TransmitErrorReport",
|
||||
"-Xmx32m",
|
||||
"ReserveMemory",
|
||||
"test");
|
||||
|
||||
|
148
hotspot/test/runtime/verifier/TestANewArray.java
Normal file
148
hotspot/test/runtime/verifier/TestANewArray.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
import com.oracle.java.testlibrary.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test that anewarray bytecode is valid only if it specifies 255 or fewer dimensions.
|
||||
* @library /testlibrary
|
||||
* @compile -XDignore.symbol.file TestANewArray.java
|
||||
* @run main/othervm TestANewArray 49
|
||||
* @run main/othervm TestANewArray 50
|
||||
* @run main/othervm TestANewArray 51
|
||||
* @run main/othervm TestANewArray 52
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing anewarray instruction with 254, 255 & 264 dimensions to verify JVMS 8,
|
||||
* Section 4.9.1, Static Constraints that states the following:
|
||||
*
|
||||
* "No anewarray instruction may be used to create an array of more than 255 dimensions."
|
||||
*
|
||||
*/
|
||||
|
||||
public class TestANewArray {
|
||||
|
||||
static String classCName = null; // the generated class name
|
||||
|
||||
static final int test_Dimension_254 = 254; // should always pass
|
||||
static final int test_Dimension_255 = 255; // should always pass, except for cfv 49
|
||||
static final int test_Dimension_264 = 264; // should always fail
|
||||
|
||||
static final String array_Dimension_254 = genArrayDim(test_Dimension_254);
|
||||
static final String array_Dimension_255 = genArrayDim(test_Dimension_255);
|
||||
static final String array_Dimension_264 = genArrayDim(test_Dimension_264);
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
int cfv = Integer.parseInt(args[0]);
|
||||
|
||||
// 254 array dimensions
|
||||
byte[] classFile_254 = dumpClassFile(cfv, test_Dimension_254, array_Dimension_254);
|
||||
writeClassFileFromByteArray(classFile_254);
|
||||
System.err.println("Running with cfv: " + cfv + ", test_Dimension_254");
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName);
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldNotContain("java.lang.VerifyError");
|
||||
output.shouldHaveExitValue(0);
|
||||
|
||||
// 255 array dimensions
|
||||
byte[] classFile_255 = dumpClassFile(cfv, test_Dimension_255, array_Dimension_255);
|
||||
writeClassFileFromByteArray(classFile_255);
|
||||
System.err.println("Running with cfv: " + cfv + ", test_Dimension_255");
|
||||
pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName);
|
||||
output = new OutputAnalyzer(pb.start());
|
||||
if (cfv == 49) {
|
||||
// The type-inferencing verifier used for <=49.0 ClassFiles detects an anewarray instruction
|
||||
// with exactly 255 dimensions and incorrectly issues the "Array with too many dimensions" VerifyError.
|
||||
output.shouldContain("Array with too many dimensions");
|
||||
output.shouldHaveExitValue(1);
|
||||
} else {
|
||||
// 255 dimensions should always pass, except for cfv 49
|
||||
output.shouldNotContain("java.lang.VerifyError");
|
||||
output.shouldNotContain("java.lang.ClassFormatError");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
// 264 array dimensions
|
||||
byte[] classFile_264 = dumpClassFile(cfv, test_Dimension_264, array_Dimension_264);
|
||||
writeClassFileFromByteArray(classFile_264);
|
||||
System.err.println("Running with cfv: " + cfv + ", test_Dimension_264");
|
||||
pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName);
|
||||
output = new OutputAnalyzer(pb.start());
|
||||
output.shouldContain("java.lang.ClassFormatError");
|
||||
output.shouldHaveExitValue(1);
|
||||
}
|
||||
|
||||
public static byte[] dumpClassFile(int cfv, int testDimension264, String arrayDim) throws Exception {
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
MethodVisitor mv;
|
||||
|
||||
classCName = "classCName_" + cfv + "_" + testDimension264;
|
||||
|
||||
cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, classCName, null, "java/lang/Object", null);
|
||||
{
|
||||
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
mv.visitCode();
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(1, 1);
|
||||
mv.visitEnd();
|
||||
}
|
||||
{ // classCName main method
|
||||
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
|
||||
mv.visitCode();
|
||||
mv.visitIntInsn(BIPUSH, 1);
|
||||
mv.visitTypeInsn(ANEWARRAY, arrayDim); // Test ANEWARRAY bytecode with various dimensions
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(2, 2);
|
||||
mv.visitEnd();
|
||||
}
|
||||
cw.visitEnd();
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
public static FileOutputStream writeClassFileFromByteArray(byte[] classFileByteArray) throws Exception {
|
||||
FileOutputStream fos = new FileOutputStream(new File(classCName + ".class"));
|
||||
fos.write(classFileByteArray);
|
||||
fos.close();
|
||||
return fos;
|
||||
}
|
||||
|
||||
private static String genArrayDim(int testDim) {
|
||||
StringBuilder array_Dimension = new StringBuilder();
|
||||
for (int i = 0; i < testDim; i++)
|
||||
{
|
||||
array_Dimension.append("[");
|
||||
}
|
||||
return array_Dimension.append("Ljava/lang/Object;").toString();
|
||||
}
|
||||
}
|
@ -260,3 +260,4 @@ e88cecf5a21b760ff7d7761c2db6bb8c82bc9f0c jdk9-b12
|
||||
6bad71866c7598587860e0981b0b0e51ec8c0476 jdk9-b15
|
||||
a1461221b05d4620e4d7d1907e2a0282aaedf31c jdk9-b16
|
||||
6f923fcbe5129eceb9617a9a18dbdd743980e785 jdk9-b17
|
||||
5afa90c28742d175431be75f9098745510bd2b30 jdk9-b18
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -32,7 +34,6 @@ import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import javax.xml.transform.Templates;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.w3c.dom.Document;
|
||||
@ -51,6 +52,7 @@ import com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.serializer.ToStream;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -74,7 +76,7 @@ public abstract class AbstractTranslet implements Translet {
|
||||
public String _doctypeSystem = null;
|
||||
public boolean _indent = false;
|
||||
public String _mediaType = null;
|
||||
public Vector _cdata = null;
|
||||
public ArrayList<String> _cdata = null;
|
||||
public int _indentamount = -1;
|
||||
|
||||
public static final int FIRST_TRANSLET_VERSION = 100;
|
||||
@ -642,7 +644,7 @@ public abstract class AbstractTranslet implements Translet {
|
||||
*/
|
||||
public void addCdataElement(String name) {
|
||||
if (_cdata == null) {
|
||||
_cdata = new Vector();
|
||||
_cdata = new ArrayList<>();
|
||||
}
|
||||
|
||||
int lastColon = name.lastIndexOf(':');
|
||||
@ -650,11 +652,11 @@ public abstract class AbstractTranslet implements Translet {
|
||||
if (lastColon > 0) {
|
||||
String uri = name.substring(0, lastColon);
|
||||
String localName = name.substring(lastColon+1);
|
||||
_cdata.addElement(uri);
|
||||
_cdata.addElement(localName);
|
||||
_cdata.add(uri);
|
||||
_cdata.add(localName);
|
||||
} else {
|
||||
_cdata.addElement(null);
|
||||
_cdata.addElement(name);
|
||||
_cdata.add(null);
|
||||
_cdata.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -40,7 +42,7 @@ import java.net.UnknownServiceException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -1084,7 +1086,7 @@ public final class TransformerImpl extends Transformer
|
||||
else if (name.equals(OutputKeys.CDATA_SECTION_ELEMENTS)) {
|
||||
if (value != null) {
|
||||
StringTokenizer e = new StringTokenizer(value);
|
||||
Vector uriAndLocalNames = null;
|
||||
ArrayList<String> uriAndLocalNames = null;
|
||||
while (e.hasMoreTokens()) {
|
||||
final String token = e.nextToken();
|
||||
|
||||
@ -1104,11 +1106,11 @@ public final class TransformerImpl extends Transformer
|
||||
}
|
||||
|
||||
if (uriAndLocalNames == null) {
|
||||
uriAndLocalNames = new Vector();
|
||||
uriAndLocalNames = new ArrayList<>();
|
||||
}
|
||||
// add the uri/localName as a pair, in that order
|
||||
uriAndLocalNames.addElement(uri);
|
||||
uriAndLocalNames.addElement(localName);
|
||||
uriAndLocalNames.add(uri);
|
||||
uriAndLocalNames.add(localName);
|
||||
}
|
||||
handler.setCdataSectionElements(uriAndLocalNames);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ implements EntityReference {
|
||||
* @see DocumentTypeImpl
|
||||
* @see EntityImpl
|
||||
*/
|
||||
// The Xerces parser invokes callbacks for startEnityReference
|
||||
// The Xerces parser invokes callbacks for startEntityReference
|
||||
// the parsed value of the entity EACH TIME, so it is actually
|
||||
// easier to create the nodes through the callbacks rather than
|
||||
// clone the Entity.
|
||||
|
@ -585,7 +585,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
boolean reportEntity = fReportEntity;
|
||||
if (name.startsWith("%")) {
|
||||
reportEntity = peekReportEntity();
|
||||
// check well-formedness of the enity
|
||||
// check well-formedness of the entity
|
||||
int startMarkUpDepth = popPEStack();
|
||||
// throw fatalError if this entity was incomplete and
|
||||
// was a freestanding decl
|
||||
|
@ -2728,7 +2728,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
//if the last section was character data
|
||||
if(fLastSectionWasCharacterData){
|
||||
|
||||
//if we dont encounter any CDATA or ENITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA
|
||||
//if we dont encounter any CDATA or ENTITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA
|
||||
//return the last scanned charactrer data.
|
||||
if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE)
|
||||
&& (fScannerState != SCANNER_STATE_CHARACTER_DATA)){
|
||||
|
@ -1218,7 +1218,7 @@ public class XMLDTDValidator
|
||||
// references appear in the document.
|
||||
// REVISIT: this can be combined to a single check in
|
||||
// startEntity if we add one more argument in
|
||||
// startEnity, inAttrValue
|
||||
// startEntity, inAttrValue
|
||||
String nonNormalizedValue = attributes.getNonNormalizedValue(i);
|
||||
if (nonNormalizedValue != null) {
|
||||
String entityName = getExternalEntityRefInAttrValue(nonNormalizedValue);
|
||||
|
@ -559,11 +559,13 @@ final class ElementSchemePointer implements XPointerPart {
|
||||
* @param token The token string
|
||||
*/
|
||||
private void addToken(String tokenStr) {
|
||||
if (!fTokenNames.containsValue(tokenStr)) {
|
||||
Integer tokenInt = new Integer(fTokenNames.size());
|
||||
String str = fTokenNames.get(tokenStr);
|
||||
Integer tokenInt = str == null ? null : Integer.parseInt(str);
|
||||
if (tokenInt == null) {
|
||||
tokenInt = new Integer(fTokenNames.size());
|
||||
fTokenNames.put(tokenInt, tokenStr);
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -524,11 +524,13 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
* @param token The token string
|
||||
*/
|
||||
private void addToken(String tokenStr) {
|
||||
if (!fTokenNames.containsValue(tokenStr)) {
|
||||
Integer tokenInt = new Integer(fTokenNames.size());
|
||||
String str = fTokenNames.get(tokenStr);
|
||||
Integer tokenInt = str == null ? null : Integer.parseInt(str);
|
||||
if (tokenInt == null) {
|
||||
tokenInt = new Integer(fTokenNames.size());
|
||||
fTokenNames.put(tokenInt, tokenStr);
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1251,4 +1253,4 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
super.setProperty(propertyId, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class DTMConfigurationException extends DTMException {
|
||||
|
||||
/**
|
||||
* Create a new <code>DTMConfigurationException</code> with no
|
||||
* detail mesage.
|
||||
* detail message.
|
||||
*/
|
||||
public DTMConfigurationException() {
|
||||
super("Configuration Error");
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2003-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -27,7 +29,7 @@ import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import javax.xml.transform.Transformer;
|
||||
@ -150,9 +152,9 @@ public class EmptySerializer implements SerializationHandler
|
||||
couldThrowIOException();
|
||||
}
|
||||
/**
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.Vector)
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
|
||||
*/
|
||||
public void setCdataSectionElements(Vector URI_and_localNames)
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
aMethodIsCalled();
|
||||
}
|
||||
@ -763,4 +765,25 @@ public class EmptySerializer implements SerializationHandler
|
||||
aMethodIsCalled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getOutputProperty(String name) {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getOutputPropertyDefault(String name) {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOutputProperty(String name, String val) {
|
||||
aMethodIsCalled();
|
||||
|
||||
}
|
||||
|
||||
public void setOutputPropertyDefault(String name, String val) {
|
||||
aMethodIsCalled();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -23,8 +25,11 @@
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import javax.xml.transform.Transformer;
|
||||
|
||||
@ -108,12 +113,12 @@ public abstract class SerializerBase
|
||||
/**
|
||||
* The System ID for the doc type.
|
||||
*/
|
||||
private String m_doctypeSystem;
|
||||
protected String m_doctypeSystem;
|
||||
|
||||
/**
|
||||
* The public ID for the doc type.
|
||||
*/
|
||||
private String m_doctypePublic;
|
||||
protected String m_doctypePublic;
|
||||
|
||||
/**
|
||||
* Flag to tell that we need to add the doctype decl, which we can't do
|
||||
@ -121,16 +126,10 @@ public abstract class SerializerBase
|
||||
*/
|
||||
boolean m_needToOutputDocTypeDecl = true;
|
||||
|
||||
/**
|
||||
* The character encoding. Must match the encoding used for the
|
||||
* printWriter.
|
||||
*/
|
||||
private String m_encoding = null;
|
||||
|
||||
/**
|
||||
* Tells if we should write the XML declaration.
|
||||
*/
|
||||
private boolean m_shouldNotWriteXMLHeader = false;
|
||||
protected boolean m_shouldNotWriteXMLHeader = false;
|
||||
|
||||
/**
|
||||
* The standalone value for the doctype.
|
||||
@ -159,12 +158,12 @@ public abstract class SerializerBase
|
||||
/**
|
||||
* Tells the XML version, for writing out to the XML decl.
|
||||
*/
|
||||
private String m_version = null;
|
||||
protected String m_version = null;
|
||||
|
||||
/**
|
||||
* The mediatype. Not used right now.
|
||||
*/
|
||||
private String m_mediatype;
|
||||
protected String m_mediatype;
|
||||
|
||||
/**
|
||||
* The transformer that was around when this output handler was created (if
|
||||
@ -172,13 +171,6 @@ public abstract class SerializerBase
|
||||
*/
|
||||
private Transformer m_transformer;
|
||||
|
||||
/**
|
||||
* Pairs of local names and corresponding URIs of CDATA sections. This list
|
||||
* comes from the cdata-section-elements attribute. Every second one is a
|
||||
* local name, and every other second one is the URI for the local name.
|
||||
*/
|
||||
protected Vector m_cdataSectionElements = null;
|
||||
|
||||
/**
|
||||
* Namespace support, that keeps track of currently defined
|
||||
* prefix/uri mappings. As processed elements come and go, so do
|
||||
@ -538,16 +530,16 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public String getEncoding()
|
||||
{
|
||||
return m_encoding;
|
||||
return getOutputProperty(OutputKeys.ENCODING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
|
||||
* @param m_encoding the character encoding
|
||||
*/
|
||||
public void setEncoding(String m_encoding)
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.m_encoding = m_encoding;
|
||||
setOutputProperty(OutputKeys.ENCODING,encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -557,7 +549,8 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setOmitXMLDeclaration(boolean b)
|
||||
{
|
||||
this.m_shouldNotWriteXMLHeader = b;
|
||||
String val = b ? "yes":"no";
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,val);
|
||||
}
|
||||
|
||||
|
||||
@ -588,7 +581,7 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setDoctypePublic(String doctypePublic)
|
||||
{
|
||||
this.m_doctypePublic = doctypePublic;
|
||||
setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
|
||||
}
|
||||
|
||||
|
||||
@ -610,7 +603,7 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setDoctypeSystem(String doctypeSystem)
|
||||
{
|
||||
this.m_doctypeSystem = doctypeSystem;
|
||||
setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
|
||||
}
|
||||
|
||||
/** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
|
||||
@ -621,8 +614,8 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setDoctype(String doctypeSystem, String doctypePublic)
|
||||
{
|
||||
this.m_doctypeSystem = doctypeSystem;
|
||||
this.m_doctypePublic = doctypePublic;
|
||||
setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
|
||||
setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -634,12 +627,9 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setStandalone(String standalone)
|
||||
{
|
||||
if (standalone != null)
|
||||
{
|
||||
m_standaloneWasSpecified = true;
|
||||
setStandaloneInternal(standalone);
|
||||
}
|
||||
setOutputProperty(OutputKeys.STANDALONE, standalone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XSL standalone attribute, but does not remember if this is a
|
||||
* default or explicite setting.
|
||||
@ -700,7 +690,7 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setVersion(String version)
|
||||
{
|
||||
m_version = version;
|
||||
setOutputProperty(OutputKeys.VERSION, version);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -712,7 +702,7 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setMediaType(String mediaType)
|
||||
{
|
||||
m_mediatype = mediaType;
|
||||
setOutputProperty(OutputKeys.MEDIA_TYPE,mediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -741,7 +731,8 @@ public abstract class SerializerBase
|
||||
*/
|
||||
public void setIndent(boolean doIndent)
|
||||
{
|
||||
m_doIndent = doIndent;
|
||||
String val = doIndent ? "yes":"no";
|
||||
setOutputProperty(OutputKeys.INDENT,val);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -786,59 +777,6 @@ public abstract class SerializerBase
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a boolean state based on if the name of the current element
|
||||
* is found in the list of qnames. A state is only pushed if
|
||||
* there were some cdata-section-names were specified.
|
||||
* <p>
|
||||
* Hidden parameters are the vector of qualified elements specified in
|
||||
* cdata-section-names attribute, and the m_cdataSectionStates stack
|
||||
* onto which whether the current element is in the list is pushed (true or
|
||||
* false). Other hidden parameters are the current elements namespaceURI,
|
||||
* localName and qName
|
||||
*/
|
||||
protected boolean isCdataSection()
|
||||
{
|
||||
|
||||
boolean b = false;
|
||||
|
||||
if (null != m_cdataSectionElements)
|
||||
{
|
||||
if (m_elemContext.m_elementLocalName == null)
|
||||
m_elemContext.m_elementLocalName =
|
||||
getLocalName(m_elemContext.m_elementName);
|
||||
if (m_elemContext.m_elementURI == null)
|
||||
{
|
||||
String prefix = getPrefixPart(m_elemContext.m_elementName);
|
||||
if (prefix != null)
|
||||
m_elemContext.m_elementURI =
|
||||
m_prefixMap.lookupNamespace(prefix);
|
||||
|
||||
}
|
||||
|
||||
if ((null != m_elemContext.m_elementURI)
|
||||
&& m_elemContext.m_elementURI.length() == 0)
|
||||
m_elemContext.m_elementURI = null;
|
||||
|
||||
int nElems = m_cdataSectionElements.size();
|
||||
|
||||
// loop through 2 at a time, as these are pairs of URI and localName
|
||||
for (int i = 0; i < nElems; i += 2)
|
||||
{
|
||||
String uri = (String) m_cdataSectionElements.elementAt(i);
|
||||
String loc = (String) m_cdataSectionElements.elementAt(i + 1);
|
||||
if (loc.equals(m_elemContext.m_elementLocalName)
|
||||
&& subPartMatch(m_elemContext.m_elementURI, uri))
|
||||
{
|
||||
b = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if two strings are equal, without worry if the first string is null.
|
||||
*
|
||||
@ -1312,12 +1250,11 @@ public abstract class SerializerBase
|
||||
private void resetSerializerBase()
|
||||
{
|
||||
this.m_attributes.clear();
|
||||
this.m_cdataSectionElements = null;
|
||||
this.m_StringOfCDATASections = null;
|
||||
this.m_elemContext = new ElemContext();
|
||||
this.m_doctypePublic = null;
|
||||
this.m_doctypeSystem = null;
|
||||
this.m_doIndent = false;
|
||||
this.m_encoding = null;
|
||||
this.m_indentAmount = 0;
|
||||
this.m_inEntityRef = false;
|
||||
this.m_inExternalDTD = false;
|
||||
@ -1399,4 +1336,333 @@ public abstract class SerializerBase
|
||||
// A particular sub-class of SerializerBase provides the implementation (if desired)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The CDATA section names stored in a whitespace separateed list with
|
||||
* each element being a word of the form "{uri}localName" This list
|
||||
* comes from the cdata-section-elements attribute.
|
||||
*
|
||||
* This field replaces m_cdataSectionElements Vector.
|
||||
*/
|
||||
protected String m_StringOfCDATASections = null;
|
||||
|
||||
boolean m_docIsEmpty = true;
|
||||
void initCdataElems(String s)
|
||||
{
|
||||
if (s != null)
|
||||
{
|
||||
int max = s.length();
|
||||
|
||||
// true if we are in the middle of a pair of curly braces that delimit a URI
|
||||
boolean inCurly = false;
|
||||
|
||||
// true if we found a URI but haven't yet processed the local name
|
||||
boolean foundURI = false;
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
String uri = null;
|
||||
String localName = null;
|
||||
|
||||
// parse through string, breaking on whitespaces. I do this instead
|
||||
// of a tokenizer so I can track whitespace inside of curly brackets,
|
||||
// which theoretically shouldn't happen if they contain legal URLs.
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (Character.isWhitespace(c))
|
||||
{
|
||||
if (!inCurly)
|
||||
{
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
localName = buf.toString();
|
||||
if (!foundURI)
|
||||
uri = "";
|
||||
addCDATAElement(uri,localName);
|
||||
buf.setLength(0);
|
||||
foundURI = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
buf.append(c); // add whitespace to the URI
|
||||
}
|
||||
else if ('{' == c) // starting a URI
|
||||
inCurly = true;
|
||||
else if ('}' == c)
|
||||
{
|
||||
// we just ended a URI
|
||||
foundURI = true;
|
||||
uri = buf.toString();
|
||||
buf.setLength(0);
|
||||
inCurly = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// append non-whitespace, non-curly to current URI or localName being gathered.
|
||||
buf.append(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
// We have one last localName to process.
|
||||
localName = buf.toString();
|
||||
if (!foundURI)
|
||||
uri = "";
|
||||
addCDATAElement(uri,localName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected java.util.HashMap<String, HashMap<String, String>> m_CdataElems = null;
|
||||
private void addCDATAElement(String uri, String localName)
|
||||
{
|
||||
if (m_CdataElems == null) {
|
||||
m_CdataElems = new java.util.HashMap<>();
|
||||
}
|
||||
|
||||
HashMap<String,String> h = m_CdataElems.get(localName);
|
||||
if (h == null) {
|
||||
h = new HashMap<>();
|
||||
m_CdataElems.put(localName,h);
|
||||
}
|
||||
h.put(uri,uri);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if nothing has been sent to this result tree yet.
|
||||
* <p>
|
||||
* This is not a public API.
|
||||
*
|
||||
* @xsl.usage internal
|
||||
*/
|
||||
public boolean documentIsEmpty() {
|
||||
// If we haven't called startDocument() yet, then this document is empty
|
||||
return m_docIsEmpty && (m_elemContext.m_currentElemDepth == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the current element in m_elemContext
|
||||
* is a CDATA section.
|
||||
* CDATA sections are specified in the <xsl:output> attribute
|
||||
* cdata-section-names or in the JAXP equivalent property.
|
||||
* In any case the format of the value of such a property is:
|
||||
* <pre>
|
||||
* "{uri1}localName1 {uri2}localName2 . . . "
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* This method is not a public API, but is only used internally by the serializer.
|
||||
*/
|
||||
protected boolean isCdataSection() {
|
||||
boolean b = false;
|
||||
|
||||
if (null != m_StringOfCDATASections) {
|
||||
if (m_elemContext.m_elementLocalName == null) {
|
||||
String localName = getLocalName(m_elemContext.m_elementName);
|
||||
m_elemContext.m_elementLocalName = localName;
|
||||
}
|
||||
|
||||
if ( m_elemContext.m_elementURI == null) {
|
||||
|
||||
m_elemContext.m_elementURI = getElementURI();
|
||||
}
|
||||
else if ( m_elemContext.m_elementURI.length() == 0) {
|
||||
if ( m_elemContext.m_elementName == null) {
|
||||
m_elemContext.m_elementName = m_elemContext.m_elementLocalName;
|
||||
// leave URI as "", meaning in no namespace
|
||||
}
|
||||
else if (m_elemContext.m_elementLocalName.length() < m_elemContext.m_elementName.length()){
|
||||
// We were told the URI was "", yet the name has a prefix since the name is longer than the localname.
|
||||
// So we will fix that incorrect information here.
|
||||
m_elemContext.m_elementURI = getElementURI();
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> h = null;
|
||||
if (m_CdataElems != null) {
|
||||
h = m_CdataElems.get(m_elemContext.m_elementLocalName);
|
||||
}
|
||||
if (h != null) {
|
||||
Object obj = h.get(m_elemContext.m_elementURI);
|
||||
if (obj != null)
|
||||
b = true;
|
||||
}
|
||||
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before this call m_elementContext.m_elementURI is null,
|
||||
* which means it is not yet known. After this call it
|
||||
* is non-null, but possibly "" meaning that it is in the
|
||||
* default namespace.
|
||||
*
|
||||
* @return The URI of the element, never null, but possibly "".
|
||||
*/
|
||||
private String getElementURI() {
|
||||
String uri = null;
|
||||
// At this point in processing we have received all the
|
||||
// namespace mappings
|
||||
// As we still don't know the elements namespace,
|
||||
// we now figure it out.
|
||||
|
||||
String prefix = getPrefixPart(m_elemContext.m_elementName);
|
||||
|
||||
if (prefix == null) {
|
||||
// no prefix so lookup the URI of the default namespace
|
||||
uri = m_prefixMap.lookupNamespace("");
|
||||
} else {
|
||||
uri = m_prefixMap.lookupNamespace(prefix);
|
||||
}
|
||||
if (uri == null) {
|
||||
// We didn't find the namespace for the
|
||||
// prefix ... ouch, that shouldn't happen.
|
||||
// This is a hack, we really don't know
|
||||
// the namespace
|
||||
uri = EMPTYSTRING;
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of an output property,
|
||||
* the explicit value, if any, otherwise the
|
||||
* default value, if any, otherwise null.
|
||||
*/
|
||||
public String getOutputProperty(String name) {
|
||||
String val = getOutputPropertyNonDefault(name);
|
||||
// If no explicit value, try to get the default value
|
||||
if (val == null)
|
||||
val = getOutputPropertyDefault(name);
|
||||
return val;
|
||||
|
||||
}
|
||||
/**
|
||||
* Get the value of an output property,
|
||||
* not the default value. If there is a default
|
||||
* value, but no non-default value this method
|
||||
* will return null.
|
||||
* <p>
|
||||
*
|
||||
*/
|
||||
public String getOutputPropertyNonDefault(String name) {
|
||||
return getProp(name,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value of an xsl:output property,
|
||||
* which would be null only if no default value exists
|
||||
* for the property.
|
||||
*/
|
||||
public String getOutputPropertyDefault(String name) {
|
||||
return getProp(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for the output property, typically from
|
||||
* an xsl:output element, but this does not change what
|
||||
* the default value is.
|
||||
*/
|
||||
public void setOutputProperty(String name, String val) {
|
||||
setProp(name,val,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default value for an output property, but this does
|
||||
* not impact any explicitly set value.
|
||||
*/
|
||||
public void setOutputPropertyDefault(String name, String val) {
|
||||
setProp(name,val,true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A mapping of keys to explicitly set values, for example if
|
||||
* and <xsl:output/> has an "encoding" attribute, this
|
||||
* map will have what that attribute maps to.
|
||||
*/
|
||||
private HashMap<String, String> m_OutputProps;
|
||||
/**
|
||||
* A mapping of keys to default values, for example if
|
||||
* the default value of the encoding is "UTF-8" then this
|
||||
* map will have that "encoding" maps to "UTF-8".
|
||||
*/
|
||||
private HashMap<String, String> m_OutputPropsDefault;
|
||||
|
||||
Set<String> getOutputPropDefaultKeys() {
|
||||
return m_OutputPropsDefault.keySet();
|
||||
}
|
||||
Set<String> getOutputPropKeys() {
|
||||
return m_OutputProps.keySet();
|
||||
}
|
||||
|
||||
private String getProp(String name, boolean defaultVal) {
|
||||
if (m_OutputProps == null) {
|
||||
m_OutputProps = new HashMap<>();
|
||||
m_OutputPropsDefault = new HashMap<>();
|
||||
}
|
||||
|
||||
String val;
|
||||
if (defaultVal)
|
||||
val = m_OutputPropsDefault.get(name);
|
||||
else
|
||||
val = m_OutputProps.get(name);
|
||||
|
||||
return val;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param name The name of the property, e.g. "{http://myprop}indent-tabs" or "indent".
|
||||
* @param val The value of the property, e.g. "4"
|
||||
* @param defaultVal true if this is a default value being set for the property as
|
||||
* opposed to a user define on, set say explicitly in the stylesheet or via JAXP
|
||||
*/
|
||||
void setProp(String name, String val, boolean defaultVal) {
|
||||
if (m_OutputProps == null) {
|
||||
m_OutputProps = new HashMap<>();
|
||||
m_OutputPropsDefault = new HashMap<>();
|
||||
}
|
||||
|
||||
if (defaultVal)
|
||||
m_OutputPropsDefault.put(name,val);
|
||||
else {
|
||||
if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name) && val != null) {
|
||||
initCdataElems(val);
|
||||
String oldVal = m_OutputProps.get(name);
|
||||
String newVal;
|
||||
if (oldVal == null)
|
||||
newVal = oldVal + ' ' + val;
|
||||
else
|
||||
newVal = val;
|
||||
m_OutputProps.put(name,newVal);
|
||||
}
|
||||
else {
|
||||
m_OutputProps.put(name,val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first char of the local name
|
||||
* @param name Either a local name, or a local name
|
||||
* preceeded by a uri enclosed in curly braces.
|
||||
*/
|
||||
static char getFirstCharLocName(String name) {
|
||||
final char first;
|
||||
int i = name.indexOf('}');
|
||||
if (i < 0)
|
||||
first = name.charAt(0);
|
||||
else
|
||||
first = name.charAt(i+1);
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -349,84 +351,84 @@ public final class ToHTMLStream extends ToStream
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("A");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("a");
|
||||
elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("NAME", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("AREA");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("area");
|
||||
elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("NOHREF", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("BASE");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("base");
|
||||
elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("BUTTON");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("button");
|
||||
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("BLOCKQUOTE");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("blockquote");
|
||||
elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("DEL");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("del");
|
||||
elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("DIR");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("dir");
|
||||
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("DIV");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("div");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL); // Netscape 4 extension
|
||||
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("DL");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("dl");
|
||||
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("FORM");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("form");
|
||||
elemDesc.setAttr("ACTION", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
// Attribution to: "Voytenko, Dimitry" <DVoytenko@SECTORBASE.COM>
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("FRAME");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("frame");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("NORESIZE",ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("HEAD");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("head");
|
||||
elemDesc.setAttr("PROFILE", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("HR");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("hr");
|
||||
elemDesc.setAttr("NOSHADE", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
// HTML 4.0, section 16.5
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("IFRAME");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("iframe");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
// Netscape 4 extension
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("ILAYER");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("ilayer");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("IMG");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("img");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("INPUT");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("input");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("CHECKED", ElemDesc.ATTREMPTY);
|
||||
@ -435,24 +437,24 @@ public final class ToHTMLStream extends ToStream
|
||||
elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("INS");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("ins");
|
||||
elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
// Netscape 4 extension
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("LAYER");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("layer");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("LINK");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("link");
|
||||
elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("MENU");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("menu");
|
||||
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("OBJECT");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("object");
|
||||
elemDesc.setAttr("CLASSID", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("CODEBASE", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("DATA", ElemDesc.ATTRURL);
|
||||
@ -461,58 +463,58 @@ public final class ToHTMLStream extends ToStream
|
||||
elemDesc.setAttr("DECLARE", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("OL");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("ol");
|
||||
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("OPTGROUP");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("optgroup");
|
||||
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("OPTION");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("option");
|
||||
elemDesc.setAttr("SELECTED", ElemDesc.ATTREMPTY);
|
||||
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("Q");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("q");
|
||||
elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("SCRIPT");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("script");
|
||||
elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("FOR", ElemDesc.ATTRURL);
|
||||
elemDesc.setAttr("DEFER", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("SELECT");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("select");
|
||||
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
|
||||
elemDesc.setAttr("MULTIPLE", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("TABLE");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("table");
|
||||
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("TD");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("td");
|
||||
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("TEXTAREA");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("textarea");
|
||||
elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
|
||||
elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("TH");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("th");
|
||||
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
// The nowrap attribute of a tr element is both
|
||||
// a Netscape and Internet-Explorer extension
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("TR");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("tr");
|
||||
elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
|
||||
|
||||
// ----------------------------------------------
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("UL");
|
||||
elemDesc = (ElemDesc) m_elementFlags.get("ul");
|
||||
elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
|
||||
}
|
||||
|
||||
@ -1762,7 +1764,7 @@ public final class ToHTMLStream extends ToStream
|
||||
* lets determine if the current element is specified in the cdata-
|
||||
* section-elements list.
|
||||
*/
|
||||
if (m_cdataSectionElements != null)
|
||||
if (m_StringOfCDATASections != null)
|
||||
m_elemContext.m_isCdataSection = isCdataSection();
|
||||
if (m_doIndent)
|
||||
{
|
||||
@ -1776,54 +1778,7 @@ public final class ToHTMLStream extends ToStream
|
||||
throw new SAXException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Initialize the serializer with the specified output stream and output
|
||||
* format. Must be called before calling any of the serialize methods.
|
||||
*
|
||||
* @param output The output stream to use
|
||||
* @param format The output format
|
||||
* @throws UnsupportedEncodingException The encoding specified in the
|
||||
* output format is not supported
|
||||
*/
|
||||
protected synchronized void init(OutputStream output, Properties format)
|
||||
throws UnsupportedEncodingException
|
||||
{
|
||||
if (null == format)
|
||||
{
|
||||
format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
|
||||
}
|
||||
super.init(output,format, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies an output stream to which the document should be
|
||||
* serialized. This method should not be called while the
|
||||
* serializer is in the process of serializing a document.
|
||||
* <p>
|
||||
* The encoding specified in the output properties is used, or
|
||||
* if no encoding was specified, the default for the selected
|
||||
* output method.
|
||||
*
|
||||
* @param output The output stream
|
||||
*/
|
||||
public void setOutputStream(OutputStream output)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Properties format;
|
||||
if (null == m_format)
|
||||
format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
|
||||
else
|
||||
format = m_format;
|
||||
init(output, format, true);
|
||||
}
|
||||
catch (UnsupportedEncodingException uee)
|
||||
{
|
||||
|
||||
// Should have been warned in init, I guess...
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This method is used when a prefix/uri namespace mapping
|
||||
* is indicated after the element was started with a
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
@ -234,9 +234,9 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
/**
|
||||
* Does nothing. The setting of CDATA section elements has an impact on
|
||||
* stream serializers.
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.Vector)
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
|
||||
*/
|
||||
public void setCdataSectionElements(Vector URI_and_localNames)
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -25,11 +27,15 @@ package com.sun.org.apache.xml.internal.serializer;
|
||||
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.ErrorListener;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
@ -186,9 +192,6 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
boolean m_isUTF8 = false;
|
||||
|
||||
/** The xsl:output properties. */
|
||||
protected Properties m_format;
|
||||
|
||||
/**
|
||||
* remembers if we are in between the startCDATA() and endCDATA() callbacks
|
||||
*/
|
||||
@ -306,6 +309,7 @@ abstract public class ToStream extends SerializerBase
|
||||
}
|
||||
}
|
||||
|
||||
OutputStream m_outputStream;
|
||||
/**
|
||||
* Get the output stream where the events will be serialized to.
|
||||
*
|
||||
@ -314,13 +318,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
public OutputStream getOutputStream()
|
||||
{
|
||||
|
||||
if (m_writer instanceof WriterToUTF8Buffered)
|
||||
return ((WriterToUTF8Buffered) m_writer).getOutputStream();
|
||||
if (m_writer instanceof WriterToASCI)
|
||||
return ((WriterToASCI) m_writer).getOutputStream();
|
||||
else
|
||||
return null;
|
||||
return m_outputStream;
|
||||
}
|
||||
|
||||
// Implement DeclHandler
|
||||
@ -419,10 +417,174 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
protected final void outputLineSep() throws IOException
|
||||
{
|
||||
|
||||
m_writer.write(m_lineSep, 0, m_lineSepLen);
|
||||
}
|
||||
|
||||
void setProp(String name, String val, boolean defaultVal) {
|
||||
if (val != null) {
|
||||
|
||||
char first = getFirstCharLocName(name);
|
||||
switch (first) {
|
||||
case 'c':
|
||||
if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name)) {
|
||||
addCdataSectionElements(val); // val is cdataSectionNames
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
if (OutputKeys.DOCTYPE_SYSTEM.equals(name)) {
|
||||
this.m_doctypeSystem = val;
|
||||
} else if (OutputKeys.DOCTYPE_PUBLIC.equals(name)) {
|
||||
this.m_doctypePublic = val;
|
||||
if (val.startsWith("-//W3C//DTD XHTML"))
|
||||
m_spaceBeforeClose = true;
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
String newEncoding = val;
|
||||
if (OutputKeys.ENCODING.equals(name)) {
|
||||
String possible_encoding = Encodings.getMimeEncoding(val);
|
||||
if (possible_encoding != null) {
|
||||
// if the encoding is being set, try to get the
|
||||
// preferred
|
||||
// mime-name and set it too.
|
||||
super.setProp("mime-name", possible_encoding,
|
||||
defaultVal);
|
||||
}
|
||||
final String oldExplicitEncoding = getOutputPropertyNonDefault(OutputKeys.ENCODING);
|
||||
final String oldDefaultEncoding = getOutputPropertyDefault(OutputKeys.ENCODING);
|
||||
if ( (defaultVal && ( oldDefaultEncoding == null || !oldDefaultEncoding.equalsIgnoreCase(newEncoding)))
|
||||
|| ( !defaultVal && (oldExplicitEncoding == null || !oldExplicitEncoding.equalsIgnoreCase(newEncoding) ))) {
|
||||
// We are trying to change the default or the non-default setting of the encoding to a different value
|
||||
// from what it was
|
||||
|
||||
EncodingInfo encodingInfo = Encodings.getEncodingInfo(newEncoding);
|
||||
if (newEncoding != null && encodingInfo.name == null) {
|
||||
// We tried to get an EncodingInfo for Object for the given
|
||||
// encoding, but it came back with an internall null name
|
||||
// so the encoding is not supported by the JDK, issue a message.
|
||||
final String msg = Utils.messages.createMessage(
|
||||
MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ newEncoding });
|
||||
|
||||
final String msg2 =
|
||||
"Warning: encoding \"" + newEncoding + "\" not supported, using "
|
||||
+ Encodings.DEFAULT_MIME_ENCODING;
|
||||
try {
|
||||
// Prepare to issue the warning message
|
||||
final Transformer tran = super.getTransformer();
|
||||
if (tran != null) {
|
||||
final ErrorListener errHandler = tran
|
||||
.getErrorListener();
|
||||
// Issue the warning message
|
||||
if (null != errHandler
|
||||
&& m_sourceLocator != null) {
|
||||
errHandler
|
||||
.warning(new TransformerException(
|
||||
msg, m_sourceLocator));
|
||||
errHandler
|
||||
.warning(new TransformerException(
|
||||
msg2, m_sourceLocator));
|
||||
} else {
|
||||
System.out.println(msg);
|
||||
System.out.println(msg2);
|
||||
}
|
||||
} else {
|
||||
System.out.println(msg);
|
||||
System.out.println(msg2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// We said we are using UTF-8, so use it
|
||||
newEncoding = Encodings.DEFAULT_MIME_ENCODING;
|
||||
val = Encodings.DEFAULT_MIME_ENCODING; // to store the modified value into the properties a little later
|
||||
encodingInfo = Encodings.getEncodingInfo(newEncoding);
|
||||
}
|
||||
// The encoding was good, or was forced to UTF-8 above
|
||||
|
||||
|
||||
// If there is already a non-default set encoding and we
|
||||
// are trying to set the default encoding, skip the this block
|
||||
// as the non-default value is already the one to use.
|
||||
if (defaultVal == false || oldExplicitEncoding == null) {
|
||||
m_encodingInfo = encodingInfo;
|
||||
if (newEncoding != null)
|
||||
m_isUTF8 = newEncoding.equals(Encodings.DEFAULT_MIME_ENCODING);
|
||||
|
||||
// if there was a previously set OutputStream
|
||||
OutputStream os = getOutputStream();
|
||||
if (os != null) {
|
||||
Writer w = getWriter();
|
||||
|
||||
// If the writer was previously set, but
|
||||
// set by the user, or if the new encoding is the same
|
||||
// as the old encoding, skip this block
|
||||
String oldEncoding = getOutputProperty(OutputKeys.ENCODING);
|
||||
if ((w == null || !m_writer_set_by_user)
|
||||
&& !newEncoding.equalsIgnoreCase(oldEncoding)) {
|
||||
// Make the change of encoding in our internal
|
||||
// table, then call setOutputStreamInternal
|
||||
// which will stomp on the old Writer (if any)
|
||||
// with a new Writer with the new encoding.
|
||||
super.setProp(name, val, defaultVal);
|
||||
setOutputStreamInternal(os,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
if (OutputPropertiesFactory.S_KEY_INDENT_AMOUNT.equals(name)) {
|
||||
setIndentAmount(Integer.parseInt(val));
|
||||
} else if (OutputKeys.INDENT.equals(name)) {
|
||||
boolean b = "yes".equals(val) ? true : false;
|
||||
m_doIndent = b;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'l':
|
||||
if (OutputPropertiesFactory.S_KEY_LINE_SEPARATOR.equals(name)) {
|
||||
m_lineSep = val.toCharArray();
|
||||
m_lineSepLen = m_lineSep.length;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'm':
|
||||
if (OutputKeys.MEDIA_TYPE.equals(name)) {
|
||||
m_mediatype = val;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (OutputKeys.OMIT_XML_DECLARATION.equals(name)) {
|
||||
boolean b = "yes".equals(val) ? true : false;
|
||||
this.m_shouldNotWriteXMLHeader = b;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
// if standalone was explicitly specified
|
||||
if (OutputKeys.STANDALONE.equals(name)) {
|
||||
if (defaultVal) {
|
||||
setStandaloneInternal(val);
|
||||
} else {
|
||||
m_standaloneWasSpecified = true;
|
||||
setStandaloneInternal(val);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'v':
|
||||
if (OutputKeys.VERSION.equals(name)) {
|
||||
m_version = val;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
super.setProp(name, val, defaultVal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies an output format for this serializer. It the
|
||||
* serializer has already been associated with an output format,
|
||||
@ -434,115 +596,34 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
public void setOutputFormat(Properties format)
|
||||
{
|
||||
|
||||
boolean shouldFlush = m_shouldFlush;
|
||||
|
||||
init(m_writer, format, false, false);
|
||||
|
||||
m_shouldFlush = shouldFlush;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the serializer with the specified writer and output format.
|
||||
* Must be called before calling any of the serialize methods.
|
||||
* This method can be called multiple times and the xsl:output properties
|
||||
* passed in the 'format' parameter are accumulated across calls.
|
||||
*
|
||||
* @param writer The writer to use
|
||||
* @param format The output format
|
||||
* @param shouldFlush True if the writer should be flushed at EndDocument.
|
||||
*/
|
||||
private synchronized void init(
|
||||
Writer writer,
|
||||
Properties format,
|
||||
boolean defaultProperties,
|
||||
boolean shouldFlush)
|
||||
{
|
||||
|
||||
m_shouldFlush = shouldFlush;
|
||||
|
||||
|
||||
// if we are tracing events we need to trace what
|
||||
// characters are written to the output writer.
|
||||
if (m_tracer != null
|
||||
&& !(writer instanceof SerializerTraceWriter) )
|
||||
m_writer = new SerializerTraceWriter(writer, m_tracer);
|
||||
else
|
||||
m_writer = writer;
|
||||
|
||||
|
||||
m_format = format;
|
||||
// m_cdataSectionNames =
|
||||
// OutputProperties.getQNameProperties(
|
||||
// OutputKeys.CDATA_SECTION_ELEMENTS,
|
||||
// format);
|
||||
setCdataSectionElements(OutputKeys.CDATA_SECTION_ELEMENTS, format);
|
||||
|
||||
setIndentAmount(
|
||||
OutputPropertyUtils.getIntProperty(
|
||||
OutputPropertiesFactory.S_KEY_INDENT_AMOUNT,
|
||||
format));
|
||||
setIndent(
|
||||
OutputPropertyUtils.getBooleanProperty(OutputKeys.INDENT, format));
|
||||
|
||||
if (format != null)
|
||||
{
|
||||
String sep =
|
||||
format.getProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR);
|
||||
if (sep != null) {
|
||||
m_lineSep = sep.toCharArray();
|
||||
m_lineSepLen = sep.length();
|
||||
// Set the default values first,
|
||||
// and the non-default values after that,
|
||||
// just in case there is some unexpected
|
||||
// residual values left over from over-ridden default values
|
||||
Enumeration propNames;
|
||||
propNames = format.propertyNames();
|
||||
while (propNames.hasMoreElements())
|
||||
{
|
||||
String key = (String) propNames.nextElement();
|
||||
// Get the value, possibly a default value
|
||||
String value = format.getProperty(key);
|
||||
// Get the non-default value (if any).
|
||||
String explicitValue = (String) format.get(key);
|
||||
if (explicitValue == null && value != null) {
|
||||
// This is a default value
|
||||
this.setOutputPropertyDefault(key,value);
|
||||
}
|
||||
if (explicitValue != null) {
|
||||
// This is an explicit non-default value
|
||||
this.setOutputProperty(key,explicitValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean shouldNotWriteXMLHeader =
|
||||
OutputPropertyUtils.getBooleanProperty(
|
||||
OutputKeys.OMIT_XML_DECLARATION,
|
||||
format);
|
||||
setOmitXMLDeclaration(shouldNotWriteXMLHeader);
|
||||
setDoctypeSystem(format.getProperty(OutputKeys.DOCTYPE_SYSTEM));
|
||||
String doctypePublic = format.getProperty(OutputKeys.DOCTYPE_PUBLIC);
|
||||
setDoctypePublic(doctypePublic);
|
||||
|
||||
// if standalone was explicitly specified
|
||||
if (format.get(OutputKeys.STANDALONE) != null)
|
||||
{
|
||||
String val = format.getProperty(OutputKeys.STANDALONE);
|
||||
if (defaultProperties)
|
||||
setStandaloneInternal(val);
|
||||
else
|
||||
setStandalone(val);
|
||||
}
|
||||
|
||||
setMediaType(format.getProperty(OutputKeys.MEDIA_TYPE));
|
||||
|
||||
if (null != doctypePublic)
|
||||
{
|
||||
if (doctypePublic.startsWith("-//W3C//DTD XHTML"))
|
||||
m_spaceBeforeClose = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This code is added for XML 1.1 Version output.
|
||||
*/
|
||||
String version = getVersion();
|
||||
if (null == version)
|
||||
{
|
||||
version = format.getProperty(OutputKeys.VERSION);
|
||||
setVersion(version);
|
||||
}
|
||||
|
||||
// initCharsMap();
|
||||
String encoding = getEncoding();
|
||||
if (null == encoding)
|
||||
{
|
||||
encoding =
|
||||
Encodings.getMimeEncoding(
|
||||
format.getProperty(OutputKeys.ENCODING));
|
||||
setEncoding(encoding);
|
||||
}
|
||||
|
||||
m_isUTF8 = encoding.equals(Encodings.DEFAULT_MIME_ENCODING);
|
||||
|
||||
// Access this only from the Hashtable level... we don't want to
|
||||
// get default properties.
|
||||
String entitiesFileName =
|
||||
@ -557,107 +638,10 @@ abstract public class ToStream extends SerializerBase
|
||||
m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the serializer with the specified writer and output format.
|
||||
* Must be called before calling any of the serialize methods.
|
||||
*
|
||||
* @param writer The writer to use
|
||||
* @param format The output format
|
||||
*/
|
||||
private synchronized void init(Writer writer, Properties format)
|
||||
{
|
||||
init(writer, format, false, false);
|
||||
}
|
||||
/**
|
||||
* Initialize the serializer with the specified output stream and output
|
||||
* format. Must be called before calling any of the serialize methods.
|
||||
*
|
||||
* @param output The output stream to use
|
||||
* @param format The output format
|
||||
* @param defaultProperties true if the properties are the default
|
||||
* properties
|
||||
*
|
||||
* @throws UnsupportedEncodingException The encoding specified in the
|
||||
* output format is not supported
|
||||
*/
|
||||
protected synchronized void init(
|
||||
OutputStream output,
|
||||
Properties format,
|
||||
boolean defaultProperties)
|
||||
throws UnsupportedEncodingException
|
||||
{
|
||||
|
||||
String encoding = getEncoding();
|
||||
if (encoding == null)
|
||||
{
|
||||
// if not already set then get it from the properties
|
||||
encoding =
|
||||
Encodings.getMimeEncoding(
|
||||
format.getProperty(OutputKeys.ENCODING));
|
||||
setEncoding(encoding);
|
||||
}
|
||||
|
||||
if (encoding.equalsIgnoreCase("UTF-8"))
|
||||
{
|
||||
m_isUTF8 = true;
|
||||
// if (output instanceof java.io.BufferedOutputStream)
|
||||
// {
|
||||
// init(new WriterToUTF8(output), format, defaultProperties, true);
|
||||
// }
|
||||
// else if (output instanceof java.io.FileOutputStream)
|
||||
// {
|
||||
// init(new WriterToUTF8Buffered(output), format, defaultProperties, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Not sure what to do in this case. I'm going to be conservative
|
||||
// // and not buffer.
|
||||
// init(new WriterToUTF8(output), format, defaultProperties, true);
|
||||
// }
|
||||
|
||||
|
||||
init(
|
||||
new WriterToUTF8Buffered(output),
|
||||
format,
|
||||
defaultProperties,
|
||||
true);
|
||||
|
||||
|
||||
}
|
||||
else if (
|
||||
encoding.equals("WINDOWS-1250")
|
||||
|| encoding.equals("US-ASCII")
|
||||
|| encoding.equals("ASCII"))
|
||||
{
|
||||
init(new WriterToASCI(output), format, defaultProperties, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Writer osw;
|
||||
|
||||
try
|
||||
{
|
||||
osw = Encodings.getWriter(output, encoding);
|
||||
}
|
||||
catch (UnsupportedEncodingException uee)
|
||||
{
|
||||
System.out.println(
|
||||
"Warning: encoding \""
|
||||
+ encoding
|
||||
+ "\" not supported"
|
||||
+ ", using "
|
||||
+ Encodings.DEFAULT_MIME_ENCODING);
|
||||
|
||||
encoding = Encodings.DEFAULT_MIME_ENCODING;
|
||||
setEncoding(encoding);
|
||||
osw = Encodings.getWriter(output, encoding);
|
||||
}
|
||||
|
||||
init(osw, format, defaultProperties, true);
|
||||
}
|
||||
|
||||
m_shouldFlush = shouldFlush;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -665,9 +649,26 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @return The output format in use
|
||||
*/
|
||||
public Properties getOutputFormat()
|
||||
{
|
||||
return m_format;
|
||||
public Properties getOutputFormat() {
|
||||
Properties def = new Properties();
|
||||
{
|
||||
Set<String> s = getOutputPropDefaultKeys();
|
||||
for (String key : s) {
|
||||
String val = getOutputPropertyDefault(key);
|
||||
def.put(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
Properties props = new Properties(def);
|
||||
{
|
||||
Set<String> s = getOutputPropKeys();
|
||||
for (String key : s) {
|
||||
String val = getOutputPropertyNonDefault(key);
|
||||
if (val != null)
|
||||
props.put(key, val);
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -679,13 +680,28 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
public void setWriter(Writer writer)
|
||||
{
|
||||
setWriterInternal(writer, true);
|
||||
}
|
||||
|
||||
private boolean m_writer_set_by_user;
|
||||
private void setWriterInternal(Writer writer, boolean setByUser) {
|
||||
m_writer_set_by_user = setByUser;
|
||||
m_writer = writer;
|
||||
// if we are tracing events we need to trace what
|
||||
// characters are written to the output writer.
|
||||
if (m_tracer != null
|
||||
&& !(writer instanceof SerializerTraceWriter) )
|
||||
m_writer = new SerializerTraceWriter(writer, m_tracer);
|
||||
else
|
||||
m_writer = writer;
|
||||
if (m_tracer != null) {
|
||||
boolean noTracerYet = true;
|
||||
Writer w2 = m_writer;
|
||||
while (w2 instanceof WriterChain) {
|
||||
if (w2 instanceof SerializerTraceWriter) {
|
||||
noTracerYet = false;
|
||||
break;
|
||||
}
|
||||
w2 = ((WriterChain)w2).getWriter();
|
||||
}
|
||||
if (noTracerYet)
|
||||
m_writer = new SerializerTraceWriter(m_writer, m_tracer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -720,25 +736,68 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
public void setOutputStream(OutputStream output)
|
||||
{
|
||||
setOutputStreamInternal(output, true);
|
||||
}
|
||||
|
||||
try
|
||||
private void setOutputStreamInternal(OutputStream output, boolean setByUser)
|
||||
{
|
||||
m_outputStream = output;
|
||||
String encoding = getOutputProperty(OutputKeys.ENCODING);
|
||||
if (Encodings.DEFAULT_MIME_ENCODING.equalsIgnoreCase(encoding))
|
||||
{
|
||||
Properties format;
|
||||
if (null == m_format)
|
||||
format =
|
||||
OutputPropertiesFactory.getDefaultMethodProperties(
|
||||
Method.XML);
|
||||
else
|
||||
format = m_format;
|
||||
init(output, format, true);
|
||||
// We wrap the OutputStream with a writer, but
|
||||
// not one set by the user
|
||||
try {
|
||||
setWriterInternal(new WriterToUTF8Buffered(output), false);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (
|
||||
"WINDOWS-1250".equals(encoding)
|
||||
|| "US-ASCII".equals(encoding)
|
||||
|| "ASCII".equals(encoding))
|
||||
{
|
||||
setWriterInternal(new WriterToASCI(output), false);
|
||||
} else if (encoding != null) {
|
||||
Writer osw = null;
|
||||
try
|
||||
{
|
||||
osw = Encodings.getWriter(output, encoding);
|
||||
}
|
||||
catch (UnsupportedEncodingException uee)
|
||||
{
|
||||
osw = null;
|
||||
}
|
||||
|
||||
|
||||
if (osw == null) {
|
||||
System.out.println(
|
||||
"Warning: encoding \""
|
||||
+ encoding
|
||||
+ "\" not supported"
|
||||
+ ", using "
|
||||
+ Encodings.DEFAULT_MIME_ENCODING);
|
||||
|
||||
encoding = Encodings.DEFAULT_MIME_ENCODING;
|
||||
setEncoding(encoding);
|
||||
try {
|
||||
osw = Encodings.getWriter(output, encoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// We can't really get here, UTF-8 is always supported
|
||||
// This try-catch exists to make the compiler happy
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
setWriterInternal(osw,false);
|
||||
}
|
||||
catch (UnsupportedEncodingException uee)
|
||||
{
|
||||
|
||||
// Should have been warned in init, I guess...
|
||||
else {
|
||||
// don't have any encoding, but we have an OutputStream
|
||||
Writer osw = new OutputStreamWriter(output);
|
||||
setWriterInternal(osw,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setEscaping(boolean)
|
||||
*/
|
||||
@ -2455,7 +2514,7 @@ abstract public class ToStream extends SerializerBase
|
||||
* lets determine if the current element is specified in the cdata-
|
||||
* section-elements list.
|
||||
*/
|
||||
if (m_cdataSectionElements != null)
|
||||
if (m_StringOfCDATASections != null)
|
||||
m_elemContext.m_isCdataSection = isCdataSection();
|
||||
|
||||
if (m_doIndent)
|
||||
@ -2532,12 +2591,12 @@ abstract public class ToStream extends SerializerBase
|
||||
* @param key the property key.
|
||||
* @param props the list of properties to search in.
|
||||
*
|
||||
* Sets the vector of local-name/URI pairs of the cdata section elements
|
||||
* Sets the ArrayList of local-name/URI pairs of the cdata section elements
|
||||
* specified in the cdata-section-elements property.
|
||||
*
|
||||
* This method is essentially a copy of getQNameProperties() from
|
||||
* OutputProperties. Eventually this method should go away and a call
|
||||
* to setCdataSectionElements(Vector v) should be made directly.
|
||||
* to setCdataSectionElements(ArrayList<String> v) should be made directly.
|
||||
*/
|
||||
private void setCdataSectionElements(String key, Properties props)
|
||||
{
|
||||
@ -2546,11 +2605,11 @@ abstract public class ToStream extends SerializerBase
|
||||
|
||||
if (null != s)
|
||||
{
|
||||
// Vector of URI/LocalName pairs
|
||||
Vector v = new Vector();
|
||||
// ArrayList<String> of URI/LocalName pairs
|
||||
ArrayList<String> v = new ArrayList<>();
|
||||
int l = s.length();
|
||||
boolean inCurly = false;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
// parse through string, breaking on whitespaces. I do this instead
|
||||
// of a tokenizer so I can track whitespace inside of curly brackets,
|
||||
@ -2597,7 +2656,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @return a QName object
|
||||
*/
|
||||
private void addCdataSectionElement(String URI_and_localName, Vector v)
|
||||
private void addCdataSectionElement(String URI_and_localName, ArrayList<String> v)
|
||||
{
|
||||
|
||||
StringTokenizer tokenizer =
|
||||
@ -2608,14 +2667,14 @@ abstract public class ToStream extends SerializerBase
|
||||
if (null == s2)
|
||||
{
|
||||
// add null URI and the local name
|
||||
v.addElement(null);
|
||||
v.addElement(s1);
|
||||
v.add(null);
|
||||
v.add(s1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add URI, then local name
|
||||
v.addElement(s1);
|
||||
v.addElement(s2);
|
||||
v.add(s1);
|
||||
v.add(s2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2624,11 +2683,38 @@ abstract public class ToStream extends SerializerBase
|
||||
* The "official way to set URI and localName pairs.
|
||||
* This method should be used by both Xalan and XSLTC.
|
||||
*
|
||||
* @param URI_and_localNames a vector of pairs of Strings (URI/local)
|
||||
* @param URI_and_localNames an ArrayList of pairs of Strings (URI/local)
|
||||
*/
|
||||
public void setCdataSectionElements(Vector URI_and_localNames)
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
m_cdataSectionElements = URI_and_localNames;
|
||||
// convert to the new way.
|
||||
if (URI_and_localNames != null)
|
||||
{
|
||||
final int len = URI_and_localNames.size() - 1;
|
||||
if (len > 0)
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < len; i += 2)
|
||||
{
|
||||
// whitspace separated "{uri1}local1 {uri2}local2 ..."
|
||||
if (i != 0)
|
||||
sb.append(' ');
|
||||
final String uri = (String) URI_and_localNames.get(i);
|
||||
final String localName =
|
||||
(String) URI_and_localNames.get(i + 1);
|
||||
if (uri != null)
|
||||
{
|
||||
// If there is no URI don't put this in, just the localName then.
|
||||
sb.append('{');
|
||||
sb.append(uri);
|
||||
sb.append('}');
|
||||
}
|
||||
sb.append(localName);
|
||||
}
|
||||
m_StringOfCDATASections = sb.toString();
|
||||
}
|
||||
}
|
||||
initCdataElems(m_StringOfCDATASections);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3084,37 +3170,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
String old = getEncoding();
|
||||
super.setEncoding(encoding);
|
||||
if (old == null || !old.equals(encoding)) {
|
||||
// If we have changed the setting of the
|
||||
m_encodingInfo = Encodings.getEncodingInfo(encoding);
|
||||
|
||||
if (encoding != null && m_encodingInfo.name == null) {
|
||||
// We tried to get an EncodingInfo for Object for the given
|
||||
// encoding, but it came back with an internall null name
|
||||
// so the encoding is not supported by the JDK, issue a message.
|
||||
String msg = Utils.messages.createMessage(
|
||||
MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
|
||||
try
|
||||
{
|
||||
// Prepare to issue the warning message
|
||||
Transformer tran = super.getTransformer();
|
||||
if (tran != null) {
|
||||
ErrorListener errHandler = tran.getErrorListener();
|
||||
// Issue the warning message
|
||||
if (null != errHandler && m_sourceLocator != null)
|
||||
errHandler.warning(new TransformerException(msg, m_sourceLocator));
|
||||
else
|
||||
System.out.println(msg);
|
||||
}
|
||||
else
|
||||
System.out.println(msg);
|
||||
}
|
||||
catch (Exception e){}
|
||||
}
|
||||
}
|
||||
return;
|
||||
setOutputProperty(OutputKeys.ENCODING,encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3386,4 +3442,24 @@ abstract public class ToStream extends SerializerBase
|
||||
public void setDTDEntityExpansion(boolean expand) {
|
||||
m_expandDTDEntities = expand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remembers the cdata sections specified in the cdata-section-elements by appending the given
|
||||
* cdata section elements to the list. This method can be called multiple times, but once an
|
||||
* element is put in the list of cdata section elements it can not be removed.
|
||||
* This method should be used by both Xalan and XSLTC.
|
||||
*
|
||||
* @param URI_and_localNames a whitespace separated list of element names, each element
|
||||
* is a URI in curly braces (optional) and a local name. An example of such a parameter is:
|
||||
* "{http://company.com}price {myURI2}book chapter"
|
||||
*/
|
||||
public void addCdataSectionElements(String URI_and_localNames)
|
||||
{
|
||||
if (URI_and_localNames != null)
|
||||
initCdataElems(URI_and_localNames);
|
||||
if (m_StringOfCDATASections == null)
|
||||
m_StringOfCDATASections = URI_and_localNames;
|
||||
else
|
||||
m_StringOfCDATASections += (" " + URI_and_localNames);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import javax.xml.transform.Transformer;
|
||||
@ -100,12 +100,12 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* A collection of namespace URI's (only for first element).
|
||||
* _namespacePrefix has the matching prefix for these URI's
|
||||
*/
|
||||
private Vector m_namespaceURI = null;
|
||||
private ArrayList<String> m_namespaceURI = null;
|
||||
/**
|
||||
* A collection of namespace Prefix (only for first element)
|
||||
* _namespaceURI has the matching URIs for these prefix'
|
||||
*/
|
||||
private Vector m_namespacePrefix = null;
|
||||
private ArrayList<String> m_namespacePrefix = null;
|
||||
|
||||
/**
|
||||
* true if startDocument() was called before the underlying handler
|
||||
@ -421,11 +421,11 @@ public final class ToUnknownStream extends SerializerBase
|
||||
{
|
||||
if (m_namespacePrefix == null)
|
||||
{
|
||||
m_namespacePrefix = new Vector();
|
||||
m_namespaceURI = new Vector();
|
||||
m_namespacePrefix = new ArrayList<>();
|
||||
m_namespaceURI = new ArrayList<>();
|
||||
}
|
||||
m_namespacePrefix.addElement(prefix);
|
||||
m_namespaceURI.addElement(uri);
|
||||
m_namespacePrefix.add(prefix);
|
||||
m_namespaceURI.add(uri);
|
||||
|
||||
if (m_firstElementURI == null)
|
||||
{
|
||||
@ -1092,8 +1092,8 @@ public final class ToUnknownStream extends SerializerBase
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
final String prefix =
|
||||
(String) m_namespacePrefix.elementAt(i);
|
||||
final String uri = (String) m_namespaceURI.elementAt(i);
|
||||
(String) m_namespacePrefix.get(i);
|
||||
final String uri = (String) m_namespaceURI.get(i);
|
||||
m_handler.startPrefixMapping(prefix, uri, false);
|
||||
}
|
||||
m_namespacePrefix = null;
|
||||
@ -1165,8 +1165,8 @@ public final class ToUnknownStream extends SerializerBase
|
||||
final int max = m_namespacePrefix.size();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
final String prefix = (String) m_namespacePrefix.elementAt(i);
|
||||
final String uri = (String) m_namespaceURI.elementAt(i);
|
||||
final String prefix = m_namespacePrefix.get(i);
|
||||
final String uri = m_namespaceURI.get(i);
|
||||
|
||||
if (m_firstElementPrefix != null
|
||||
&& m_firstElementPrefix.equals(prefix)
|
||||
@ -1194,7 +1194,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* specified in the cdata-section-elements attribute.
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.Vector)
|
||||
*/
|
||||
public void setCdataSectionElements(Vector URI_and_localNames)
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
m_handler.setCdataSectionElements(URI_and_localNames);
|
||||
}
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
|
@ -3,9 +3,11 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2003-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@ -22,7 +24,7 @@
|
||||
*/
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This interface has methods associated with the XSLT xsl:output attribues
|
||||
@ -105,11 +107,6 @@ interface XSLOutputAttributes
|
||||
*/
|
||||
public String getVersion();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value coming from the xsl:output cdata-section-elements
|
||||
* stylesheet property.
|
||||
@ -124,7 +121,7 @@ interface XSLOutputAttributes
|
||||
* relevant in specifying which elements have their text to be output as
|
||||
* CDATA sections.
|
||||
*/
|
||||
public void setCdataSectionElements(Vector URI_and_localNames);
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames);
|
||||
|
||||
/** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
|
||||
* @param system the system identifier to be used in the DOCTYPE declaration
|
||||
@ -181,4 +178,58 @@ interface XSLOutputAttributes
|
||||
*/
|
||||
public void setVersion(String version);
|
||||
|
||||
/**
|
||||
* Get the value for a property that affects seraialization,
|
||||
* if a property was set return that value, otherwise return
|
||||
* the default value, otherwise return null.
|
||||
* @param name The name of the property, which is just the local name
|
||||
* if it is in no namespace, but is the URI in curly braces followed by
|
||||
* the local name if it is in a namespace, for example:
|
||||
* <ul>
|
||||
* <li> "encoding"
|
||||
* <li> "method"
|
||||
* <li> "{http://xml.apache.org/xalan}indent-amount"
|
||||
* <li> "{http://xml.apache.org/xalan}line-separator"
|
||||
* </ul>
|
||||
* @return The value of the parameter
|
||||
*/
|
||||
public String getOutputProperty(String name);
|
||||
/**
|
||||
* Get the default value for a property that affects seraialization,
|
||||
* or null if there is none. It is possible that a non-default value
|
||||
* was set for the property, however the value returned by this method
|
||||
* is unaffected by any non-default settings.
|
||||
* @param name The name of the property.
|
||||
* @return The default value of the parameter, or null if there is no default value.
|
||||
*/
|
||||
public String getOutputPropertyDefault(String name);
|
||||
/**
|
||||
* Set the non-default value for a property that affects seraialization.
|
||||
* @param name The name of the property, which is just the local name
|
||||
* if it is in no namespace, but is the URI in curly braces followed by
|
||||
* the local name if it is in a namespace, for example:
|
||||
* <ul>
|
||||
* <li> "encoding"
|
||||
* <li> "method"
|
||||
* <li> "{http://xml.apache.org/xalan}indent-amount"
|
||||
* <li> "{http://xml.apache.org/xalan}line-separator"
|
||||
* </ul>
|
||||
* @val The non-default value of the parameter
|
||||
*/
|
||||
public void setOutputProperty(String name, String val);
|
||||
|
||||
/**
|
||||
* Set the default value for a property that affects seraialization.
|
||||
* @param name The name of the property, which is just the local name
|
||||
* if it is in no namespace, but is the URI in curly braces followed by
|
||||
* the local name if it is in a namespace, for example:
|
||||
* <ul>
|
||||
* <li> "encoding"
|
||||
* <li> "method"
|
||||
* <li> "{http://xml.apache.org/xalan}indent-amount"
|
||||
* <li> "{http://xml.apache.org/xalan}line-separator"
|
||||
* </ul>
|
||||
* @val The default value of the parameter
|
||||
*/
|
||||
public void setOutputPropertyDefault(String name, String val);
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public abstract class Entity {
|
||||
}
|
||||
|
||||
/**each 'external' parsed entity may have xml/text declaration containing version information
|
||||
* @return String version of the enity, for an internal entity version would be null
|
||||
* @return String version of the entity, for an internal entity version would be null
|
||||
*/
|
||||
public String getEntityVersion(){
|
||||
return version ;
|
||||
|
@ -34,7 +34,7 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
|
||||
* @author Neeraj
|
||||
*
|
||||
* This class wraps XMLInputSource and is also capable of telling wether application
|
||||
* returned XMLStreamReader or not when XMLResolver.resolveEnity
|
||||
* returned XMLStreamReader or not when XMLResolver.resolveEntity
|
||||
* was called.
|
||||
*/
|
||||
public class StaxXMLInputSource {
|
||||
|
@ -36,7 +36,7 @@ public class DatatypeConfigurationException extends Exception {
|
||||
|
||||
/**
|
||||
* <p>Create a new <code>DatatypeConfigurationException</code> with
|
||||
* no specified detail mesage and cause.</p>
|
||||
* no specified detail message and cause.</p>
|
||||
*/
|
||||
|
||||
public DatatypeConfigurationException() {
|
||||
|
@ -119,7 +119,7 @@ public abstract class DatatypeFactory {
|
||||
Pattern.compile("[^YM]*[DT].*");
|
||||
|
||||
/**
|
||||
* <p>Protected constructor to prevent instaniation outside of package.</p>
|
||||
* <p>Protected constructor to prevent instantiation outside of package.</p>
|
||||
*
|
||||
* <p>Use {@link #newInstance()} to create a <code>DatatypeFactory</code>.</p>
|
||||
*/
|
||||
|
@ -83,7 +83,7 @@ public class QName implements Serializable {
|
||||
*
|
||||
* <p>To workaround this issue, serialVersionUID is set with either
|
||||
* a default value or a compatibility value. To use the
|
||||
* compatiblity value, set the system property:</p>
|
||||
* compatibility value, set the system property:</p>
|
||||
*
|
||||
* <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code>
|
||||
*
|
||||
|
@ -423,7 +423,7 @@ public abstract class DocumentBuilderFactory {
|
||||
* <ul>
|
||||
* <li>
|
||||
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
|
||||
* Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
|
||||
* Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
|
||||
* If XML processing is limited for security reasons, it will be reported via a call to the registered
|
||||
* {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
|
||||
* See {@link DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
|
||||
@ -517,7 +517,7 @@ public abstract class DocumentBuilderFactory {
|
||||
* modified DOM trees.
|
||||
*
|
||||
* <p>
|
||||
* Initialy, null is set as the {@link Schema}.
|
||||
* Initially, null is set as the {@link Schema}.
|
||||
*
|
||||
* <p>
|
||||
* This processing will take effect even if
|
||||
@ -531,7 +531,7 @@ public abstract class DocumentBuilderFactory {
|
||||
* exception when the {@link #newDocumentBuilder()} is invoked.</p>
|
||||
*
|
||||
*
|
||||
* <h4>Note for implmentors</h4>
|
||||
* <h4>Note for implementors</h4>
|
||||
*
|
||||
* <p>
|
||||
* A parser must be able to work with any {@link Schema}
|
||||
|
@ -45,7 +45,7 @@ public class FactoryConfigurationError extends Error {
|
||||
|
||||
/**
|
||||
* Create a new <code>FactoryConfigurationError</code> with no
|
||||
* detail mesage.
|
||||
* detail message.
|
||||
*/
|
||||
|
||||
public FactoryConfigurationError() {
|
||||
|
@ -35,7 +35,7 @@ public class ParserConfigurationException extends Exception {
|
||||
|
||||
/**
|
||||
* Create a new <code>ParserConfigurationException</code> with no
|
||||
* detail mesage.
|
||||
* detail message.
|
||||
*/
|
||||
|
||||
public ParserConfigurationException() {
|
||||
|
@ -69,7 +69,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
* given {@link org.xml.sax.HandlerBase} or the
|
||||
* {@link org.xml.sax.helpers.DefaultHandler} are called.<p>
|
||||
*
|
||||
* Implementors of this class which wrap an underlaying implementation
|
||||
* Implementors of this class which wrap an underlying implementation
|
||||
* can consider using the {@link org.xml.sax.helpers.ParserAdapter}
|
||||
* class to initially adapt their SAX1 implementation to work under
|
||||
* this revised class.
|
||||
@ -79,7 +79,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
public abstract class SAXParser {
|
||||
|
||||
/**
|
||||
* <p>Protected constructor to prevent instaniation.
|
||||
* <p>Protected constructor to prevent instantiation.
|
||||
* Use {@link javax.xml.parsers.SAXParserFactory#newSAXParser()}.</p>
|
||||
*/
|
||||
protected SAXParser () {
|
||||
@ -393,10 +393,10 @@ public abstract class SAXParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SAX parser that is encapsultated by the
|
||||
* Returns the SAX parser that is encapsulated by the
|
||||
* implementation of this class.
|
||||
*
|
||||
* @return The SAX parser that is encapsultated by the
|
||||
* @return The SAX parser that is encapsulated by the
|
||||
* implementation of this class.
|
||||
*
|
||||
* @throws SAXException If any SAX errors occur during processing.
|
||||
|
@ -359,7 +359,7 @@ public abstract class SAXParserFactory {
|
||||
* is responsible to make sure that the application will receive
|
||||
* those modified event stream.</p>
|
||||
*
|
||||
* <p>Initialy, <code>null</code> is set as the {@link Schema}.</p>
|
||||
* <p>Initially, <code>null</code> is set as the {@link Schema}.</p>
|
||||
*
|
||||
* <p>This processing will take effect even if
|
||||
* the {@link #isValidating()} method returns <code>false</code>.
|
||||
|
@ -28,7 +28,7 @@ package javax.xml.transform;
|
||||
/**
|
||||
* <p>To provide customized error handling, implement this interface and
|
||||
* use the <code>setErrorListener</code> method to register an instance of the
|
||||
* implmentation with the {@link javax.xml.transform.Transformer}. The
|
||||
* implementation with the {@link javax.xml.transform.Transformer}. The
|
||||
* <code>Transformer</code> then reports all errors and warnings through this
|
||||
* interface.</p>
|
||||
*
|
||||
|
@ -32,7 +32,7 @@ public class TransformerConfigurationException extends TransformerException {
|
||||
|
||||
/**
|
||||
* Create a new <code>TransformerConfigurationException</code> with no
|
||||
* detail mesage.
|
||||
* detail message.
|
||||
*/
|
||||
public TransformerConfigurationException() {
|
||||
super("Configuration Error");
|
||||
|
@ -42,7 +42,7 @@ public class TransformerFactoryConfigurationError extends Error {
|
||||
|
||||
/**
|
||||
* Create a new <code>TransformerFactoryConfigurationError</code> with no
|
||||
* detail mesage.
|
||||
* detail message.
|
||||
*/
|
||||
public TransformerFactoryConfigurationError() {
|
||||
|
||||
|
@ -358,7 +358,7 @@ public abstract class SchemaFactory {
|
||||
* <ul>
|
||||
* <li>
|
||||
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
|
||||
* Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
|
||||
* Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
|
||||
* If XML processing is limited for security reasons, it will be reported via a call to the registered
|
||||
* {@link ErrorHandler#fatalError(SAXParseException exception)}.
|
||||
* See {@link #setErrorHandler(ErrorHandler errorHandler)}.
|
||||
|
@ -379,7 +379,7 @@ public abstract class ValidatorHandler implements ContentHandler {
|
||||
* <ul>
|
||||
* <li>
|
||||
* <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
|
||||
* Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
|
||||
* Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
|
||||
* If XML processing is limited for security reasons, it will be reported via a call to the registered
|
||||
* {@link ErrorHandler#fatalError(SAXParseException exception)}.
|
||||
* See {@link #setErrorHandler(ErrorHandler errorHandler)}.
|
||||
|
@ -263,3 +263,4 @@ c9e8bb8c1144a966ca7b481142c6b5e55d14a29c jdk9-b09
|
||||
e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15
|
||||
1e1a3b2215b7551d88e89d1ca8c1e1ebe3d3c0ab jdk9-b16
|
||||
6b159e727dac283f424b7d19f5be3ddd9f85acf5 jdk9-b17
|
||||
275f2385aed80c84297840638d58656366350c58 jdk9-b18
|
||||
|
@ -260,3 +260,4 @@ c7c8002d02721e02131d104549ebeb8b379fb8d2 jdk9-b13
|
||||
4537360f09fe23ab339ee588747b657feb12d0c8 jdk9-b15
|
||||
ab7d2c565b0de5bee1361d282d4029371327fc9e jdk9-b16
|
||||
fd8e675f141b9bdb2f46d1ae8251f4ee3a895d64 jdk9-b17
|
||||
6ad17b31f0d30593392b1e8695b9709dbbd7fb70 jdk9-b18
|
||||
|
@ -370,7 +370,57 @@ int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
|
||||
}
|
||||
|
||||
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
|
||||
BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
|
||||
int crc = -1, prc = -1;
|
||||
threadEntry_t self;
|
||||
fdEntry_t* fdEntry = getFdEntry(s);
|
||||
|
||||
if (fdEntry == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* On AIX, when the system call connect() is interrupted, the connection
|
||||
* is not aborted and it will be established asynchronously by the kernel.
|
||||
* Hence, no need to restart connect() when EINTR is received
|
||||
*/
|
||||
startOp(fdEntry, &self);
|
||||
crc = connect(s, addr, addrlen);
|
||||
endOp(fdEntry, &self);
|
||||
|
||||
if (crc == -1 && errno == EINTR) {
|
||||
struct pollfd s_pollfd;
|
||||
int sockopt_arg = 0;
|
||||
socklen_t len;
|
||||
|
||||
s_pollfd.fd = s;
|
||||
s_pollfd.events = POLLOUT | POLLERR;
|
||||
|
||||
/* poll the file descriptor */
|
||||
do {
|
||||
startOp(fdEntry, &self);
|
||||
prc = poll(&s_pollfd, 1, -1);
|
||||
endOp(fdEntry, &self);
|
||||
} while (prc == -1 && errno == EINTR);
|
||||
|
||||
if (prc < 0)
|
||||
return prc;
|
||||
|
||||
len = sizeof(sockopt_arg);
|
||||
|
||||
/* Check whether the connection has been established */
|
||||
if (getsockopt(s, SOL_SOCKET, SO_ERROR, &sockopt_arg, &len) == -1)
|
||||
return -1;
|
||||
|
||||
if (sockopt_arg != 0 ) {
|
||||
errno = sockopt_arg;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return crc;
|
||||
}
|
||||
|
||||
/* At this point, fd is connected. Set successful return code */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
|
||||
|
@ -523,7 +523,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
* that is used for menu shortcuts on this toolkit.
|
||||
* @see java.awt.MenuBar
|
||||
* @see java.awt.MenuShortcut
|
||||
* @since JDK1.1
|
||||
* @since 1.1
|
||||
*/
|
||||
@Override
|
||||
public int getMenuShortcutKeyMask() {
|
||||
|
@ -839,7 +839,7 @@ class ConstantPool {
|
||||
return parts;
|
||||
}
|
||||
|
||||
/** @since JDK 7, JSR 292 */
|
||||
/** @since 1.7, JSR 292 */
|
||||
public static
|
||||
class MethodHandleEntry extends Entry {
|
||||
final int refKind;
|
||||
@ -889,7 +889,7 @@ class ConstantPool {
|
||||
}
|
||||
}
|
||||
|
||||
/** @since JDK 7, JSR 292 */
|
||||
/** @since 1.7, JSR 292 */
|
||||
public static
|
||||
class MethodTypeEntry extends Entry {
|
||||
final SignatureEntry typeRef;
|
||||
@ -924,7 +924,7 @@ class ConstantPool {
|
||||
}
|
||||
}
|
||||
|
||||
/** @since JDK 7, JSR 292 */
|
||||
/** @since 1.7, JSR 292 */
|
||||
public static
|
||||
class InvokeDynamicEntry extends Entry {
|
||||
final BootstrapMethodEntry bssRef;
|
||||
@ -977,7 +977,7 @@ class ConstantPool {
|
||||
}
|
||||
}
|
||||
|
||||
/** @since JDK 7, JSR 292 */
|
||||
/** @since 1.7, JSR 292 */
|
||||
public static
|
||||
class BootstrapMethodEntry extends Entry {
|
||||
final MethodHandleEntry bsmRef;
|
||||
|
@ -97,7 +97,7 @@ http://www.ietf.org/rfc/rfc2616.txt
|
||||
</ul>
|
||||
|
||||
<li>
|
||||
@since JDK1.5.0</li>
|
||||
@since 1.5</li>
|
||||
|
||||
<br><!-- Put @see and @since tags down here. -->
|
||||
</body>
|
||||
|
@ -562,7 +562,7 @@ public class Introspector {
|
||||
}
|
||||
if (readMethod != null) {
|
||||
ReflectUtil.checkPackageAccess(readMethod.getDeclaringClass());
|
||||
return MethodUtil.invoke(readMethod, complex, new Class[0]);
|
||||
return MethodUtil.invoke(readMethod, complex, new Class<?>[0]);
|
||||
}
|
||||
|
||||
throw new AttributeNotFoundException(
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user