From 87be0f2e80f6fba87014068645291842bd3ea0ad Mon Sep 17 00:00:00 2001 From: Anton Litvinov Date: Fri, 2 Jun 2017 18:40:55 +0300 Subject: [PATCH 01/59] 8181192: [macos] javafx.print.PrinterJob.showPrintDialog() hangs on macOS Reviewed-by: prr, serb --- .../macosx/native/libawt_lwawt/awt/CPrinterJob.m | 4 ++-- .../share/classes/sun/print/RasterPrinterJob.java | 8 ++++++++ .../java/awt/print/PageFormat/WrongPaperPrintingTest.java | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m index db54e27faca..03a32ddd8e7 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m @@ -376,7 +376,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I"); - static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;"); + static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;"); NSMutableDictionary* printingDictionary = [dst dictionary]; @@ -412,7 +412,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; - jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat, (jint)0); + jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); if (page != NULL) { javaPageFormatToNSPrintInfo(env, NULL, page, dst); } diff --git a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index b856b4aa1e7..018ac519d00 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -886,6 +886,14 @@ public abstract class RasterPrinterJob extends PrinterJob { } } + protected PageFormat getPageFormatFromAttributes() { + if (attributes == null || attributes.isEmpty()) { + return null; + } + return attributeToPageFormat(getPrintService(), this.attributes); + } + + /** * Presents the user a dialog for changing properties of the * print job interactively. diff --git a/jdk/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java b/jdk/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java index 79f07489e3f..2299015b25d 100644 --- a/jdk/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java +++ b/jdk/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java @@ -24,6 +24,7 @@ /* @test @bug 8167102 @summary PrintRequestAttributeSet breaks page size set using PageFormat + @ignore Exclude the test until 8167102 is resolved by a new reassessed fix @run main/manual WrongPaperPrintingTest */ From c4d86b2455ba0dad12de2f7e35a67c91279385b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20=C3=96sterlund?= Date: Tue, 6 Jun 2017 13:31:34 -0400 Subject: [PATCH 02/59] 8161145: The min/max macros make hotspot tests fail to build with GCC 6 Change min/max macros to expand (once) to self. Reviewed-by: sgehwolf, pliden, andrew --- hotspot/src/share/vm/utilities/globalDefinitions.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index e07ed31678d..dbb080ef6e3 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1095,8 +1095,11 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) { #undef min #endif -#define max(a,b) Do_not_use_max_use_MAX2_instead -#define min(a,b) Do_not_use_min_use_MIN2_instead +// The following defines serve the purpose of preventing use of accidentally +// included min max macros from compiling, while continuing to allow innocent +// min and max identifiers in the code to compile as intended. +#define max max +#define min min // It is necessary to use templates here. Having normal overloaded // functions does not work because it is necessary to provide both 32- From 061b09e8472d7d45c25d869aace8eb5fe5237e7b Mon Sep 17 00:00:00 2001 From: Ron Pressler Date: Mon, 5 Jun 2017 15:52:09 -0700 Subject: [PATCH 03/59] 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9 Co-authored-by: Claes Redestad Reviewed-by: psandoz, dholmes, thartmann, kvn --- .../hotspot/test/CheckGraalIntrinsics.java | 56 ++++---- .../StandardGraphBuilderPlugins.java | 8 +- hotspot/src/share/vm/c1/c1_Compiler.cpp | 8 +- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 8 +- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 8 +- hotspot/src/share/vm/classfile/vmSymbols.cpp | 35 ++--- hotspot/src/share/vm/classfile/vmSymbols.hpp | 130 +++++++++--------- hotspot/src/share/vm/opto/c2compiler.cpp | 72 +++++----- hotspot/src/share/vm/opto/library_call.cpp | 89 ++++++------ hotspot/src/share/vm/prims/unsafe.cpp | 22 +-- .../src/share/vm/shark/sharkIntrinsics.cpp | 10 +- .../src/share/vm/shark/sharkIntrinsics.hpp | 4 +- .../c2/cr8004867/TestIntUnsafeCAS.java | 108 +++++++-------- .../intrinsics/unsafe/TestCAEAntiDep.java | 3 +- .../intrinsics/unsafe/UnsafeTwoCASLong.java | 7 +- .../test/compiler/profiling/UnsafeAccess.java | 2 +- ...dkInternalMiscUnsafeAccessTestBoolean.java | 51 ++++--- .../JdkInternalMiscUnsafeAccessTestByte.java | 51 ++++--- .../JdkInternalMiscUnsafeAccessTestChar.java | 51 ++++--- ...JdkInternalMiscUnsafeAccessTestDouble.java | 51 ++++--- .../JdkInternalMiscUnsafeAccessTestFloat.java | 51 ++++--- .../JdkInternalMiscUnsafeAccessTestInt.java | 51 ++++--- .../JdkInternalMiscUnsafeAccessTestLong.java | 51 ++++--- ...JdkInternalMiscUnsafeAccessTestObject.java | 51 ++++--- .../JdkInternalMiscUnsafeAccessTestShort.java | 51 ++++--- .../SunMiscUnsafeAccessTestBoolean.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestByte.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestChar.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestDouble.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestFloat.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestInt.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestLong.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestObject.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestShort.java | 3 +- .../unsafe/X-UnsafeAccessTest.java.template | 61 +++++--- 35 files changed, 566 insertions(+), 551 deletions(-) diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java index d070eb08fbc..9a73893a4f5 100644 --- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java +++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -246,21 +246,21 @@ public class CheckGraalIntrinsics extends GraalTest { "jdk/internal/misc/Unsafe.allocateUninitializedArray0(Ljava/lang/Class;I)Ljava/lang/Object;", "jdk/internal/misc/Unsafe.compareAndExchangeByteAcquire(Ljava/lang/Object;JBB)B", "jdk/internal/misc/Unsafe.compareAndExchangeByteRelease(Ljava/lang/Object;JBB)B", - "jdk/internal/misc/Unsafe.compareAndExchangeByteVolatile(Ljava/lang/Object;JBB)B", + "jdk/internal/misc/Unsafe.compareAndExchangeByte(Ljava/lang/Object;JBB)B", "jdk/internal/misc/Unsafe.compareAndExchangeIntAcquire(Ljava/lang/Object;JII)I", "jdk/internal/misc/Unsafe.compareAndExchangeIntRelease(Ljava/lang/Object;JII)I", - "jdk/internal/misc/Unsafe.compareAndExchangeIntVolatile(Ljava/lang/Object;JII)I", + "jdk/internal/misc/Unsafe.compareAndExchangeInt(Ljava/lang/Object;JII)I", "jdk/internal/misc/Unsafe.compareAndExchangeLongAcquire(Ljava/lang/Object;JJJ)J", "jdk/internal/misc/Unsafe.compareAndExchangeLongRelease(Ljava/lang/Object;JJJ)J", - "jdk/internal/misc/Unsafe.compareAndExchangeLongVolatile(Ljava/lang/Object;JJJ)J", + "jdk/internal/misc/Unsafe.compareAndExchangeLong(Ljava/lang/Object;JJJ)J", "jdk/internal/misc/Unsafe.compareAndExchangeObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "jdk/internal/misc/Unsafe.compareAndExchangeObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", - "jdk/internal/misc/Unsafe.compareAndExchangeObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", + "jdk/internal/misc/Unsafe.compareAndExchangeObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "jdk/internal/misc/Unsafe.compareAndExchangeShortAcquire(Ljava/lang/Object;JSS)S", "jdk/internal/misc/Unsafe.compareAndExchangeShortRelease(Ljava/lang/Object;JSS)S", - "jdk/internal/misc/Unsafe.compareAndExchangeShortVolatile(Ljava/lang/Object;JSS)S", - "jdk/internal/misc/Unsafe.compareAndSwapByte(Ljava/lang/Object;JBB)Z", - "jdk/internal/misc/Unsafe.compareAndSwapShort(Ljava/lang/Object;JSS)Z", + "jdk/internal/misc/Unsafe.compareAndExchangeShort(Ljava/lang/Object;JSS)S", + "jdk/internal/misc/Unsafe.compareAndSetByte(Ljava/lang/Object;JBB)Z", + "jdk/internal/misc/Unsafe.compareAndSetShort(Ljava/lang/Object;JSS)Z", "jdk/internal/misc/Unsafe.copyMemory0(Ljava/lang/Object;JLjava/lang/Object;JJ)V", "jdk/internal/misc/Unsafe.getAndAddByte(Ljava/lang/Object;JB)B", "jdk/internal/misc/Unsafe.getAndAddShort(Ljava/lang/Object;JS)S", @@ -295,26 +295,26 @@ public class CheckGraalIntrinsics extends GraalTest { "jdk/internal/misc/Unsafe.putObjectOpaque(Ljava/lang/Object;JLjava/lang/Object;)V", "jdk/internal/misc/Unsafe.putShortOpaque(Ljava/lang/Object;JS)V", "jdk/internal/misc/Unsafe.unpark(Ljava/lang/Object;)V", - "jdk/internal/misc/Unsafe.weakCompareAndSwapByte(Ljava/lang/Object;JBB)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapByteAcquire(Ljava/lang/Object;JBB)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapByteRelease(Ljava/lang/Object;JBB)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapByteVolatile(Ljava/lang/Object;JBB)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapInt(Ljava/lang/Object;JII)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapIntAcquire(Ljava/lang/Object;JII)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapIntRelease(Ljava/lang/Object;JII)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapIntVolatile(Ljava/lang/Object;JII)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapLong(Ljava/lang/Object;JJJ)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapLongAcquire(Ljava/lang/Object;JJJ)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapLongRelease(Ljava/lang/Object;JJJ)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapLongVolatile(Ljava/lang/Object;JJJ)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapShort(Ljava/lang/Object;JSS)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapShortAcquire(Ljava/lang/Object;JSS)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapShortRelease(Ljava/lang/Object;JSS)Z", - "jdk/internal/misc/Unsafe.weakCompareAndSwapShortVolatile(Ljava/lang/Object;JSS)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetBytePlain(Ljava/lang/Object;JBB)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetByteAcquire(Ljava/lang/Object;JBB)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetByteRelease(Ljava/lang/Object;JBB)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetByte(Ljava/lang/Object;JBB)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetIntPlain(Ljava/lang/Object;JII)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetIntAcquire(Ljava/lang/Object;JII)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetIntRelease(Ljava/lang/Object;JII)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetInt(Ljava/lang/Object;JII)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetLongPlain(Ljava/lang/Object;JJJ)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetLongAcquire(Ljava/lang/Object;JJJ)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetLongRelease(Ljava/lang/Object;JJJ)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetLong(Ljava/lang/Object;JJJ)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetObjectPlain(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetShortPlain(Ljava/lang/Object;JSS)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetShortAcquire(Ljava/lang/Object;JSS)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetShortRelease(Ljava/lang/Object;JSS)Z", + "jdk/internal/misc/Unsafe.weakCompareAndSetShort(Ljava/lang/Object;JSS)Z", "jdk/internal/util/Preconditions.checkIndex(IILjava/util/function/BiFunction;)I", "jdk/jfr/internal/JVM.counterTime()J", "jdk/jfr/internal/JVM.getBufferWriter()Ljava/lang/Object;", diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java index 8a45e457eda..ccc89420c7a 100644 --- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java +++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java @@ -251,7 +251,13 @@ public class StandardGraphBuilderPlugins { for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}) { Class javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass(); - r.register5("compareAndSwap" + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() { + String casName; + if (Java8OrEarlier) { + casName = "compareAndSwap"; + } else { + casName = "compareAndSet"; + } + r.register5(casName + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode expected, ValueNode x) { // Emits a null-check for the otherwise unused receiver diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 731b9efc96c..416f0f38fc8 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,7 +108,7 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { } switch (id) { - case vmIntrinsics::_compareAndSwapLong: + case vmIntrinsics::_compareAndSetLong: if (!VM_Version::supports_cx8()) return false; break; case vmIntrinsics::_getAndAddInt: @@ -217,8 +217,8 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { case vmIntrinsics::_updateDirectByteBufferCRC32C: #endif case vmIntrinsics::_vectorizedMismatch: - case vmIntrinsics::_compareAndSwapInt: - case vmIntrinsics::_compareAndSwapObject: + case vmIntrinsics::_compareAndSetInt: + case vmIntrinsics::_compareAndSetObject: case vmIntrinsics::_getCharStringU: case vmIntrinsics::_putCharStringU: #ifdef TRACE_HAVE_INTRINSICS diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 200a3fc782d..d4400483912 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3500,9 +3500,9 @@ void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee, bool ignore_retur case vmIntrinsics::_putLongVolatile : append_unsafe_put_obj(callee, T_LONG, true); return; case vmIntrinsics::_putFloatVolatile : append_unsafe_put_obj(callee, T_FLOAT, true); return; case vmIntrinsics::_putDoubleVolatile : append_unsafe_put_obj(callee, T_DOUBLE, true); return; - case vmIntrinsics::_compareAndSwapLong: - case vmIntrinsics::_compareAndSwapInt: - case vmIntrinsics::_compareAndSwapObject: append_unsafe_CAS(callee); return; + case vmIntrinsics::_compareAndSetLong: + case vmIntrinsics::_compareAndSetInt: + case vmIntrinsics::_compareAndSetObject: append_unsafe_CAS(callee); return; case vmIntrinsics::_getAndAddInt: case vmIntrinsics::_getAndAddLong : append_unsafe_get_and_set_obj(callee, true); return; case vmIntrinsics::_getAndSetInt : diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index 8143eefb83d..68c959280d7 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3212,13 +3212,13 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { // java.nio.Buffer.checkIndex case vmIntrinsics::_checkIndex: do_NIOCheckIndex(x); break; - case vmIntrinsics::_compareAndSwapObject: + case vmIntrinsics::_compareAndSetObject: do_CompareAndSwap(x, objectType); break; - case vmIntrinsics::_compareAndSwapInt: + case vmIntrinsics::_compareAndSetInt: do_CompareAndSwap(x, intType); break; - case vmIntrinsics::_compareAndSwapLong: + case vmIntrinsics::_compareAndSetLong: do_CompareAndSwap(x, longType); break; diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp index ad17837fb0d..e56b4e95d6c 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.cpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -632,25 +632,28 @@ bool vmIntrinsics::is_disabled_by_flags(vmIntrinsics::ID id) { case vmIntrinsics::_loadFence: case vmIntrinsics::_storeFence: case vmIntrinsics::_fullFence: - case vmIntrinsics::_compareAndSwapLong: - case vmIntrinsics::_weakCompareAndSwapLong: - case vmIntrinsics::_weakCompareAndSwapLongAcquire: - case vmIntrinsics::_weakCompareAndSwapLongRelease: - case vmIntrinsics::_compareAndSwapInt: - case vmIntrinsics::_weakCompareAndSwapInt: - case vmIntrinsics::_weakCompareAndSwapIntAcquire: - case vmIntrinsics::_weakCompareAndSwapIntRelease: - case vmIntrinsics::_compareAndSwapObject: - case vmIntrinsics::_weakCompareAndSwapObject: - case vmIntrinsics::_weakCompareAndSwapObjectAcquire: - case vmIntrinsics::_weakCompareAndSwapObjectRelease: - case vmIntrinsics::_compareAndExchangeIntVolatile: + case vmIntrinsics::_compareAndSetLong: + case vmIntrinsics::_weakCompareAndSetLong: + case vmIntrinsics::_weakCompareAndSetLongPlain: + case vmIntrinsics::_weakCompareAndSetLongAcquire: + case vmIntrinsics::_weakCompareAndSetLongRelease: + case vmIntrinsics::_compareAndSetInt: + case vmIntrinsics::_weakCompareAndSetInt: + case vmIntrinsics::_weakCompareAndSetIntPlain: + case vmIntrinsics::_weakCompareAndSetIntAcquire: + case vmIntrinsics::_weakCompareAndSetIntRelease: + case vmIntrinsics::_compareAndSetObject: + case vmIntrinsics::_weakCompareAndSetObject: + case vmIntrinsics::_weakCompareAndSetObjectPlain: + case vmIntrinsics::_weakCompareAndSetObjectAcquire: + case vmIntrinsics::_weakCompareAndSetObjectRelease: + case vmIntrinsics::_compareAndExchangeInt: case vmIntrinsics::_compareAndExchangeIntAcquire: case vmIntrinsics::_compareAndExchangeIntRelease: - case vmIntrinsics::_compareAndExchangeLongVolatile: + case vmIntrinsics::_compareAndExchangeLong: case vmIntrinsics::_compareAndExchangeLongAcquire: case vmIntrinsics::_compareAndExchangeLongRelease: - case vmIntrinsics::_compareAndExchangeObjectVolatile: + case vmIntrinsics::_compareAndExchangeObject: case vmIntrinsics::_compareAndExchangeObjectAcquire: case vmIntrinsics::_compareAndExchangeObjectRelease: if (!InlineUnsafeOps) return true; diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 13405609579..15aa3613422 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -1244,100 +1244,100 @@ do_intrinsic(_putIntUnaligned, jdk_internal_misc_Unsafe, putIntUnaligned_name, putInt_signature, F_R) \ do_intrinsic(_putLongUnaligned, jdk_internal_misc_Unsafe, putLongUnaligned_name, putLong_signature, F_R) \ \ - do_signature(compareAndSwapObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z") \ + do_signature(compareAndSetObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z") \ do_signature(compareAndExchangeObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;") \ - do_signature(compareAndSwapLong_signature, "(Ljava/lang/Object;JJJ)Z") \ + do_signature(compareAndSetLong_signature, "(Ljava/lang/Object;JJJ)Z") \ do_signature(compareAndExchangeLong_signature, "(Ljava/lang/Object;JJJ)J") \ - do_signature(compareAndSwapInt_signature, "(Ljava/lang/Object;JII)Z") \ + do_signature(compareAndSetInt_signature, "(Ljava/lang/Object;JII)Z") \ do_signature(compareAndExchangeInt_signature, "(Ljava/lang/Object;JII)I") \ - do_signature(compareAndSwapByte_signature, "(Ljava/lang/Object;JBB)Z") \ + do_signature(compareAndSetByte_signature, "(Ljava/lang/Object;JBB)Z") \ do_signature(compareAndExchangeByte_signature, "(Ljava/lang/Object;JBB)B") \ - do_signature(compareAndSwapShort_signature, "(Ljava/lang/Object;JSS)Z") \ + do_signature(compareAndSetShort_signature, "(Ljava/lang/Object;JSS)Z") \ do_signature(compareAndExchangeShort_signature, "(Ljava/lang/Object;JSS)S") \ \ - do_name(compareAndSwapObject_name, "compareAndSwapObject") \ - do_name(compareAndExchangeObjectVolatile_name, "compareAndExchangeObjectVolatile") \ + do_name(compareAndSetObject_name, "compareAndSetObject") \ + do_name(compareAndExchangeObject_name, "compareAndExchangeObject") \ do_name(compareAndExchangeObjectAcquire_name, "compareAndExchangeObjectAcquire") \ do_name(compareAndExchangeObjectRelease_name, "compareAndExchangeObjectRelease") \ - do_name(compareAndSwapLong_name, "compareAndSwapLong") \ - do_name(compareAndExchangeLongVolatile_name, "compareAndExchangeLongVolatile") \ + do_name(compareAndSetLong_name, "compareAndSetLong") \ + do_name(compareAndExchangeLong_name, "compareAndExchangeLong") \ do_name(compareAndExchangeLongAcquire_name, "compareAndExchangeLongAcquire") \ do_name(compareAndExchangeLongRelease_name, "compareAndExchangeLongRelease") \ - do_name(compareAndSwapInt_name, "compareAndSwapInt") \ - do_name(compareAndExchangeIntVolatile_name, "compareAndExchangeIntVolatile") \ + do_name(compareAndSetInt_name, "compareAndSetInt") \ + do_name(compareAndExchangeInt_name, "compareAndExchangeInt") \ do_name(compareAndExchangeIntAcquire_name, "compareAndExchangeIntAcquire") \ do_name(compareAndExchangeIntRelease_name, "compareAndExchangeIntRelease") \ - do_name(compareAndSwapByte_name, "compareAndSwapByte") \ - do_name(compareAndExchangeByteVolatile_name, "compareAndExchangeByteVolatile") \ + do_name(compareAndSetByte_name, "compareAndSetByte") \ + do_name(compareAndExchangeByte_name, "compareAndExchangeByte") \ do_name(compareAndExchangeByteAcquire_name, "compareAndExchangeByteAcquire") \ do_name(compareAndExchangeByteRelease_name, "compareAndExchangeByteRelease") \ - do_name(compareAndSwapShort_name, "compareAndSwapShort") \ - do_name(compareAndExchangeShortVolatile_name, "compareAndExchangeShortVolatile") \ + do_name(compareAndSetShort_name, "compareAndSetShort") \ + do_name(compareAndExchangeShort_name, "compareAndExchangeShort") \ do_name(compareAndExchangeShortAcquire_name, "compareAndExchangeShortAcquire") \ do_name(compareAndExchangeShortRelease_name, "compareAndExchangeShortRelease") \ \ - do_name(weakCompareAndSwapObject_name, "weakCompareAndSwapObject") \ - do_name(weakCompareAndSwapObjectAcquire_name, "weakCompareAndSwapObjectAcquire") \ - do_name(weakCompareAndSwapObjectRelease_name, "weakCompareAndSwapObjectRelease") \ - do_name(weakCompareAndSwapObjectVolatile_name, "weakCompareAndSwapObjectVolatile") \ - do_name(weakCompareAndSwapLong_name, "weakCompareAndSwapLong") \ - do_name(weakCompareAndSwapLongAcquire_name, "weakCompareAndSwapLongAcquire") \ - do_name(weakCompareAndSwapLongRelease_name, "weakCompareAndSwapLongRelease") \ - do_name(weakCompareAndSwapLongVolatile_name, "weakCompareAndSwapLongVolatile") \ - do_name(weakCompareAndSwapInt_name, "weakCompareAndSwapInt") \ - do_name(weakCompareAndSwapIntAcquire_name, "weakCompareAndSwapIntAcquire") \ - do_name(weakCompareAndSwapIntRelease_name, "weakCompareAndSwapIntRelease") \ - do_name(weakCompareAndSwapIntVolatile_name, "weakCompareAndSwapIntVolatile") \ - do_name(weakCompareAndSwapByte_name, "weakCompareAndSwapByte") \ - do_name(weakCompareAndSwapByteAcquire_name, "weakCompareAndSwapByteAcquire") \ - do_name(weakCompareAndSwapByteRelease_name, "weakCompareAndSwapByteRelease") \ - do_name(weakCompareAndSwapByteVolatile_name, "weakCompareAndSwapByteVolatile") \ - do_name(weakCompareAndSwapShort_name, "weakCompareAndSwapShort") \ - do_name(weakCompareAndSwapShortAcquire_name, "weakCompareAndSwapShortAcquire") \ - do_name(weakCompareAndSwapShortRelease_name, "weakCompareAndSwapShortRelease") \ - do_name(weakCompareAndSwapShortVolatile_name, "weakCompareAndSwapShortVolatile") \ + do_name(weakCompareAndSetObjectPlain_name, "weakCompareAndSetObjectPlain") \ + do_name(weakCompareAndSetObjectAcquire_name, "weakCompareAndSetObjectAcquire") \ + do_name(weakCompareAndSetObjectRelease_name, "weakCompareAndSetObjectRelease") \ + do_name(weakCompareAndSetObject_name, "weakCompareAndSetObject") \ + do_name(weakCompareAndSetLongPlain_name, "weakCompareAndSetLongPlain") \ + do_name(weakCompareAndSetLongAcquire_name, "weakCompareAndSetLongAcquire") \ + do_name(weakCompareAndSetLongRelease_name, "weakCompareAndSetLongRelease") \ + do_name(weakCompareAndSetLong_name, "weakCompareAndSetLong") \ + do_name(weakCompareAndSetIntPlain_name, "weakCompareAndSetIntPlain") \ + do_name(weakCompareAndSetIntAcquire_name, "weakCompareAndSetIntAcquire") \ + do_name(weakCompareAndSetIntRelease_name, "weakCompareAndSetIntRelease") \ + do_name(weakCompareAndSetInt_name, "weakCompareAndSetInt") \ + do_name(weakCompareAndSetBytePlain_name, "weakCompareAndSetBytePlain") \ + do_name(weakCompareAndSetByteAcquire_name, "weakCompareAndSetByteAcquire") \ + do_name(weakCompareAndSetByteRelease_name, "weakCompareAndSetByteRelease") \ + do_name(weakCompareAndSetByte_name, "weakCompareAndSetByte") \ + do_name(weakCompareAndSetShortPlain_name, "weakCompareAndSetShortPlain") \ + do_name(weakCompareAndSetShortAcquire_name, "weakCompareAndSetShortAcquire") \ + do_name(weakCompareAndSetShortRelease_name, "weakCompareAndSetShortRelease") \ + do_name(weakCompareAndSetShort_name, "weakCompareAndSetShort") \ \ - do_intrinsic(_compareAndSwapObject, jdk_internal_misc_Unsafe, compareAndSwapObject_name, compareAndSwapObject_signature, F_RN) \ - do_intrinsic(_compareAndExchangeObjectVolatile, jdk_internal_misc_Unsafe, compareAndExchangeObjectVolatile_name, compareAndExchangeObject_signature, F_RN) \ + do_intrinsic(_compareAndSetObject, jdk_internal_misc_Unsafe, compareAndSetObject_name, compareAndSetObject_signature, F_RN) \ + do_intrinsic(_compareAndExchangeObject, jdk_internal_misc_Unsafe, compareAndExchangeObject_name, compareAndExchangeObject_signature, F_RN) \ do_intrinsic(_compareAndExchangeObjectAcquire, jdk_internal_misc_Unsafe, compareAndExchangeObjectAcquire_name, compareAndExchangeObject_signature, F_R) \ do_intrinsic(_compareAndExchangeObjectRelease, jdk_internal_misc_Unsafe, compareAndExchangeObjectRelease_name, compareAndExchangeObject_signature, F_R) \ - do_intrinsic(_compareAndSwapLong, jdk_internal_misc_Unsafe, compareAndSwapLong_name, compareAndSwapLong_signature, F_RN) \ - do_intrinsic(_compareAndExchangeLongVolatile, jdk_internal_misc_Unsafe, compareAndExchangeLongVolatile_name, compareAndExchangeLong_signature, F_RN) \ + do_intrinsic(_compareAndSetLong, jdk_internal_misc_Unsafe, compareAndSetLong_name, compareAndSetLong_signature, F_RN) \ + do_intrinsic(_compareAndExchangeLong, jdk_internal_misc_Unsafe, compareAndExchangeLong_name, compareAndExchangeLong_signature, F_RN) \ do_intrinsic(_compareAndExchangeLongAcquire, jdk_internal_misc_Unsafe, compareAndExchangeLongAcquire_name, compareAndExchangeLong_signature, F_R) \ do_intrinsic(_compareAndExchangeLongRelease, jdk_internal_misc_Unsafe, compareAndExchangeLongRelease_name, compareAndExchangeLong_signature, F_R) \ - do_intrinsic(_compareAndSwapInt, jdk_internal_misc_Unsafe, compareAndSwapInt_name, compareAndSwapInt_signature, F_RN) \ - do_intrinsic(_compareAndExchangeIntVolatile, jdk_internal_misc_Unsafe, compareAndExchangeIntVolatile_name, compareAndExchangeInt_signature, F_RN) \ + do_intrinsic(_compareAndSetInt, jdk_internal_misc_Unsafe, compareAndSetInt_name, compareAndSetInt_signature, F_RN) \ + do_intrinsic(_compareAndExchangeInt, jdk_internal_misc_Unsafe, compareAndExchangeInt_name, compareAndExchangeInt_signature, F_RN) \ do_intrinsic(_compareAndExchangeIntAcquire, jdk_internal_misc_Unsafe, compareAndExchangeIntAcquire_name, compareAndExchangeInt_signature, F_R) \ do_intrinsic(_compareAndExchangeIntRelease, jdk_internal_misc_Unsafe, compareAndExchangeIntRelease_name, compareAndExchangeInt_signature, F_R) \ - do_intrinsic(_compareAndSwapByte, jdk_internal_misc_Unsafe, compareAndSwapByte_name, compareAndSwapByte_signature, F_R) \ - do_intrinsic(_compareAndExchangeByteVolatile, jdk_internal_misc_Unsafe, compareAndExchangeByteVolatile_name, compareAndExchangeByte_signature, F_R) \ + do_intrinsic(_compareAndSetByte, jdk_internal_misc_Unsafe, compareAndSetByte_name, compareAndSetByte_signature, F_R) \ + do_intrinsic(_compareAndExchangeByte, jdk_internal_misc_Unsafe, compareAndExchangeByte_name, compareAndExchangeByte_signature, F_R) \ do_intrinsic(_compareAndExchangeByteAcquire, jdk_internal_misc_Unsafe, compareAndExchangeByteAcquire_name, compareAndExchangeByte_signature, F_R) \ do_intrinsic(_compareAndExchangeByteRelease, jdk_internal_misc_Unsafe, compareAndExchangeByteRelease_name, compareAndExchangeByte_signature, F_R) \ - do_intrinsic(_compareAndSwapShort, jdk_internal_misc_Unsafe, compareAndSwapShort_name, compareAndSwapShort_signature, F_R) \ - do_intrinsic(_compareAndExchangeShortVolatile, jdk_internal_misc_Unsafe, compareAndExchangeShortVolatile_name, compareAndExchangeShort_signature, F_R) \ + do_intrinsic(_compareAndSetShort, jdk_internal_misc_Unsafe, compareAndSetShort_name, compareAndSetShort_signature, F_R) \ + do_intrinsic(_compareAndExchangeShort, jdk_internal_misc_Unsafe, compareAndExchangeShort_name, compareAndExchangeShort_signature, F_R) \ do_intrinsic(_compareAndExchangeShortAcquire, jdk_internal_misc_Unsafe, compareAndExchangeShortAcquire_name, compareAndExchangeShort_signature, F_R) \ do_intrinsic(_compareAndExchangeShortRelease, jdk_internal_misc_Unsafe, compareAndExchangeShortRelease_name, compareAndExchangeShort_signature, F_R) \ \ - do_intrinsic(_weakCompareAndSwapObject, jdk_internal_misc_Unsafe, weakCompareAndSwapObject_name, compareAndSwapObject_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapObjectAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapObjectAcquire_name, compareAndSwapObject_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapObjectRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapObjectRelease_name, compareAndSwapObject_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapObjectVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapObjectVolatile_name, compareAndSwapObject_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapLong, jdk_internal_misc_Unsafe, weakCompareAndSwapLong_name, compareAndSwapLong_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapLongAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapLongAcquire_name, compareAndSwapLong_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapLongRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapLongRelease_name, compareAndSwapLong_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapLongVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapLongVolatile_name, compareAndSwapLong_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapInt, jdk_internal_misc_Unsafe, weakCompareAndSwapInt_name, compareAndSwapInt_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapIntAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapIntAcquire_name, compareAndSwapInt_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapIntRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapIntRelease_name, compareAndSwapInt_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapIntVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapIntVolatile_name, compareAndSwapInt_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapByte, jdk_internal_misc_Unsafe, weakCompareAndSwapByte_name, compareAndSwapByte_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapByteAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapByteAcquire_name, compareAndSwapByte_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapByteRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapByteRelease_name, compareAndSwapByte_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapByteVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapByteVolatile_name, compareAndSwapByte_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapShort, jdk_internal_misc_Unsafe, weakCompareAndSwapShort_name, compareAndSwapShort_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapShortAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapShortAcquire_name, compareAndSwapShort_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapShortRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapShortRelease_name, compareAndSwapShort_signature, F_R) \ - do_intrinsic(_weakCompareAndSwapShortVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapShortVolatile_name, compareAndSwapShort_signature, F_R) \ + do_intrinsic(_weakCompareAndSetObjectPlain, jdk_internal_misc_Unsafe, weakCompareAndSetObjectPlain_name, compareAndSetObject_signature, F_R) \ + do_intrinsic(_weakCompareAndSetObjectAcquire, jdk_internal_misc_Unsafe, weakCompareAndSetObjectAcquire_name, compareAndSetObject_signature, F_R) \ + do_intrinsic(_weakCompareAndSetObjectRelease, jdk_internal_misc_Unsafe, weakCompareAndSetObjectRelease_name, compareAndSetObject_signature, F_R) \ + do_intrinsic(_weakCompareAndSetObject, jdk_internal_misc_Unsafe, weakCompareAndSetObject_name, compareAndSetObject_signature, F_R) \ + do_intrinsic(_weakCompareAndSetLongPlain, jdk_internal_misc_Unsafe, weakCompareAndSetLongPlain_name, compareAndSetLong_signature, F_R) \ + do_intrinsic(_weakCompareAndSetLongAcquire, jdk_internal_misc_Unsafe, weakCompareAndSetLongAcquire_name, compareAndSetLong_signature, F_R) \ + do_intrinsic(_weakCompareAndSetLongRelease, jdk_internal_misc_Unsafe, weakCompareAndSetLongRelease_name, compareAndSetLong_signature, F_R) \ + do_intrinsic(_weakCompareAndSetLong, jdk_internal_misc_Unsafe, weakCompareAndSetLong_name, compareAndSetLong_signature, F_R) \ + do_intrinsic(_weakCompareAndSetIntPlain, jdk_internal_misc_Unsafe, weakCompareAndSetIntPlain_name, compareAndSetInt_signature, F_R) \ + do_intrinsic(_weakCompareAndSetIntAcquire, jdk_internal_misc_Unsafe, weakCompareAndSetIntAcquire_name, compareAndSetInt_signature, F_R) \ + do_intrinsic(_weakCompareAndSetIntRelease, jdk_internal_misc_Unsafe, weakCompareAndSetIntRelease_name, compareAndSetInt_signature, F_R) \ + do_intrinsic(_weakCompareAndSetInt, jdk_internal_misc_Unsafe, weakCompareAndSetInt_name, compareAndSetInt_signature, F_R) \ + do_intrinsic(_weakCompareAndSetBytePlain, jdk_internal_misc_Unsafe, weakCompareAndSetBytePlain_name, compareAndSetByte_signature, F_R) \ + do_intrinsic(_weakCompareAndSetByteAcquire, jdk_internal_misc_Unsafe, weakCompareAndSetByteAcquire_name, compareAndSetByte_signature, F_R) \ + do_intrinsic(_weakCompareAndSetByteRelease, jdk_internal_misc_Unsafe, weakCompareAndSetByteRelease_name, compareAndSetByte_signature, F_R) \ + do_intrinsic(_weakCompareAndSetByte, jdk_internal_misc_Unsafe, weakCompareAndSetByte_name, compareAndSetByte_signature, F_R) \ + do_intrinsic(_weakCompareAndSetShortPlain, jdk_internal_misc_Unsafe, weakCompareAndSetShortPlain_name, compareAndSetShort_signature, F_R) \ + do_intrinsic(_weakCompareAndSetShortAcquire, jdk_internal_misc_Unsafe, weakCompareAndSetShortAcquire_name, compareAndSetShort_signature, F_R) \ + do_intrinsic(_weakCompareAndSetShortRelease, jdk_internal_misc_Unsafe, weakCompareAndSetShortRelease_name, compareAndSetShort_signature, F_R) \ + do_intrinsic(_weakCompareAndSetShort, jdk_internal_misc_Unsafe, weakCompareAndSetShort_name, compareAndSetShort_signature, F_R) \ \ do_intrinsic(_getAndAddInt, jdk_internal_misc_Unsafe, getAndAddInt_name, getAndAddInt_signature, F_R) \ do_name( getAndAddInt_name, "getAndAddInt") \ diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index ec7e03c5ff0..69106bbeaa2 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -244,8 +244,8 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return false; break; - /* CompareAndSwap, Object: */ - case vmIntrinsics::_compareAndSwapObject: + /* CompareAndSet, Object: */ + case vmIntrinsics::_compareAndSetObject: #ifdef _LP64 if ( UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapN)) return false; if (!UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapP)) return false; @@ -253,10 +253,10 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt if (!Matcher::match_rule_supported(Op_CompareAndSwapP)) return false; #endif break; - case vmIntrinsics::_weakCompareAndSwapObject: - case vmIntrinsics::_weakCompareAndSwapObjectAcquire: - case vmIntrinsics::_weakCompareAndSwapObjectRelease: - case vmIntrinsics::_weakCompareAndSwapObjectVolatile: + case vmIntrinsics::_weakCompareAndSetObjectPlain: + case vmIntrinsics::_weakCompareAndSetObjectAcquire: + case vmIntrinsics::_weakCompareAndSetObjectRelease: + case vmIntrinsics::_weakCompareAndSetObject: #ifdef _LP64 if ( UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapN)) return false; if (!UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false; @@ -264,52 +264,52 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false; #endif break; - /* CompareAndSwap, Long: */ - case vmIntrinsics::_compareAndSwapLong: + /* CompareAndSet, Long: */ + case vmIntrinsics::_compareAndSetLong: if (!Matcher::match_rule_supported(Op_CompareAndSwapL)) return false; break; - case vmIntrinsics::_weakCompareAndSwapLong: - case vmIntrinsics::_weakCompareAndSwapLongAcquire: - case vmIntrinsics::_weakCompareAndSwapLongRelease: - case vmIntrinsics::_weakCompareAndSwapLongVolatile: + case vmIntrinsics::_weakCompareAndSetLongPlain: + case vmIntrinsics::_weakCompareAndSetLongAcquire: + case vmIntrinsics::_weakCompareAndSetLongRelease: + case vmIntrinsics::_weakCompareAndSetLong: if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false; break; - /* CompareAndSwap, Int: */ - case vmIntrinsics::_compareAndSwapInt: + /* CompareAndSet, Int: */ + case vmIntrinsics::_compareAndSetInt: if (!Matcher::match_rule_supported(Op_CompareAndSwapI)) return false; break; - case vmIntrinsics::_weakCompareAndSwapInt: - case vmIntrinsics::_weakCompareAndSwapIntAcquire: - case vmIntrinsics::_weakCompareAndSwapIntRelease: - case vmIntrinsics::_weakCompareAndSwapIntVolatile: + case vmIntrinsics::_weakCompareAndSetIntPlain: + case vmIntrinsics::_weakCompareAndSetIntAcquire: + case vmIntrinsics::_weakCompareAndSetIntRelease: + case vmIntrinsics::_weakCompareAndSetInt: if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false; break; - /* CompareAndSwap, Byte: */ - case vmIntrinsics::_compareAndSwapByte: + /* CompareAndSet, Byte: */ + case vmIntrinsics::_compareAndSetByte: if (!Matcher::match_rule_supported(Op_CompareAndSwapB)) return false; break; - case vmIntrinsics::_weakCompareAndSwapByte: - case vmIntrinsics::_weakCompareAndSwapByteAcquire: - case vmIntrinsics::_weakCompareAndSwapByteRelease: - case vmIntrinsics::_weakCompareAndSwapByteVolatile: + case vmIntrinsics::_weakCompareAndSetBytePlain: + case vmIntrinsics::_weakCompareAndSetByteAcquire: + case vmIntrinsics::_weakCompareAndSetByteRelease: + case vmIntrinsics::_weakCompareAndSetByte: if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapB)) return false; break; - /* CompareAndSwap, Short: */ - case vmIntrinsics::_compareAndSwapShort: + /* CompareAndSet, Short: */ + case vmIntrinsics::_compareAndSetShort: if (!Matcher::match_rule_supported(Op_CompareAndSwapS)) return false; break; - case vmIntrinsics::_weakCompareAndSwapShort: - case vmIntrinsics::_weakCompareAndSwapShortAcquire: - case vmIntrinsics::_weakCompareAndSwapShortRelease: - case vmIntrinsics::_weakCompareAndSwapShortVolatile: + case vmIntrinsics::_weakCompareAndSetShortPlain: + case vmIntrinsics::_weakCompareAndSetShortAcquire: + case vmIntrinsics::_weakCompareAndSetShortRelease: + case vmIntrinsics::_weakCompareAndSetShort: if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapS)) return false; break; /* CompareAndExchange, Object: */ - case vmIntrinsics::_compareAndExchangeObjectVolatile: + case vmIntrinsics::_compareAndExchangeObject: case vmIntrinsics::_compareAndExchangeObjectAcquire: case vmIntrinsics::_compareAndExchangeObjectRelease: #ifdef _LP64 @@ -321,28 +321,28 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt break; /* CompareAndExchange, Long: */ - case vmIntrinsics::_compareAndExchangeLongVolatile: + case vmIntrinsics::_compareAndExchangeLong: case vmIntrinsics::_compareAndExchangeLongAcquire: case vmIntrinsics::_compareAndExchangeLongRelease: if (!Matcher::match_rule_supported(Op_CompareAndExchangeL)) return false; break; /* CompareAndExchange, Int: */ - case vmIntrinsics::_compareAndExchangeIntVolatile: + case vmIntrinsics::_compareAndExchangeInt: case vmIntrinsics::_compareAndExchangeIntAcquire: case vmIntrinsics::_compareAndExchangeIntRelease: if (!Matcher::match_rule_supported(Op_CompareAndExchangeI)) return false; break; /* CompareAndExchange, Byte: */ - case vmIntrinsics::_compareAndExchangeByteVolatile: + case vmIntrinsics::_compareAndExchangeByte: case vmIntrinsics::_compareAndExchangeByteAcquire: case vmIntrinsics::_compareAndExchangeByteRelease: if (!Matcher::match_rule_supported(Op_CompareAndExchangeB)) return false; break; /* CompareAndExchange, Short: */ - case vmIntrinsics::_compareAndExchangeShortVolatile: + case vmIntrinsics::_compareAndExchangeShort: case vmIntrinsics::_compareAndExchangeShortAcquire: case vmIntrinsics::_compareAndExchangeShortRelease: if (!Matcher::match_rule_supported(Op_CompareAndExchangeS)) return false; diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index e1e1c9f188f..4e5051ee01c 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -649,46 +649,46 @@ bool LibraryCallKit::try_to_inline(int predicate) { case vmIntrinsics::_putFloatOpaque: return inline_unsafe_access( is_store, T_FLOAT, Opaque, false); case vmIntrinsics::_putDoubleOpaque: return inline_unsafe_access( is_store, T_DOUBLE, Opaque, false); - case vmIntrinsics::_compareAndSwapObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap, Volatile); - case vmIntrinsics::_compareAndSwapByte: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap, Volatile); - case vmIntrinsics::_compareAndSwapShort: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap, Volatile); - case vmIntrinsics::_compareAndSwapInt: return inline_unsafe_load_store(T_INT, LS_cmp_swap, Volatile); - case vmIntrinsics::_compareAndSwapLong: return inline_unsafe_load_store(T_LONG, LS_cmp_swap, Volatile); + case vmIntrinsics::_compareAndSetObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap, Volatile); + case vmIntrinsics::_compareAndSetByte: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap, Volatile); + case vmIntrinsics::_compareAndSetShort: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap, Volatile); + case vmIntrinsics::_compareAndSetInt: return inline_unsafe_load_store(T_INT, LS_cmp_swap, Volatile); + case vmIntrinsics::_compareAndSetLong: return inline_unsafe_load_store(T_LONG, LS_cmp_swap, Volatile); - case vmIntrinsics::_weakCompareAndSwapObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed); - case vmIntrinsics::_weakCompareAndSwapObjectAcquire: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire); - case vmIntrinsics::_weakCompareAndSwapObjectRelease: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release); - case vmIntrinsics::_weakCompareAndSwapObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile); - case vmIntrinsics::_weakCompareAndSwapByte: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Relaxed); - case vmIntrinsics::_weakCompareAndSwapByteAcquire: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Acquire); - case vmIntrinsics::_weakCompareAndSwapByteRelease: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Release); - case vmIntrinsics::_weakCompareAndSwapByteVolatile: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Volatile); - case vmIntrinsics::_weakCompareAndSwapShort: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Relaxed); - case vmIntrinsics::_weakCompareAndSwapShortAcquire: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Acquire); - case vmIntrinsics::_weakCompareAndSwapShortRelease: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Release); - case vmIntrinsics::_weakCompareAndSwapShortVolatile: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Volatile); - case vmIntrinsics::_weakCompareAndSwapInt: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Relaxed); - case vmIntrinsics::_weakCompareAndSwapIntAcquire: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Acquire); - case vmIntrinsics::_weakCompareAndSwapIntRelease: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Release); - case vmIntrinsics::_weakCompareAndSwapIntVolatile: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Volatile); - case vmIntrinsics::_weakCompareAndSwapLong: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Relaxed); - case vmIntrinsics::_weakCompareAndSwapLongAcquire: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Acquire); - case vmIntrinsics::_weakCompareAndSwapLongRelease: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Release); - case vmIntrinsics::_weakCompareAndSwapLongVolatile: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Volatile); + case vmIntrinsics::_weakCompareAndSetObjectPlain: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed); + case vmIntrinsics::_weakCompareAndSetObjectAcquire: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire); + case vmIntrinsics::_weakCompareAndSetObjectRelease: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSetObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile); + case vmIntrinsics::_weakCompareAndSetBytePlain: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Relaxed); + case vmIntrinsics::_weakCompareAndSetByteAcquire: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Acquire); + case vmIntrinsics::_weakCompareAndSetByteRelease: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSetByte: return inline_unsafe_load_store(T_BYTE, LS_cmp_swap_weak, Volatile); + case vmIntrinsics::_weakCompareAndSetShortPlain: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Relaxed); + case vmIntrinsics::_weakCompareAndSetShortAcquire: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Acquire); + case vmIntrinsics::_weakCompareAndSetShortRelease: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSetShort: return inline_unsafe_load_store(T_SHORT, LS_cmp_swap_weak, Volatile); + case vmIntrinsics::_weakCompareAndSetIntPlain: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Relaxed); + case vmIntrinsics::_weakCompareAndSetIntAcquire: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Acquire); + case vmIntrinsics::_weakCompareAndSetIntRelease: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSetInt: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Volatile); + case vmIntrinsics::_weakCompareAndSetLongPlain: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Relaxed); + case vmIntrinsics::_weakCompareAndSetLongAcquire: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Acquire); + case vmIntrinsics::_weakCompareAndSetLongRelease: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSetLong: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Volatile); - case vmIntrinsics::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange, Volatile); + case vmIntrinsics::_compareAndExchangeObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange, Volatile); case vmIntrinsics::_compareAndExchangeObjectAcquire: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange, Acquire); case vmIntrinsics::_compareAndExchangeObjectRelease: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange, Release); - case vmIntrinsics::_compareAndExchangeByteVolatile: return inline_unsafe_load_store(T_BYTE, LS_cmp_exchange, Volatile); + case vmIntrinsics::_compareAndExchangeByte: return inline_unsafe_load_store(T_BYTE, LS_cmp_exchange, Volatile); case vmIntrinsics::_compareAndExchangeByteAcquire: return inline_unsafe_load_store(T_BYTE, LS_cmp_exchange, Acquire); case vmIntrinsics::_compareAndExchangeByteRelease: return inline_unsafe_load_store(T_BYTE, LS_cmp_exchange, Release); - case vmIntrinsics::_compareAndExchangeShortVolatile: return inline_unsafe_load_store(T_SHORT, LS_cmp_exchange, Volatile); + case vmIntrinsics::_compareAndExchangeShort: return inline_unsafe_load_store(T_SHORT, LS_cmp_exchange, Volatile); case vmIntrinsics::_compareAndExchangeShortAcquire: return inline_unsafe_load_store(T_SHORT, LS_cmp_exchange, Acquire); case vmIntrinsics::_compareAndExchangeShortRelease: return inline_unsafe_load_store(T_SHORT, LS_cmp_exchange, Release); - case vmIntrinsics::_compareAndExchangeIntVolatile: return inline_unsafe_load_store(T_INT, LS_cmp_exchange, Volatile); + case vmIntrinsics::_compareAndExchangeInt: return inline_unsafe_load_store(T_INT, LS_cmp_exchange, Volatile); case vmIntrinsics::_compareAndExchangeIntAcquire: return inline_unsafe_load_store(T_INT, LS_cmp_exchange, Acquire); case vmIntrinsics::_compareAndExchangeIntRelease: return inline_unsafe_load_store(T_INT, LS_cmp_exchange, Release); - case vmIntrinsics::_compareAndExchangeLongVolatile: return inline_unsafe_load_store(T_LONG, LS_cmp_exchange, Volatile); + case vmIntrinsics::_compareAndExchangeLong: return inline_unsafe_load_store(T_LONG, LS_cmp_exchange, Volatile); case vmIntrinsics::_compareAndExchangeLongAcquire: return inline_unsafe_load_store(T_LONG, LS_cmp_exchange, Acquire); case vmIntrinsics::_compareAndExchangeLongRelease: return inline_unsafe_load_store(T_LONG, LS_cmp_exchange, Release); @@ -2587,23 +2587,26 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c // // LS_cmp_swap: // -// boolean compareAndSwapObject(Object o, long offset, Object expected, Object x); -// boolean compareAndSwapInt( Object o, long offset, int expected, int x); -// boolean compareAndSwapLong( Object o, long offset, long expected, long x); +// boolean compareAndSetObject(Object o, long offset, Object expected, Object x); +// boolean compareAndSetInt( Object o, long offset, int expected, int x); +// boolean compareAndSetLong( Object o, long offset, long expected, long x); // // LS_cmp_swap_weak: // -// boolean weakCompareAndSwapObject( Object o, long offset, Object expected, Object x); -// boolean weakCompareAndSwapObjectAcquire(Object o, long offset, Object expected, Object x); -// boolean weakCompareAndSwapObjectRelease(Object o, long offset, Object expected, Object x); +// boolean weakCompareAndSetObject( Object o, long offset, Object expected, Object x); +// boolean weakCompareAndSetObjectPlain( Object o, long offset, Object expected, Object x); +// boolean weakCompareAndSetObjectAcquire(Object o, long offset, Object expected, Object x); +// boolean weakCompareAndSetObjectRelease(Object o, long offset, Object expected, Object x); // -// boolean weakCompareAndSwapInt( Object o, long offset, int expected, int x); -// boolean weakCompareAndSwapIntAcquire( Object o, long offset, int expected, int x); -// boolean weakCompareAndSwapIntRelease( Object o, long offset, int expected, int x); +// boolean weakCompareAndSetInt( Object o, long offset, int expected, int x); +// boolean weakCompareAndSetIntPlain( Object o, long offset, int expected, int x); +// boolean weakCompareAndSetIntAcquire( Object o, long offset, int expected, int x); +// boolean weakCompareAndSetIntRelease( Object o, long offset, int expected, int x); // -// boolean weakCompareAndSwapLong( Object o, long offset, long expected, long x); -// boolean weakCompareAndSwapLongAcquire( Object o, long offset, long expected, long x); -// boolean weakCompareAndSwapLongRelease( Object o, long offset, long expected, long x); +// boolean weakCompareAndSetLong( Object o, long offset, long expected, long x); +// boolean weakCompareAndSetLongPlain( Object o, long offset, long expected, long x); +// boolean weakCompareAndSetLongAcquire( Object o, long offset, long expected, long x); +// boolean weakCompareAndSetLongRelease( Object o, long offset, long expected, long x); // // LS_cmp_exchange: // @@ -4965,7 +4968,7 @@ bool LibraryCallKit::inline_arraycopy() { // See arraycopy_restore_alloc_state() comment // if alloc == NULL we don't have to worry about a tightly coupled allocation so we can emit all needed guards // if saved_jvms != NULL (then alloc != NULL) then we can handle guards and a tightly coupled allocation - // if saved_jvms == NULL and alloc != NULL, we can’t emit any guards + // if saved_jvms == NULL and alloc != NULL, we can't emit any guards bool can_emit_guards = (alloc == NULL || saved_jvms != NULL); // The following tests must be performed diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 1c98add775b..2f096378201 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -378,7 +378,7 @@ UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe, // On platforms which do not support atomic compare-and-swap of jlong (8 byte) // values we have to use a lock-based scheme to enforce atomicity. This has to be // applied to all Unsafe operations that set the value of a jlong field. Even so -// the compareAndSwapLong operation will not be atomic with respect to direct stores +// the compareAndSetLong operation will not be atomic with respect to direct stores // to the field from Java code. It is important therefore that any Java code that // utilizes these Unsafe jlong operations does not perform direct stores. To permit // direct loads of the field from Java code we must also use Atomic::store within the @@ -1013,7 +1013,7 @@ UNSAFE_ENTRY(jlong, Unsafe_CompareAndExchangeLong(JNIEnv *env, jobject unsafe, j #endif } UNSAFE_END -UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) { +UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) { oop x = JNIHandles::resolve(x_h); oop e = JNIHandles::resolve(e_h); oop p = JNIHandles::resolve(obj); @@ -1028,14 +1028,14 @@ UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, return true; } UNSAFE_END -UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) { +UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) { oop p = JNIHandles::resolve(obj); jint* addr = (jint *)index_oop_from_field_offset_long(p, offset); return (jint)(Atomic::cmpxchg(x, addr, e)) == e; } UNSAFE_END -UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) { +UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) { Handle p(THREAD, JNIHandles::resolve(obj)); jlong* addr = (jlong*)index_oop_from_field_offset_long(p(), offset); @@ -1194,12 +1194,12 @@ static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = { {CC "defineClass0", CC "(" DC_Args ")" CLS, FN_PTR(Unsafe_DefineClass0)}, {CC "allocateInstance", CC "(" CLS ")" OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC "throwException", CC "(" THR ")V", FN_PTR(Unsafe_ThrowException)}, - {CC "compareAndSwapObject", CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSwapObject)}, - {CC "compareAndSwapInt", CC "(" OBJ "J""I""I"")Z", FN_PTR(Unsafe_CompareAndSwapInt)}, - {CC "compareAndSwapLong", CC "(" OBJ "J""J""J"")Z", FN_PTR(Unsafe_CompareAndSwapLong)}, - {CC "compareAndExchangeObjectVolatile", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeObject)}, - {CC "compareAndExchangeIntVolatile", CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)}, - {CC "compareAndExchangeLongVolatile", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)}, + {CC "compareAndSetObject",CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSetObject)}, + {CC "compareAndSetInt", CC "(" OBJ "J""I""I"")Z", FN_PTR(Unsafe_CompareAndSetInt)}, + {CC "compareAndSetLong", CC "(" OBJ "J""J""J"")Z", FN_PTR(Unsafe_CompareAndSetLong)}, + {CC "compareAndExchangeObject", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeObject)}, + {CC "compareAndExchangeInt", CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)}, + {CC "compareAndExchangeLong", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)}, {CC "park", CC "(ZJ)V", FN_PTR(Unsafe_Park)}, {CC "unpark", CC "(" OBJ ")V", FN_PTR(Unsafe_Unpark)}, diff --git a/hotspot/src/share/vm/shark/sharkIntrinsics.cpp b/hotspot/src/share/vm/shark/sharkIntrinsics.cpp index 51b813f4b8d..15b6679bf4e 100644 --- a/hotspot/src/share/vm/shark/sharkIntrinsics.cpp +++ b/hotspot/src/share/vm/shark/sharkIntrinsics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -66,7 +66,7 @@ bool SharkIntrinsics::is_intrinsic(ciMethod *target) { return true; // Unsafe - case vmIntrinsics::_compareAndSwapInt: + case vmIntrinsics::_compareAndSetInt: return true; default: @@ -140,8 +140,8 @@ void SharkIntrinsics::do_intrinsic() { break; // Unsafe - case vmIntrinsics::_compareAndSwapInt: - do_Unsafe_compareAndSwapInt(); + case vmIntrinsics::_compareAndSetInt: + do_Unsafe_compareAndSetInt(); break; default: @@ -241,7 +241,7 @@ void SharkIntrinsics::do_Thread_currentThread() { true)); } -void SharkIntrinsics::do_Unsafe_compareAndSwapInt() { +void SharkIntrinsics::do_Unsafe_compareAndSetInt() { // Pop the arguments Value *x = state()->pop()->jint_value(); Value *e = state()->pop()->jint_value(); diff --git a/hotspot/src/share/vm/shark/sharkIntrinsics.hpp b/hotspot/src/share/vm/shark/sharkIntrinsics.hpp index f0699f8948e..8a5d60f17b9 100644 --- a/hotspot/src/share/vm/shark/sharkIntrinsics.hpp +++ b/hotspot/src/share/vm/shark/sharkIntrinsics.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -58,7 +58,7 @@ class SharkIntrinsics : public SharkTargetInvariants { void do_Object_getClass(); void do_System_currentTimeMillis(); void do_Thread_currentThread(); - void do_Unsafe_compareAndSwapInt(); + void do_Unsafe_compareAndSetInt(); }; #endif // SHARE_VM_SHARK_SHARKINTRINSICS_HPP diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java index f7838dd6c97..e0c43b05529 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java @@ -773,221 +773,221 @@ public class TestIntUnsafeCAS { static void test_ci(int[] a) { for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123); + unsafe.compareAndSetInt(a, byte_offset(i), -1, -123); } } static void test_vi(int[] a, int b, int old) { for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), old, b); + unsafe.compareAndSetInt(a, byte_offset(i), old, b); } } static void test_cp(int[] a, int[] b) { for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]); + unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]); } } static void test_2ci(int[] a, int[] b) { for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123); - unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); + unsafe.compareAndSetInt(a, byte_offset(i), 123, -123); + unsafe.compareAndSetInt(b, byte_offset(i), 123, -103); } } static void test_2vi(int[] a, int[] b, int c, int d) { for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); - unsafe.compareAndSwapInt(b, byte_offset(i), -103, d); + unsafe.compareAndSetInt(a, byte_offset(i), -123, c); + unsafe.compareAndSetInt(b, byte_offset(i), -103, d); } } static void test_ci_neg(int[] a, int old) { for (int i = ARRLEN-1; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), old, -123); + unsafe.compareAndSetInt(a, byte_offset(i), old, -123); } } static void test_vi_neg(int[] a, int b, int old) { for (int i = ARRLEN-1; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), old, b); + unsafe.compareAndSetInt(a, byte_offset(i), old, b); } } static void test_cp_neg(int[] a, int[] b) { for (int i = ARRLEN-1; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]); + unsafe.compareAndSetInt(a, byte_offset(i), -123, b[i]); } } static void test_2ci_neg(int[] a, int[] b) { for (int i = ARRLEN-1; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123); - unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); + unsafe.compareAndSetInt(a, byte_offset(i), 123, -123); + unsafe.compareAndSetInt(b, byte_offset(i), 123, -103); } } static void test_2vi_neg(int[] a, int[] b, int c, int d) { for (int i = ARRLEN-1; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); - unsafe.compareAndSwapInt(b, byte_offset(i), -103, d); + unsafe.compareAndSetInt(a, byte_offset(i), -123, c); + unsafe.compareAndSetInt(b, byte_offset(i), -103, d); } } static void test_ci_oppos(int[] a, int old) { int limit = ARRLEN-1; for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123); + unsafe.compareAndSetInt(a, byte_offset(limit-i), old, -123); } } static void test_vi_oppos(int[] a, int b, int old) { int limit = ARRLEN-1; for (int i = limit; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b); + unsafe.compareAndSetInt(a, byte_offset(limit-i), old, b); } } static void test_cp_oppos(int[] a, int[] b) { int limit = ARRLEN-1; for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]); + unsafe.compareAndSetInt(a, byte_offset(i), -123, b[limit-i]); } } static void test_2ci_oppos(int[] a, int[] b) { int limit = ARRLEN-1; for (int i = 0; i < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123); - unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); + unsafe.compareAndSetInt(a, byte_offset(limit-i), 123, -123); + unsafe.compareAndSetInt(b, byte_offset(i), 123, -103); } } static void test_2vi_oppos(int[] a, int[] b, int c, int d) { int limit = ARRLEN-1; for (int i = limit; i >= 0; i-=1) { - unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); - unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d); + unsafe.compareAndSetInt(a, byte_offset(i), -123, c); + unsafe.compareAndSetInt(b, byte_offset(limit-i), -103, d); } } static void test_ci_off(int[] a, int old) { for (int i = 0; i < ARRLEN-OFFSET; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123); + unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, -123); } } static void test_vi_off(int[] a, int b, int old) { for (int i = 0; i < ARRLEN-OFFSET; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b); + unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), old, b); } } static void test_cp_off(int[] a, int[] b) { for (int i = 0; i < ARRLEN-OFFSET; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]); + unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]); } } static void test_2ci_off(int[] a, int[] b) { for (int i = 0; i < ARRLEN-OFFSET; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123); - unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103); + unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), 123, -123); + unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), 123, -103); } } static void test_2vi_off(int[] a, int[] b, int c, int d) { for (int i = 0; i < ARRLEN-OFFSET; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c); - unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d); + unsafe.compareAndSetInt(a, byte_offset(i+OFFSET), -123, c); + unsafe.compareAndSetInt(b, byte_offset(i+OFFSET), -103, d); } } static void test_ci_inv(int[] a, int k, int old) { for (int i = 0; i < ARRLEN-k; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123); + unsafe.compareAndSetInt(a, byte_offset(i+k), old, -123); } } static void test_vi_inv(int[] a, int b, int k, int old) { for (int i = 0; i < ARRLEN-k; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b); + unsafe.compareAndSetInt(a, byte_offset(i+k), old, b); } } static void test_cp_inv(int[] a, int[] b, int k) { for (int i = 0; i < ARRLEN-k; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]); + unsafe.compareAndSetInt(a, byte_offset(i+k), -123, b[i+k]); } } static void test_2ci_inv(int[] a, int[] b, int k) { for (int i = 0; i < ARRLEN-k; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123); - unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103); + unsafe.compareAndSetInt(a, byte_offset(i+k), 123, -123); + unsafe.compareAndSetInt(b, byte_offset(i+k), 123, -103); } } static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) { for (int i = 0; i < ARRLEN-k; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c); - unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d); + unsafe.compareAndSetInt(a, byte_offset(i+k), -123, c); + unsafe.compareAndSetInt(b, byte_offset(i+k), -103, d); } } static void test_ci_scl(int[] a, int old) { for (int i = 0; i*SCALE < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123); + unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, -123); } } static void test_vi_scl(int[] a, int b, int old) { for (int i = 0; i*SCALE < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b); + unsafe.compareAndSetInt(a, byte_offset(i*SCALE), old, b); } } static void test_cp_scl(int[] a, int[] b) { for (int i = 0; i*SCALE < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]); + unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]); } } static void test_2ci_scl(int[] a, int[] b) { for (int i = 0; i*SCALE < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123); - unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103); + unsafe.compareAndSetInt(a, byte_offset(i*SCALE), 123, -123); + unsafe.compareAndSetInt(b, byte_offset(i*SCALE), 123, -103); } } static void test_2vi_scl(int[] a, int[] b, int c, int d) { for (int i = 0; i*SCALE < ARRLEN; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c); - unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d); + unsafe.compareAndSetInt(a, byte_offset(i*SCALE), -123, c); + unsafe.compareAndSetInt(b, byte_offset(i*SCALE), -103, d); } } static void test_cp_alndst(int[] a, int[] b) { for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]); + unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]); } } static void test_cp_alnsrc(int[] a, int[] b) { for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { int old = unsafe.getIntVolatile(a, byte_offset(i)); - unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]); + unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+ALIGN_OFF]); } } static void test_2ci_aln(int[] a, int[] b) { for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123); + unsafe.compareAndSetInt(a, byte_offset(i+ALIGN_OFF), -1, -123); int old = unsafe.getIntVolatile(b, byte_offset(i)); - unsafe.compareAndSwapInt(b, byte_offset(i), old, -103); + unsafe.compareAndSetInt(b, byte_offset(i), old, -103); } } static void test_2vi_aln(int[] a, int[] b, int c, int d) { for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { int old = unsafe.getIntVolatile(a, byte_offset(i)); - unsafe.compareAndSwapInt(a, byte_offset(i), old, c); + unsafe.compareAndSetInt(a, byte_offset(i), old, c); old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF)); - unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d); + unsafe.compareAndSetInt(b, byte_offset(i+ALIGN_OFF), old, d); } } static void test_cp_unalndst(int[] a, int[] b) { for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]); + unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]); } } static void test_cp_unalnsrc(int[] a, int[] b) { for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { int old = unsafe.getIntVolatile(a, byte_offset(i)); - unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]); + unsafe.compareAndSetInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]); } } static void test_2ci_unaln(int[] a, int[] b) { for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { - unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123); + unsafe.compareAndSetInt(a, byte_offset(i+UNALIGN_OFF), -1, -123); int old = unsafe.getIntVolatile(b, byte_offset(i)); - unsafe.compareAndSwapInt(b, byte_offset(i), old, -103); + unsafe.compareAndSetInt(b, byte_offset(i), old, -103); } } static void test_2vi_unaln(int[] a, int[] b, int c, int d) { for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { int old = unsafe.getIntVolatile(a, byte_offset(i)); - unsafe.compareAndSwapInt(a, byte_offset(i), old, c); + unsafe.compareAndSetInt(a, byte_offset(i), old, c); old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF)); - unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d); + unsafe.compareAndSetInt(b, byte_offset(i+UNALIGN_OFF), old, d); } } diff --git a/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java b/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java index 5bec829dddd..353c73e43ba 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java +++ b/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -53,7 +54,7 @@ public class TestCAEAntiDep { } static int m(TestCAEAntiDep test, Object expected, Object x) { - C old = (C)UNSAFE.compareAndExchangeObjectVolatile(test, O_OFFSET, expected, x); + C old = (C)UNSAFE.compareAndExchangeObject(test, O_OFFSET, expected, x); int res = old.f1; old.f1 = 0x42; return res; diff --git a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java index 8f65f1d5e04..772b44b60e4 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java +++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,9 +72,8 @@ public class UnsafeTwoCASLong { } static void testAccess(Object base, long offset) { - UNSAFE.compareAndSwapLong(base, offset, 1L, 2L); - UNSAFE.compareAndSwapLong(base, offset, 2L, 1L); + UNSAFE.compareAndSetLong(base, offset, 1L, 2L); + UNSAFE.compareAndSetLong(base, offset, 2L, 1L); } } - diff --git a/hotspot/test/compiler/profiling/UnsafeAccess.java b/hotspot/test/compiler/profiling/UnsafeAccess.java index 5118101454b..eeda6d47241 100644 --- a/hotspot/test/compiler/profiling/UnsafeAccess.java +++ b/hotspot/test/compiler/profiling/UnsafeAccess.java @@ -64,7 +64,7 @@ public class UnsafeAccess { static Object helperUnsafeLoadStore(Object o, boolean isObjArray) { if (isObjArray) { Object o1 = U.getObject(o, off); - U.compareAndSwapObject(o, off, o1, new Object()); + U.compareAndSetObject(o, off, o1, new Object()); } return o; } diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java index 50e505bd840..75c33c9984c 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,32 +151,32 @@ public class JdkInternalMiscUnsafeAccessTestBoolean { // Compare { - boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false); - assertEquals(r, true, "success compareAndSwap boolean"); + boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false); + assertEquals(r, true, "success compareAndSet boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, false, "success compareAndSwap boolean value"); + assertEquals(x, false, "success compareAndSet boolean value"); } { - boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false); - assertEquals(r, false, "failing compareAndSwap boolean"); + boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false); + assertEquals(r, false, "failing compareAndSet boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, false, "failing compareAndSwap boolean value"); + assertEquals(x, false, "failing compareAndSet boolean value"); } // Advanced compare { - boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, true); - assertEquals(r, false, "success compareAndExchangeVolatile boolean"); + boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, true); + assertEquals(r, false, "success compareAndExchange boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, true, "success compareAndExchangeVolatile boolean value"); + assertEquals(x, true, "success compareAndExchange boolean value"); } { - boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, false); - assertEquals(r, true, "failing compareAndExchangeVolatile boolean"); + boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, false); + assertEquals(r, true, "failing compareAndExchange boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, true, "failing compareAndExchangeVolatile boolean value"); + assertEquals(x, true, "failing compareAndExchange boolean value"); } { @@ -210,41 +210,41 @@ public class JdkInternalMiscUnsafeAccessTestBoolean { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapBoolean(base, offset, true, false); + success = UNSAFE.weakCompareAndSetBooleanPlain(base, offset, true, false); } - assertEquals(success, true, "weakCompareAndSwap boolean"); + assertEquals(success, true, "weakCompareAndSetPlain boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, false, "weakCompareAndSwap boolean value"); + assertEquals(x, false, "weakCompareAndSetPlain boolean value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapBooleanAcquire(base, offset, false, true); + success = UNSAFE.weakCompareAndSetBooleanAcquire(base, offset, false, true); } - assertEquals(success, true, "weakCompareAndSwapAcquire boolean"); + assertEquals(success, true, "weakCompareAndSetAcquire boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, true, "weakCompareAndSwapAcquire boolean"); + assertEquals(x, true, "weakCompareAndSetAcquire boolean"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapBooleanRelease(base, offset, true, false); + success = UNSAFE.weakCompareAndSetBooleanRelease(base, offset, true, false); } - assertEquals(success, true, "weakCompareAndSwapRelease boolean"); + assertEquals(success, true, "weakCompareAndSetRelease boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, false, "weakCompareAndSwapRelease boolean"); + assertEquals(x, false, "weakCompareAndSetRelease boolean"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapBooleanVolatile(base, offset, false, true); + success = UNSAFE.weakCompareAndSetBoolean(base, offset, false, true); } - assertEquals(success, true, "weakCompareAndSwapVolatile boolean"); + assertEquals(success, true, "weakCompareAndSet boolean"); boolean x = UNSAFE.getBoolean(base, offset); - assertEquals(x, true, "weakCompareAndSwapVolatile boolean"); + assertEquals(x, true, "weakCompareAndSet boolean"); } UNSAFE.putBoolean(base, offset, false); @@ -260,4 +260,3 @@ public class JdkInternalMiscUnsafeAccessTestBoolean { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java index e35e5904d93..30ffae395df 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,32 +180,32 @@ public class JdkInternalMiscUnsafeAccessTestByte { // Compare { - boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x23); - assertEquals(r, true, "success compareAndSwap byte"); + boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x23); + assertEquals(r, true, "success compareAndSet byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x23, "success compareAndSwap byte value"); + assertEquals(x, (byte)0x23, "success compareAndSet byte value"); } { - boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x45); - assertEquals(r, false, "failing compareAndSwap byte"); + boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x45); + assertEquals(r, false, "failing compareAndSet byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x23, "failing compareAndSwap byte value"); + assertEquals(x, (byte)0x23, "failing compareAndSet byte value"); } // Advanced compare { - byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x01); - assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte"); + byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x01); + assertEquals(r, (byte)0x23, "success compareAndExchange byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value"); + assertEquals(x, (byte)0x01, "success compareAndExchange byte value"); } { - byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x45); - assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte"); + byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x45); + assertEquals(r, (byte)0x01, "failing compareAndExchange byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value"); + assertEquals(x, (byte)0x01, "failing compareAndExchange byte value"); } { @@ -239,41 +239,41 @@ public class JdkInternalMiscUnsafeAccessTestByte { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapByte(base, offset, (byte)0x01, (byte)0x23); + success = UNSAFE.weakCompareAndSetBytePlain(base, offset, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSwap byte"); + assertEquals(success, true, "weakCompareAndSetPlain byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x23, "weakCompareAndSwap byte value"); + assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapByteAcquire(base, offset, (byte)0x23, (byte)0x01); + success = UNSAFE.weakCompareAndSetByteAcquire(base, offset, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSwapAcquire byte"); + assertEquals(success, true, "weakCompareAndSetAcquire byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x01, "weakCompareAndSwapAcquire byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapByteRelease(base, offset, (byte)0x01, (byte)0x23); + success = UNSAFE.weakCompareAndSetByteRelease(base, offset, (byte)0x01, (byte)0x23); } - assertEquals(success, true, "weakCompareAndSwapRelease byte"); + assertEquals(success, true, "weakCompareAndSetRelease byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x23, "weakCompareAndSwapRelease byte"); + assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapByteVolatile(base, offset, (byte)0x23, (byte)0x01); + success = UNSAFE.weakCompareAndSetByte(base, offset, (byte)0x23, (byte)0x01); } - assertEquals(success, true, "weakCompareAndSwapVolatile byte"); + assertEquals(success, true, "weakCompareAndSet byte"); byte x = UNSAFE.getByte(base, offset); - assertEquals(x, (byte)0x01, "weakCompareAndSwapVolatile byte"); + assertEquals(x, (byte)0x01, "weakCompareAndSet byte"); } UNSAFE.putByte(base, offset, (byte)0x23); @@ -306,4 +306,3 @@ public class JdkInternalMiscUnsafeAccessTestByte { } } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java index 0bb36c898bc..817af4b18c1 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,32 +198,32 @@ public class JdkInternalMiscUnsafeAccessTestChar { // Compare { - boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u4567'); - assertEquals(r, true, "success compareAndSwap char"); + boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u4567'); + assertEquals(r, true, "success compareAndSet char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u4567', "success compareAndSwap char value"); + assertEquals(x, '\u4567', "success compareAndSet char value"); } { - boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u89AB'); - assertEquals(r, false, "failing compareAndSwap char"); + boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u89AB'); + assertEquals(r, false, "failing compareAndSet char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u4567', "failing compareAndSwap char value"); + assertEquals(x, '\u4567', "failing compareAndSet char value"); } // Advanced compare { - char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u0123'); - assertEquals(r, '\u4567', "success compareAndExchangeVolatile char"); + char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u0123'); + assertEquals(r, '\u4567', "success compareAndExchange char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value"); + assertEquals(x, '\u0123', "success compareAndExchange char value"); } { - char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u89AB'); - assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char"); + char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u89AB'); + assertEquals(r, '\u0123', "failing compareAndExchange char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value"); + assertEquals(x, '\u0123', "failing compareAndExchange char value"); } { @@ -257,41 +257,41 @@ public class JdkInternalMiscUnsafeAccessTestChar { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapChar(base, offset, '\u0123', '\u4567'); + success = UNSAFE.weakCompareAndSetCharPlain(base, offset, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSwap char"); + assertEquals(success, true, "weakCompareAndSetPlain char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u4567', "weakCompareAndSwap char value"); + assertEquals(x, '\u4567', "weakCompareAndSetPlain char value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapCharAcquire(base, offset, '\u4567', '\u0123'); + success = UNSAFE.weakCompareAndSetCharAcquire(base, offset, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSwapAcquire char"); + assertEquals(success, true, "weakCompareAndSetAcquire char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u0123', "weakCompareAndSwapAcquire char"); + assertEquals(x, '\u0123', "weakCompareAndSetAcquire char"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapCharRelease(base, offset, '\u0123', '\u4567'); + success = UNSAFE.weakCompareAndSetCharRelease(base, offset, '\u0123', '\u4567'); } - assertEquals(success, true, "weakCompareAndSwapRelease char"); + assertEquals(success, true, "weakCompareAndSetRelease char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u4567', "weakCompareAndSwapRelease char"); + assertEquals(x, '\u4567', "weakCompareAndSetRelease char"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapCharVolatile(base, offset, '\u4567', '\u0123'); + success = UNSAFE.weakCompareAndSetChar(base, offset, '\u4567', '\u0123'); } - assertEquals(success, true, "weakCompareAndSwapVolatile char"); + assertEquals(success, true, "weakCompareAndSet char"); char x = UNSAFE.getChar(base, offset); - assertEquals(x, '\u0123', "weakCompareAndSwapVolatile char"); + assertEquals(x, '\u0123', "weakCompareAndSet char"); } UNSAFE.putChar(base, offset, '\u4567'); @@ -324,4 +324,3 @@ public class JdkInternalMiscUnsafeAccessTestChar { } } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java index 48a98c619fd..37c15e57a6a 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,32 +180,32 @@ public class JdkInternalMiscUnsafeAccessTestDouble { // Compare { - boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 2.0d); - assertEquals(r, true, "success compareAndSwap double"); + boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 2.0d); + assertEquals(r, true, "success compareAndSet double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 2.0d, "success compareAndSwap double value"); + assertEquals(x, 2.0d, "success compareAndSet double value"); } { - boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 3.0d); - assertEquals(r, false, "failing compareAndSwap double"); + boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 3.0d); + assertEquals(r, false, "failing compareAndSet double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 2.0d, "failing compareAndSwap double value"); + assertEquals(x, 2.0d, "failing compareAndSet double value"); } // Advanced compare { - double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 1.0d); - assertEquals(r, 2.0d, "success compareAndExchangeVolatile double"); + double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 1.0d); + assertEquals(r, 2.0d, "success compareAndExchange double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 1.0d, "success compareAndExchangeVolatile double value"); + assertEquals(x, 1.0d, "success compareAndExchange double value"); } { - double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 3.0d); - assertEquals(r, 1.0d, "failing compareAndExchangeVolatile double"); + double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 3.0d); + assertEquals(r, 1.0d, "failing compareAndExchange double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 1.0d, "failing compareAndExchangeVolatile double value"); + assertEquals(x, 1.0d, "failing compareAndExchange double value"); } { @@ -239,41 +239,41 @@ public class JdkInternalMiscUnsafeAccessTestDouble { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapDouble(base, offset, 1.0d, 2.0d); + success = UNSAFE.weakCompareAndSetDoublePlain(base, offset, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSwap double"); + assertEquals(success, true, "weakCompareAndSetPlain double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 2.0d, "weakCompareAndSwap double value"); + assertEquals(x, 2.0d, "weakCompareAndSetPlain double value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapDoubleAcquire(base, offset, 2.0d, 1.0d); + success = UNSAFE.weakCompareAndSetDoubleAcquire(base, offset, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSwapAcquire double"); + assertEquals(success, true, "weakCompareAndSetAcquire double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 1.0d, "weakCompareAndSwapAcquire double"); + assertEquals(x, 1.0d, "weakCompareAndSetAcquire double"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapDoubleRelease(base, offset, 1.0d, 2.0d); + success = UNSAFE.weakCompareAndSetDoubleRelease(base, offset, 1.0d, 2.0d); } - assertEquals(success, true, "weakCompareAndSwapRelease double"); + assertEquals(success, true, "weakCompareAndSetRelease double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 2.0d, "weakCompareAndSwapRelease double"); + assertEquals(x, 2.0d, "weakCompareAndSetRelease double"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapDoubleVolatile(base, offset, 2.0d, 1.0d); + success = UNSAFE.weakCompareAndSetDouble(base, offset, 2.0d, 1.0d); } - assertEquals(success, true, "weakCompareAndSwapVolatile double"); + assertEquals(success, true, "weakCompareAndSet double"); double x = UNSAFE.getDouble(base, offset); - assertEquals(x, 1.0d, "weakCompareAndSwapVolatile double"); + assertEquals(x, 1.0d, "weakCompareAndSet double"); } UNSAFE.putDouble(base, offset, 2.0d); @@ -306,4 +306,3 @@ public class JdkInternalMiscUnsafeAccessTestDouble { } } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java index 2a91a7c20c3..0ac9fa1e55a 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,32 +180,32 @@ public class JdkInternalMiscUnsafeAccessTestFloat { // Compare { - boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 2.0f); - assertEquals(r, true, "success compareAndSwap float"); + boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 2.0f); + assertEquals(r, true, "success compareAndSet float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 2.0f, "success compareAndSwap float value"); + assertEquals(x, 2.0f, "success compareAndSet float value"); } { - boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 3.0f); - assertEquals(r, false, "failing compareAndSwap float"); + boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 3.0f); + assertEquals(r, false, "failing compareAndSet float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 2.0f, "failing compareAndSwap float value"); + assertEquals(x, 2.0f, "failing compareAndSet float value"); } // Advanced compare { - float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 1.0f); - assertEquals(r, 2.0f, "success compareAndExchangeVolatile float"); + float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 1.0f); + assertEquals(r, 2.0f, "success compareAndExchange float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 1.0f, "success compareAndExchangeVolatile float value"); + assertEquals(x, 1.0f, "success compareAndExchange float value"); } { - float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 3.0f); - assertEquals(r, 1.0f, "failing compareAndExchangeVolatile float"); + float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 3.0f); + assertEquals(r, 1.0f, "failing compareAndExchange float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 1.0f, "failing compareAndExchangeVolatile float value"); + assertEquals(x, 1.0f, "failing compareAndExchange float value"); } { @@ -239,41 +239,41 @@ public class JdkInternalMiscUnsafeAccessTestFloat { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapFloat(base, offset, 1.0f, 2.0f); + success = UNSAFE.weakCompareAndSetFloatPlain(base, offset, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSwap float"); + assertEquals(success, true, "weakCompareAndSetPlain float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 2.0f, "weakCompareAndSwap float value"); + assertEquals(x, 2.0f, "weakCompareAndSetPlain float value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapFloatAcquire(base, offset, 2.0f, 1.0f); + success = UNSAFE.weakCompareAndSetFloatAcquire(base, offset, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSwapAcquire float"); + assertEquals(success, true, "weakCompareAndSetAcquire float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 1.0f, "weakCompareAndSwapAcquire float"); + assertEquals(x, 1.0f, "weakCompareAndSetAcquire float"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapFloatRelease(base, offset, 1.0f, 2.0f); + success = UNSAFE.weakCompareAndSetFloatRelease(base, offset, 1.0f, 2.0f); } - assertEquals(success, true, "weakCompareAndSwapRelease float"); + assertEquals(success, true, "weakCompareAndSetRelease float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 2.0f, "weakCompareAndSwapRelease float"); + assertEquals(x, 2.0f, "weakCompareAndSetRelease float"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapFloatVolatile(base, offset, 2.0f, 1.0f); + success = UNSAFE.weakCompareAndSetFloat(base, offset, 2.0f, 1.0f); } - assertEquals(success, true, "weakCompareAndSwapVolatile float"); + assertEquals(success, true, "weakCompareAndSet float"); float x = UNSAFE.getFloat(base, offset); - assertEquals(x, 1.0f, "weakCompareAndSwapVolatile float"); + assertEquals(x, 1.0f, "weakCompareAndSet float"); } UNSAFE.putFloat(base, offset, 2.0f); @@ -306,4 +306,3 @@ public class JdkInternalMiscUnsafeAccessTestFloat { } } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java index b55e3672427..0f0f1f101d3 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,32 +198,32 @@ public class JdkInternalMiscUnsafeAccessTestInt { // Compare { - boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF); - assertEquals(r, true, "success compareAndSwap int"); + boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0x89ABCDEF); + assertEquals(r, true, "success compareAndSet int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x89ABCDEF, "success compareAndSwap int value"); + assertEquals(x, 0x89ABCDEF, "success compareAndSet int value"); } { - boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0xCAFEBABE); - assertEquals(r, false, "failing compareAndSwap int"); + boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0xCAFEBABE); + assertEquals(r, false, "failing compareAndSet int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x89ABCDEF, "failing compareAndSwap int value"); + assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value"); } // Advanced compare { - int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0x01234567); - assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int"); + int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0x01234567); + assertEquals(r, 0x89ABCDEF, "success compareAndExchange int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value"); + assertEquals(x, 0x01234567, "success compareAndExchange int value"); } { - int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0xCAFEBABE); - assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int"); + int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0xCAFEBABE); + assertEquals(r, 0x01234567, "failing compareAndExchange int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value"); + assertEquals(x, 0x01234567, "failing compareAndExchange int value"); } { @@ -257,41 +257,41 @@ public class JdkInternalMiscUnsafeAccessTestInt { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF); + success = UNSAFE.weakCompareAndSetIntPlain(base, offset, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSwap int"); + assertEquals(success, true, "weakCompareAndSetPlain int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSwap int value"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 0x89ABCDEF, 0x01234567); + success = UNSAFE.weakCompareAndSetIntAcquire(base, offset, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSwapAcquire int"); + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x01234567, "weakCompareAndSwapAcquire int"); + assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 0x01234567, 0x89ABCDEF); + success = UNSAFE.weakCompareAndSetIntRelease(base, offset, 0x01234567, 0x89ABCDEF); } - assertEquals(success, true, "weakCompareAndSwapRelease int"); + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x89ABCDEF, "weakCompareAndSwapRelease int"); + assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 0x89ABCDEF, 0x01234567); + success = UNSAFE.weakCompareAndSetInt(base, offset, 0x89ABCDEF, 0x01234567); } - assertEquals(success, true, "weakCompareAndSwapVolatile int"); + assertEquals(success, true, "weakCompareAndSet int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 0x01234567, "weakCompareAndSwapVolatile int"); + assertEquals(x, 0x01234567, "weakCompareAndSet int"); } UNSAFE.putInt(base, offset, 0x89ABCDEF); @@ -324,4 +324,3 @@ public class JdkInternalMiscUnsafeAccessTestInt { } } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java index fc78b375071..69a51bb698b 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,32 +198,32 @@ public class JdkInternalMiscUnsafeAccessTestLong { // Compare { - boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); - assertEquals(r, true, "success compareAndSwap long"); + boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + assertEquals(r, true, "success compareAndSet long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSwap long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value"); } { - boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL); - assertEquals(r, false, "failing compareAndSwap long"); + boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL); + assertEquals(r, false, "failing compareAndSet long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSwap long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value"); } // Advanced compare { - long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); - assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long"); + long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchange long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value"); + assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchange long value"); } { - long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL); - assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long"); + long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL); + assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchange long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value"); + assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchange long value"); } { @@ -257,41 +257,41 @@ public class JdkInternalMiscUnsafeAccessTestLong { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = UNSAFE.weakCompareAndSetLongPlain(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSwap long"); + assertEquals(success, true, "weakCompareAndSetPlain long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwap long value"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = UNSAFE.weakCompareAndSetLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSwapAcquire long"); + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapAcquire long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); + success = UNSAFE.weakCompareAndSetLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL); } - assertEquals(success, true, "weakCompareAndSwapRelease long"); + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwapRelease long"); + assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); + success = UNSAFE.weakCompareAndSetLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL); } - assertEquals(success, true, "weakCompareAndSwapVolatile long"); + assertEquals(success, true, "weakCompareAndSet long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapVolatile long"); + assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long"); } UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL); @@ -324,4 +324,3 @@ public class JdkInternalMiscUnsafeAccessTestLong { } } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java index 039b472ccf7..b2e5fc57e1e 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,32 +151,32 @@ public class JdkInternalMiscUnsafeAccessTestObject { // Compare { - boolean r = UNSAFE.compareAndSwapObject(base, offset, "foo", "bar"); - assertEquals(r, true, "success compareAndSwap Object"); + boolean r = UNSAFE.compareAndSetObject(base, offset, "foo", "bar"); + assertEquals(r, true, "success compareAndSet Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "bar", "success compareAndSwap Object value"); + assertEquals(x, "bar", "success compareAndSet Object value"); } { - boolean r = UNSAFE.compareAndSwapObject(base, offset, "foo", "baz"); - assertEquals(r, false, "failing compareAndSwap Object"); + boolean r = UNSAFE.compareAndSetObject(base, offset, "foo", "baz"); + assertEquals(r, false, "failing compareAndSet Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "bar", "failing compareAndSwap Object value"); + assertEquals(x, "bar", "failing compareAndSet Object value"); } // Advanced compare { - Object r = UNSAFE.compareAndExchangeObjectVolatile(base, offset, "bar", "foo"); - assertEquals(r, "bar", "success compareAndExchangeVolatile Object"); + Object r = UNSAFE.compareAndExchangeObject(base, offset, "bar", "foo"); + assertEquals(r, "bar", "success compareAndExchange Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "foo", "success compareAndExchangeVolatile Object value"); + assertEquals(x, "foo", "success compareAndExchange Object value"); } { - Object r = UNSAFE.compareAndExchangeObjectVolatile(base, offset, "bar", "baz"); - assertEquals(r, "foo", "failing compareAndExchangeVolatile Object"); + Object r = UNSAFE.compareAndExchangeObject(base, offset, "bar", "baz"); + assertEquals(r, "foo", "failing compareAndExchange Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "foo", "failing compareAndExchangeVolatile Object value"); + assertEquals(x, "foo", "failing compareAndExchange Object value"); } { @@ -210,41 +210,41 @@ public class JdkInternalMiscUnsafeAccessTestObject { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar"); + success = UNSAFE.weakCompareAndSetObjectPlain(base, offset, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSwap Object"); + assertEquals(success, true, "weakCompareAndSetPlain Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "bar", "weakCompareAndSwap Object value"); + assertEquals(x, "bar", "weakCompareAndSetPlain Object value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo"); + success = UNSAFE.weakCompareAndSetObjectAcquire(base, offset, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSwapAcquire Object"); + assertEquals(success, true, "weakCompareAndSetAcquire Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "foo", "weakCompareAndSwapAcquire Object"); + assertEquals(x, "foo", "weakCompareAndSetAcquire Object"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar"); + success = UNSAFE.weakCompareAndSetObjectRelease(base, offset, "foo", "bar"); } - assertEquals(success, true, "weakCompareAndSwapRelease Object"); + assertEquals(success, true, "weakCompareAndSetRelease Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "bar", "weakCompareAndSwapRelease Object"); + assertEquals(x, "bar", "weakCompareAndSetRelease Object"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapObjectVolatile(base, offset, "bar", "foo"); + success = UNSAFE.weakCompareAndSetObject(base, offset, "bar", "foo"); } - assertEquals(success, true, "weakCompareAndSwapVolatile Object"); + assertEquals(success, true, "weakCompareAndSet Object"); Object x = UNSAFE.getObject(base, offset); - assertEquals(x, "foo", "weakCompareAndSwapVolatile Object"); + assertEquals(x, "foo", "weakCompareAndSet Object"); } UNSAFE.putObject(base, offset, "bar"); @@ -260,4 +260,3 @@ public class JdkInternalMiscUnsafeAccessTestObject { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java index f854979c73f..a6b845eec6b 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,32 +198,32 @@ public class JdkInternalMiscUnsafeAccessTestShort { // Compare { - boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x4567); - assertEquals(r, true, "success compareAndSwap short"); + boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x4567); + assertEquals(r, true, "success compareAndSet short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x4567, "success compareAndSwap short value"); + assertEquals(x, (short)0x4567, "success compareAndSet short value"); } { - boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x89AB); - assertEquals(r, false, "failing compareAndSwap short"); + boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x89AB); + assertEquals(r, false, "failing compareAndSet short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x4567, "failing compareAndSwap short value"); + assertEquals(x, (short)0x4567, "failing compareAndSet short value"); } // Advanced compare { - short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x0123); - assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short"); + short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x0123); + assertEquals(r, (short)0x4567, "success compareAndExchange short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value"); + assertEquals(x, (short)0x0123, "success compareAndExchange short value"); } { - short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x89AB); - assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short"); + short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x89AB); + assertEquals(r, (short)0x0123, "failing compareAndExchange short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value"); + assertEquals(x, (short)0x0123, "failing compareAndExchange short value"); } { @@ -257,41 +257,41 @@ public class JdkInternalMiscUnsafeAccessTestShort { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapShort(base, offset, (short)0x0123, (short)0x4567); + success = UNSAFE.weakCompareAndSetShortPlain(base, offset, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSwap short"); + assertEquals(success, true, "weakCompareAndSetPlain short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x4567, "weakCompareAndSwap short value"); + assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapShortAcquire(base, offset, (short)0x4567, (short)0x0123); + success = UNSAFE.weakCompareAndSetShortAcquire(base, offset, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSwapAcquire short"); + assertEquals(success, true, "weakCompareAndSetAcquire short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x0123, "weakCompareAndSwapAcquire short"); + assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapShortRelease(base, offset, (short)0x0123, (short)0x4567); + success = UNSAFE.weakCompareAndSetShortRelease(base, offset, (short)0x0123, (short)0x4567); } - assertEquals(success, true, "weakCompareAndSwapRelease short"); + assertEquals(success, true, "weakCompareAndSetRelease short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x4567, "weakCompareAndSwapRelease short"); + assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwapShortVolatile(base, offset, (short)0x4567, (short)0x0123); + success = UNSAFE.weakCompareAndSetShort(base, offset, (short)0x4567, (short)0x0123); } - assertEquals(success, true, "weakCompareAndSwapVolatile short"); + assertEquals(success, true, "weakCompareAndSet short"); short x = UNSAFE.getShort(base, offset); - assertEquals(x, (short)0x0123, "weakCompareAndSwapVolatile short"); + assertEquals(x, (short)0x0123, "weakCompareAndSet short"); } UNSAFE.putShort(base, offset, (short)0x4567); @@ -324,4 +324,3 @@ public class JdkInternalMiscUnsafeAccessTestShort { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java index 7200bf754c8..a1b68c7305d 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -138,4 +138,3 @@ public class SunMiscUnsafeAccessTestBoolean { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java index a30c01ff0f6..c086315cb8a 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -175,4 +175,3 @@ public class SunMiscUnsafeAccessTestByte { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java index 12dbb25030b..3a55939826d 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -175,4 +175,3 @@ public class SunMiscUnsafeAccessTestChar { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java index 5fedde71510..52bde3f08d6 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -175,4 +175,3 @@ public class SunMiscUnsafeAccessTestDouble { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java index 621e4ae3863..478efa4dbc3 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -175,4 +175,3 @@ public class SunMiscUnsafeAccessTestFloat { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java index 1e49aacb287..0bf8b641066 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -216,4 +216,3 @@ public class SunMiscUnsafeAccessTestInt { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java index e484bcec291..64014df3340 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -216,4 +216,3 @@ public class SunMiscUnsafeAccessTestLong { } } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java index 1241f0fbcd4..0145124c7bd 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -170,4 +170,3 @@ public class SunMiscUnsafeAccessTestObject { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java index d1d7b632389..9a815670595 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -175,4 +175,3 @@ public class SunMiscUnsafeAccessTestShort { } } } - diff --git a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template index 55ed81fc059..f28791765a1 100644 --- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template +++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,11 @@ * @bug 8143628 * @summary Test unsafe access for $type$ * +#if[JdkInternalMisc] + * @modules $module$/$package$:+open +#else[JdkInternalMisc] * @modules $module$/$package$ +#end[JdkInternalMisc] * @run testng/othervm -Diters=100 -Xint compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$ @@ -219,33 +223,51 @@ public class $Qualifier$UnsafeAccessTest$Type$ { // Compare { +#if[JdkInternalMisc] + boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value2$); + assertEquals(r, true, "success compareAndSet $type$"); +#else[JdkInternalMisc] boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value2$); assertEquals(r, true, "success compareAndSwap $type$"); +#end[JdkInternalMisc] $type$ x = UNSAFE.get$Type$(base, offset); +#if[JdkInternalMisc] + assertEquals(x, $value2$, "success compareAndSet $type$ value"); +#else[JdkInternalMisc] assertEquals(x, $value2$, "success compareAndSwap $type$ value"); +#end[JdkInternalMisc] } { +#if[JdkInternalMisc] + boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value3$); + assertEquals(r, false, "failing compareAndSet $type$"); +#else[JdkInternalMisc] boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value3$); assertEquals(r, false, "failing compareAndSwap $type$"); +#end[JdkInternalMisc] $type$ x = UNSAFE.get$Type$(base, offset); +#if[JdkInternalMisc] + assertEquals(x, $value2$, "failing compareAndSet $type$ value"); +#else[JdkInternalMisc] assertEquals(x, $value2$, "failing compareAndSwap $type$ value"); +#end[JdkInternalMisc] } #if[JdkInternalMisc] // Advanced compare { - $type$ r = UNSAFE.compareAndExchange$Type$Volatile(base, offset, $value2$, $value1$); - assertEquals(r, $value2$, "success compareAndExchangeVolatile $type$"); + $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value1$); + assertEquals(r, $value2$, "success compareAndExchange $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value1$, "success compareAndExchangeVolatile $type$ value"); + assertEquals(x, $value1$, "success compareAndExchange $type$ value"); } { - $type$ r = UNSAFE.compareAndExchange$Type$Volatile(base, offset, $value2$, $value3$); - assertEquals(r, $value1$, "failing compareAndExchangeVolatile $type$"); + $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value3$); + assertEquals(r, $value1$, "failing compareAndExchange $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value1$, "failing compareAndExchangeVolatile $type$ value"); + assertEquals(x, $value1$, "failing compareAndExchange $type$ value"); } { @@ -279,41 +301,41 @@ public class $Qualifier$UnsafeAccessTest$Type$ { { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$); + success = UNSAFE.weakCompareAndSet$Type$Plain(base, offset, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSwap $type$"); + assertEquals(success, true, "weakCompareAndSetPlain $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value2$, "weakCompareAndSwap $type$ value"); + assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$); + success = UNSAFE.weakCompareAndSet$Type$Acquire(base, offset, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSwapAcquire $type$"); + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value1$, "weakCompareAndSwapAcquire $type$"); + assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$); + success = UNSAFE.weakCompareAndSet$Type$Release(base, offset, $value1$, $value2$); } - assertEquals(success, true, "weakCompareAndSwapRelease $type$"); + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$"); + assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } { boolean success = false; for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { - success = UNSAFE.weakCompareAndSwap$Type$Volatile(base, offset, $value2$, $value1$); + success = UNSAFE.weakCompareAndSet$Type$(base, offset, $value2$, $value1$); } - assertEquals(success, true, "weakCompareAndSwapVolatile $type$"); + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value1$, "weakCompareAndSwapVolatile $type$"); + assertEquals(x, $value1$, "weakCompareAndSet $type$"); } #end[JdkInternalMisc] @@ -354,4 +376,3 @@ public class $Qualifier$UnsafeAccessTest$Type$ { #end[!boolean] #end[!Object] } - From ac0bf2d4015a98426cb99d33af484b6e6d937fc1 Mon Sep 17 00:00:00 2001 From: Ron Pressler Date: Mon, 5 Jun 2017 16:05:24 -0700 Subject: [PATCH 04/59] 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9 Reviewed-by: psandoz, dholmes, mchung --- .../share/classes/java/lang/Class.java | 6 +- .../share/classes/java/lang/ClassLoader.java | 2 +- .../lang/invoke/X-VarHandle.java.template | 42 +- .../X-VarHandleByteArrayView.java.template | 46 +- .../util/concurrent/ConcurrentHashMap.java | 40 +- .../util/concurrent/atomic/AtomicInteger.java | 14 +- .../atomic/AtomicIntegerFieldUpdater.java | 4 +- .../util/concurrent/atomic/AtomicLong.java | 18 +- .../atomic/AtomicLongFieldUpdater.java | 4 +- .../atomic/AtomicReferenceFieldUpdater.java | 4 +- .../classes/jdk/internal/misc/Unsafe.java | 608 +++++++++--------- .../share/classes/sun/misc/Unsafe.java | 8 +- 12 files changed, 398 insertions(+), 398 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index 4251a6963b4..e6962ac45ec 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -2880,19 +2880,19 @@ public final class Class implements java.io.Serializable, static boolean casReflectionData(Class clazz, SoftReference> oldData, SoftReference> newData) { - return unsafe.compareAndSwapObject(clazz, reflectionDataOffset, oldData, newData); + return unsafe.compareAndSetObject(clazz, reflectionDataOffset, oldData, newData); } static boolean casAnnotationType(Class clazz, AnnotationType oldType, AnnotationType newType) { - return unsafe.compareAndSwapObject(clazz, annotationTypeOffset, oldType, newType); + return unsafe.compareAndSetObject(clazz, annotationTypeOffset, oldType, newType); } static boolean casAnnotationData(Class clazz, AnnotationData oldData, AnnotationData newData) { - return unsafe.compareAndSwapObject(clazz, annotationDataOffset, oldData, newData); + return unsafe.compareAndSetObject(clazz, annotationDataOffset, oldData, newData); } } diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index fb9660f6072..9aee833e141 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -2884,7 +2884,7 @@ public abstract class ClassLoader { } catch (NoSuchFieldException e) { throw new InternalError(e); } - return unsafe.compareAndSwapObject(this, offset, null, obj); + return unsafe.compareAndSetObject(this, offset, null, obj); } } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index 634d64d8327..71419c36548 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,7 +125,7 @@ final class VarHandle$Type$s { @ForceInline static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -133,7 +133,7 @@ final class VarHandle$Type$s { @ForceInline static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - return UNSAFE.compareAndExchange$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -157,7 +157,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -165,7 +165,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -173,7 +173,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -181,7 +181,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -275,7 +275,7 @@ final class VarHandle$Type$s { handle.fieldOffset, value); } - + @ForceInline static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) { return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), @@ -392,7 +392,7 @@ final class VarHandle$Type$s { @ForceInline static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - return UNSAFE.compareAndSwap$Type$(handle.base, + return UNSAFE.compareAndSet$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -401,7 +401,7 @@ final class VarHandle$Type$s { @ForceInline static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - return UNSAFE.compareAndExchange$Type$Volatile(handle.base, + return UNSAFE.compareAndExchange$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -425,7 +425,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$(handle.base, + return UNSAFE.weakCompareAndSet$Type$Plain(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -433,7 +433,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base, + return UNSAFE.weakCompareAndSet$Type$(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -441,7 +441,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base, + return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -449,7 +449,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - return UNSAFE.weakCompareAndSwap$Type$Release(handle.base, + return UNSAFE.weakCompareAndSet$Type$Release(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -689,7 +689,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - return UNSAFE.compareAndSwap$Type$(array, + return UNSAFE.compareAndSet$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); @@ -702,7 +702,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - return UNSAFE.compareAndExchange$Type$Volatile(array, + return UNSAFE.compareAndExchange$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); @@ -741,7 +741,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - return UNSAFE.weakCompareAndSwap$Type$(array, + return UNSAFE.weakCompareAndSet$Type$Plain(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); @@ -754,7 +754,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - return UNSAFE.weakCompareAndSwap$Type$Volatile(array, + return UNSAFE.weakCompareAndSet$Type$(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); @@ -767,7 +767,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - return UNSAFE.weakCompareAndSwap$Type$Acquire(array, + return UNSAFE.weakCompareAndSet$Type$Acquire(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); @@ -780,7 +780,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - return UNSAFE.weakCompareAndSwap$Type$Release(array, + return UNSAFE.weakCompareAndSet$Type$Release(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); @@ -897,7 +897,7 @@ final class VarHandle$Type$s { (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } - + @ForceInline static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) { $type$[] array = ($type$[]) oarray; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index da57311e39d..e85fd913406 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -186,7 +186,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; - return UNSAFE.compareAndSwap$RawType$( + return UNSAFE.compareAndSet$RawType$( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -196,7 +196,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; return convEndian(handle.be, - UNSAFE.compareAndExchange$RawType$Volatile( + UNSAFE.compareAndExchange$RawType$( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value))); @@ -225,7 +225,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; - return UNSAFE.weakCompareAndSwap$RawType$( + return UNSAFE.weakCompareAndSet$RawType$Plain( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -234,7 +234,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; - return UNSAFE.weakCompareAndSwap$RawType$Volatile( + return UNSAFE.weakCompareAndSet$RawType$( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -243,7 +243,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; - return UNSAFE.weakCompareAndSwap$RawType$Acquire( + return UNSAFE.weakCompareAndSet$RawType$Acquire( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -252,7 +252,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; - return UNSAFE.weakCompareAndSwap$RawType$Release( + return UNSAFE.weakCompareAndSet$RawType$Release( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -336,7 +336,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } @@ -389,7 +389,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); return expectedValue; } @@ -440,7 +440,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); return expectedValue; } @@ -491,7 +491,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); return expectedValue; } @@ -625,7 +625,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; - return UNSAFE.compareAndSwap$RawType$( + return UNSAFE.compareAndSet$RawType$( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -635,7 +635,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; return convEndian(handle.be, - UNSAFE.compareAndExchange$RawType$Volatile( + UNSAFE.compareAndExchange$RawType$( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value))); @@ -664,7 +664,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; - return UNSAFE.weakCompareAndSwap$RawType$( + return UNSAFE.weakCompareAndSet$RawType$Plain( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -673,7 +673,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; - return UNSAFE.weakCompareAndSwap$RawType$Volatile( + return UNSAFE.weakCompareAndSet$RawType$( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -682,7 +682,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; - return UNSAFE.weakCompareAndSwap$RawType$Acquire( + return UNSAFE.weakCompareAndSet$RawType$Acquire( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -691,7 +691,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; - return UNSAFE.weakCompareAndSwap$RawType$Release( + return UNSAFE.weakCompareAndSet$RawType$Release( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -776,7 +776,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); return expectedValue; } @@ -830,7 +830,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value))); return expectedValue; } @@ -882,12 +882,12 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value))); return expectedValue; } - - + + @ForceInline static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; @@ -935,7 +935,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { do { nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); - } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset, nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value))); return expectedValue; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index 77c42efd6fd..aec44a2d4c7 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -768,7 +768,7 @@ public class ConcurrentHashMap extends AbstractMap static final boolean casTabAt(Node[] tab, int i, Node c, Node v) { - return U.compareAndSwapObject(tab, ((long)i << ASHIFT) + ABASE, c, v); + return U.compareAndSetObject(tab, ((long)i << ASHIFT) + ABASE, c, v); } static final void setTabAt(Node[] tab, int i, Node v) { @@ -2299,7 +2299,7 @@ public class ConcurrentHashMap extends AbstractMap while ((tab = table) == null || tab.length == 0) { if ((sc = sizeCtl) < 0) Thread.yield(); // lost initialization race; just spin - else if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) { + else if (U.compareAndSetInt(this, SIZECTL, sc, -1)) { try { if ((tab = table) == null || tab.length == 0) { int n = (sc > 0) ? sc : DEFAULT_CAPACITY; @@ -2330,13 +2330,13 @@ public class ConcurrentHashMap extends AbstractMap private final void addCount(long x, int check) { CounterCell[] as; long b, s; if ((as = counterCells) != null || - !U.compareAndSwapLong(this, BASECOUNT, b = baseCount, s = b + x)) { + !U.compareAndSetLong(this, BASECOUNT, b = baseCount, s = b + x)) { CounterCell a; long v; int m; boolean uncontended = true; if (as == null || (m = as.length - 1) < 0 || (a = as[ThreadLocalRandom.getProbe() & m]) == null || !(uncontended = - U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))) { + U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))) { fullAddCount(x, uncontended); return; } @@ -2354,10 +2354,10 @@ public class ConcurrentHashMap extends AbstractMap sc == rs + MAX_RESIZERS || (nt = nextTable) == null || transferIndex <= 0) break; - if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) + if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1)) transfer(tab, nt); } - else if (U.compareAndSwapInt(this, SIZECTL, sc, + else if (U.compareAndSetInt(this, SIZECTL, sc, (rs << RESIZE_STAMP_SHIFT) + 2)) transfer(tab, null); s = sumCount(); @@ -2378,7 +2378,7 @@ public class ConcurrentHashMap extends AbstractMap if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 || sc == rs + MAX_RESIZERS || transferIndex <= 0) break; - if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) { + if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1)) { transfer(tab, nextTab); break; } @@ -2401,7 +2401,7 @@ public class ConcurrentHashMap extends AbstractMap Node[] tab = table; int n; if (tab == null || (n = tab.length) == 0) { n = (sc > c) ? sc : c; - if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) { + if (U.compareAndSetInt(this, SIZECTL, sc, -1)) { try { if (table == tab) { @SuppressWarnings("unchecked") @@ -2418,7 +2418,7 @@ public class ConcurrentHashMap extends AbstractMap break; else if (tab == table) { int rs = resizeStamp(n); - if (U.compareAndSwapInt(this, SIZECTL, sc, + if (U.compareAndSetInt(this, SIZECTL, sc, (rs << RESIZE_STAMP_SHIFT) + 2)) transfer(tab, null); } @@ -2459,7 +2459,7 @@ public class ConcurrentHashMap extends AbstractMap i = -1; advance = false; } - else if (U.compareAndSwapInt + else if (U.compareAndSetInt (this, TRANSFERINDEX, nextIndex, nextBound = (nextIndex > stride ? nextIndex - stride : 0))) { @@ -2476,7 +2476,7 @@ public class ConcurrentHashMap extends AbstractMap sizeCtl = (n << 1) - (n >>> 1); return; } - if (U.compareAndSwapInt(this, SIZECTL, sc = sizeCtl, sc - 1)) { + if (U.compareAndSetInt(this, SIZECTL, sc = sizeCtl, sc - 1)) { if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT) return; finishing = advance = true; @@ -2601,7 +2601,7 @@ public class ConcurrentHashMap extends AbstractMap if (cellsBusy == 0) { // Try to attach new Cell CounterCell r = new CounterCell(x); // Optimistic create if (cellsBusy == 0 && - U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) { + U.compareAndSetInt(this, CELLSBUSY, 0, 1)) { boolean created = false; try { // Recheck under lock CounterCell[] rs; int m, j; @@ -2623,14 +2623,14 @@ public class ConcurrentHashMap extends AbstractMap } else if (!wasUncontended) // CAS already known to fail wasUncontended = true; // Continue after rehash - else if (U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x)) + else if (U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x)) break; else if (counterCells != as || n >= NCPU) collide = false; // At max size or stale else if (!collide) collide = true; else if (cellsBusy == 0 && - U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) { + U.compareAndSetInt(this, CELLSBUSY, 0, 1)) { try { if (counterCells == as) {// Expand table unless stale CounterCell[] rs = new CounterCell[n << 1]; @@ -2647,7 +2647,7 @@ public class ConcurrentHashMap extends AbstractMap h = ThreadLocalRandom.advanceProbe(h); } else if (cellsBusy == 0 && counterCells == as && - U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) { + U.compareAndSetInt(this, CELLSBUSY, 0, 1)) { boolean init = false; try { // Initialize table if (counterCells == as) { @@ -2662,7 +2662,7 @@ public class ConcurrentHashMap extends AbstractMap if (init) break; } - else if (U.compareAndSwapLong(this, BASECOUNT, v = baseCount, v + x)) + else if (U.compareAndSetLong(this, BASECOUNT, v = baseCount, v + x)) break; // Fall back on using base } } @@ -2858,7 +2858,7 @@ public class ConcurrentHashMap extends AbstractMap * Acquires write lock for tree restructuring. */ private final void lockRoot() { - if (!U.compareAndSwapInt(this, LOCKSTATE, 0, WRITER)) + if (!U.compareAndSetInt(this, LOCKSTATE, 0, WRITER)) contendedLock(); // offload to separate method } @@ -2876,14 +2876,14 @@ public class ConcurrentHashMap extends AbstractMap boolean waiting = false; for (int s;;) { if (((s = lockState) & ~WAITER) == 0) { - if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) { + if (U.compareAndSetInt(this, LOCKSTATE, s, WRITER)) { if (waiting) waiter = null; return; } } else if ((s & WAITER) == 0) { - if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) { + if (U.compareAndSetInt(this, LOCKSTATE, s, s | WAITER)) { waiting = true; waiter = Thread.currentThread(); } @@ -2908,7 +2908,7 @@ public class ConcurrentHashMap extends AbstractMap return e; e = e.next; } - else if (U.compareAndSwapInt(this, LOCKSTATE, s, + else if (U.compareAndSetInt(this, LOCKSTATE, s, s + READER)) { TreeNode r, p; try { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java index f2184aaeebd..22850e6dab7 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java @@ -140,7 +140,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * the actual value was not equal to the expected value. */ public final boolean compareAndSet(int expectedValue, int newValue) { - return U.compareAndSwapInt(this, VALUE, expectedValue, newValue); + return U.compareAndSetInt(this, VALUE, expectedValue, newValue); } /** @@ -161,7 +161,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { */ @Deprecated(since="9") public final boolean weakCompareAndSet(int expectedValue, int newValue) { - return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetIntPlain(this, VALUE, expectedValue, newValue); } /** @@ -175,7 +175,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) { - return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetIntPlain(this, VALUE, expectedValue, newValue); } /** @@ -473,7 +473,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * @since 9 */ public final int compareAndExchange(int expectedValue, int newValue) { - return U.compareAndExchangeIntVolatile(this, VALUE, expectedValue, newValue); + return U.compareAndExchangeInt(this, VALUE, expectedValue, newValue); } /** @@ -520,7 +520,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(int expectedValue, int newValue) { - return U.weakCompareAndSwapIntVolatile(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetInt(this, VALUE, expectedValue, newValue); } /** @@ -535,7 +535,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetAcquire(int expectedValue, int newValue) { - return U.weakCompareAndSwapIntAcquire(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetIntAcquire(this, VALUE, expectedValue, newValue); } /** @@ -550,7 +550,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetRelease(int expectedValue, int newValue) { - return U.weakCompareAndSwapIntRelease(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetIntRelease(this, VALUE, expectedValue, newValue); } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java index 1de994f06ec..826a0557b5f 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java @@ -481,12 +481,12 @@ public abstract class AtomicIntegerFieldUpdater { public final boolean compareAndSet(T obj, int expect, int update) { accessCheck(obj); - return U.compareAndSwapInt(obj, offset, expect, update); + return U.compareAndSetInt(obj, offset, expect, update); } public final boolean weakCompareAndSet(T obj, int expect, int update) { accessCheck(obj); - return U.compareAndSwapInt(obj, offset, expect, update); + return U.compareAndSetInt(obj, offset, expect, update); } public final void set(T obj, int newValue) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java index a0670eeac8f..940f67c1bf3 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java @@ -56,7 +56,7 @@ public class AtomicLong extends Number implements java.io.Serializable { /** * Records whether the underlying JVM supports lockless - * compareAndSwap for longs. While the intrinsic compareAndSwapLong + * compareAndSet for longs. While the intrinsic compareAndSetLong * method works in either case, some constructions should be * handled at Java level to avoid locking user-visible locks. */ @@ -119,7 +119,7 @@ public class AtomicLong extends Number implements java.io.Serializable { */ public final void set(long newValue) { // Use putLongVolatile instead of ordinary volatile store when - // using compareAndSwapLong, for sake of some 32bit systems. + // using compareAndSetLong, for sake of some 32bit systems. U.putLongVolatile(this, VALUE, newValue); } @@ -156,7 +156,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * the actual value was not equal to the expected value. */ public final boolean compareAndSet(long expectedValue, long newValue) { - return U.compareAndSwapLong(this, VALUE, expectedValue, newValue); + return U.compareAndSetLong(this, VALUE, expectedValue, newValue); } /** @@ -177,7 +177,7 @@ public class AtomicLong extends Number implements java.io.Serializable { */ @Deprecated(since="9") public final boolean weakCompareAndSet(long expectedValue, long newValue) { - return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue); } /** @@ -191,7 +191,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) { - return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue); } /** @@ -487,7 +487,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * @since 9 */ public final long compareAndExchange(long expectedValue, long newValue) { - return U.compareAndExchangeLongVolatile(this, VALUE, expectedValue, newValue); + return U.compareAndExchangeLong(this, VALUE, expectedValue, newValue); } /** @@ -534,7 +534,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetVolatile(long expectedValue, long newValue) { - return U.weakCompareAndSwapLongVolatile(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetLong(this, VALUE, expectedValue, newValue); } /** @@ -549,7 +549,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetAcquire(long expectedValue, long newValue) { - return U.weakCompareAndSwapLongAcquire(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetLongAcquire(this, VALUE, expectedValue, newValue); } /** @@ -564,7 +564,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * @since 9 */ public final boolean weakCompareAndSetRelease(long expectedValue, long newValue) { - return U.weakCompareAndSwapLongRelease(this, VALUE, expectedValue, newValue); + return U.weakCompareAndSetLongRelease(this, VALUE, expectedValue, newValue); } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java index bd60f0bdcbb..ee0447a8b88 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java @@ -454,12 +454,12 @@ public abstract class AtomicLongFieldUpdater { public final boolean compareAndSet(T obj, long expect, long update) { accessCheck(obj); - return U.compareAndSwapLong(obj, offset, expect, update); + return U.compareAndSetLong(obj, offset, expect, update); } public final boolean weakCompareAndSet(T obj, long expect, long update) { accessCheck(obj); - return U.compareAndSwapLong(obj, offset, expect, update); + return U.compareAndSetLong(obj, offset, expect, update); } public final void set(T obj, long newValue) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java index 56f6751b9f0..a469abb98cc 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java @@ -432,14 +432,14 @@ public abstract class AtomicReferenceFieldUpdater { public final boolean compareAndSet(T obj, V expect, V update) { accessCheck(obj); valueCheck(update); - return U.compareAndSwapObject(obj, offset, expect, update); + return U.compareAndSetObject(obj, offset, expect, update); } public final boolean weakCompareAndSet(T obj, V expect, V update) { // same implementation as strong form for now accessCheck(obj); valueCheck(update); - return U.compareAndSwapObject(obj, offset, expect, update); + return U.compareAndSetObject(obj, offset, expect, update); } public final void set(T obj, V newValue) { diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index f4de0ea0c47..f9d7e3e22b0 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1278,55 +1278,55 @@ public final class Unsafe { * @return {@code true} if successful */ @HotSpotIntrinsicCandidate - public final native boolean compareAndSwapObject(Object o, long offset, - Object expected, - Object x); + public final native boolean compareAndSetObject(Object o, long offset, + Object expected, + Object x); @HotSpotIntrinsicCandidate - public final native Object compareAndExchangeObjectVolatile(Object o, long offset, - Object expected, - Object x); + public final native Object compareAndExchangeObject(Object o, long offset, + Object expected, + Object x); @HotSpotIntrinsicCandidate public final Object compareAndExchangeObjectAcquire(Object o, long offset, Object expected, Object x) { - return compareAndExchangeObjectVolatile(o, offset, expected, x); + return compareAndExchangeObject(o, offset, expected, x); } @HotSpotIntrinsicCandidate public final Object compareAndExchangeObjectRelease(Object o, long offset, Object expected, Object x) { - return compareAndExchangeObjectVolatile(o, offset, expected, x); + return compareAndExchangeObject(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapObject(Object o, long offset, - Object expected, - Object x) { - return compareAndSwapObject(o, offset, expected, x); + public final boolean weakCompareAndSetObjectPlain(Object o, long offset, + Object expected, + Object x) { + return compareAndSetObject(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapObjectAcquire(Object o, long offset, - Object expected, - Object x) { - return compareAndSwapObject(o, offset, expected, x); + public final boolean weakCompareAndSetObjectAcquire(Object o, long offset, + Object expected, + Object x) { + return compareAndSetObject(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapObjectRelease(Object o, long offset, - Object expected, - Object x) { - return compareAndSwapObject(o, offset, expected, x); + public final boolean weakCompareAndSetObjectRelease(Object o, long offset, + Object expected, + Object x) { + return compareAndSetObject(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapObjectVolatile(Object o, long offset, - Object expected, - Object x) { - return compareAndSwapObject(o, offset, expected, x); + public final boolean weakCompareAndSetObject(Object o, long offset, + Object expected, + Object x) { + return compareAndSetObject(o, offset, expected, x); } /** @@ -1339,61 +1339,61 @@ public final class Unsafe { * @return {@code true} if successful */ @HotSpotIntrinsicCandidate - public final native boolean compareAndSwapInt(Object o, long offset, - int expected, - int x); + public final native boolean compareAndSetInt(Object o, long offset, + int expected, + int x); @HotSpotIntrinsicCandidate - public final native int compareAndExchangeIntVolatile(Object o, long offset, - int expected, - int x); + public final native int compareAndExchangeInt(Object o, long offset, + int expected, + int x); @HotSpotIntrinsicCandidate public final int compareAndExchangeIntAcquire(Object o, long offset, int expected, int x) { - return compareAndExchangeIntVolatile(o, offset, expected, x); + return compareAndExchangeInt(o, offset, expected, x); } @HotSpotIntrinsicCandidate public final int compareAndExchangeIntRelease(Object o, long offset, int expected, int x) { - return compareAndExchangeIntVolatile(o, offset, expected, x); + return compareAndExchangeInt(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapInt(Object o, long offset, - int expected, - int x) { - return compareAndSwapInt(o, offset, expected, x); + public final boolean weakCompareAndSetIntPlain(Object o, long offset, + int expected, + int x) { + return compareAndSetInt(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapIntAcquire(Object o, long offset, - int expected, - int x) { - return compareAndSwapInt(o, offset, expected, x); + public final boolean weakCompareAndSetIntAcquire(Object o, long offset, + int expected, + int x) { + return compareAndSetInt(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapIntRelease(Object o, long offset, - int expected, - int x) { - return compareAndSwapInt(o, offset, expected, x); + public final boolean weakCompareAndSetIntRelease(Object o, long offset, + int expected, + int x) { + return compareAndSetInt(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapIntVolatile(Object o, long offset, - int expected, - int x) { - return compareAndSwapInt(o, offset, expected, x); + public final boolean weakCompareAndSetInt(Object o, long offset, + int expected, + int x) { + return compareAndSetInt(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final byte compareAndExchangeByteVolatile(Object o, long offset, - byte expected, - byte x) { + public final byte compareAndExchangeByte(Object o, long offset, + byte expected, + byte x) { long wordOffset = offset & ~3; int shift = (int) (offset & 3) << 3; if (BE) { @@ -1407,64 +1407,64 @@ public final class Unsafe { fullWord = getIntVolatile(o, wordOffset); if ((fullWord & mask) != maskedExpected) return (byte) ((fullWord & mask) >> shift); - } while (!weakCompareAndSwapIntVolatile(o, wordOffset, + } while (!weakCompareAndSetInt(o, wordOffset, fullWord, (fullWord & ~mask) | maskedX)); return expected; } @HotSpotIntrinsicCandidate - public final boolean compareAndSwapByte(Object o, long offset, - byte expected, - byte x) { - return compareAndExchangeByteVolatile(o, offset, expected, x) == expected; + public final boolean compareAndSetByte(Object o, long offset, + byte expected, + byte x) { + return compareAndExchangeByte(o, offset, expected, x) == expected; } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapByteVolatile(Object o, long offset, - byte expected, - byte x) { - return compareAndSwapByte(o, offset, expected, x); + public final boolean weakCompareAndSetByte(Object o, long offset, + byte expected, + byte x) { + return compareAndSetByte(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapByteAcquire(Object o, long offset, - byte expected, - byte x) { - return weakCompareAndSwapByteVolatile(o, offset, expected, x); + public final boolean weakCompareAndSetByteAcquire(Object o, long offset, + byte expected, + byte x) { + return weakCompareAndSetByte(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapByteRelease(Object o, long offset, - byte expected, - byte x) { - return weakCompareAndSwapByteVolatile(o, offset, expected, x); + public final boolean weakCompareAndSetByteRelease(Object o, long offset, + byte expected, + byte x) { + return weakCompareAndSetByte(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapByte(Object o, long offset, - byte expected, - byte x) { - return weakCompareAndSwapByteVolatile(o, offset, expected, x); + public final boolean weakCompareAndSetBytePlain(Object o, long offset, + byte expected, + byte x) { + return weakCompareAndSetByte(o, offset, expected, x); } @HotSpotIntrinsicCandidate public final byte compareAndExchangeByteAcquire(Object o, long offset, byte expected, byte x) { - return compareAndExchangeByteVolatile(o, offset, expected, x); + return compareAndExchangeByte(o, offset, expected, x); } @HotSpotIntrinsicCandidate public final byte compareAndExchangeByteRelease(Object o, long offset, byte expected, byte x) { - return compareAndExchangeByteVolatile(o, offset, expected, x); + return compareAndExchangeByte(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final short compareAndExchangeShortVolatile(Object o, long offset, - short expected, - short x) { + public final short compareAndExchangeShort(Object o, long offset, + short expected, + short x) { if ((offset & 3) == 3) { throw new IllegalArgumentException("Update spans the word, not supported"); } @@ -1482,44 +1482,44 @@ public final class Unsafe { if ((fullWord & mask) != maskedExpected) { return (short) ((fullWord & mask) >> shift); } - } while (!weakCompareAndSwapIntVolatile(o, wordOffset, + } while (!weakCompareAndSetInt(o, wordOffset, fullWord, (fullWord & ~mask) | maskedX)); return expected; } @HotSpotIntrinsicCandidate - public final boolean compareAndSwapShort(Object o, long offset, - short expected, - short x) { - return compareAndExchangeShortVolatile(o, offset, expected, x) == expected; + public final boolean compareAndSetShort(Object o, long offset, + short expected, + short x) { + return compareAndExchangeShort(o, offset, expected, x) == expected; } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapShortVolatile(Object o, long offset, - short expected, - short x) { - return compareAndSwapShort(o, offset, expected, x); + public final boolean weakCompareAndSetShort(Object o, long offset, + short expected, + short x) { + return compareAndSetShort(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapShortAcquire(Object o, long offset, - short expected, - short x) { - return weakCompareAndSwapShortVolatile(o, offset, expected, x); + public final boolean weakCompareAndSetShortAcquire(Object o, long offset, + short expected, + short x) { + return weakCompareAndSetShort(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapShortRelease(Object o, long offset, - short expected, - short x) { - return weakCompareAndSwapShortVolatile(o, offset, expected, x); + public final boolean weakCompareAndSetShortRelease(Object o, long offset, + short expected, + short x) { + return weakCompareAndSetShort(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapShort(Object o, long offset, - short expected, - short x) { - return weakCompareAndSwapShortVolatile(o, offset, expected, x); + public final boolean weakCompareAndSetShortPlain(Object o, long offset, + short expected, + short x) { + return weakCompareAndSetShort(o, offset, expected, x); } @@ -1527,14 +1527,14 @@ public final class Unsafe { public final short compareAndExchangeShortAcquire(Object o, long offset, short expected, short x) { - return compareAndExchangeShortVolatile(o, offset, expected, x); + return compareAndExchangeShort(o, offset, expected, x); } @HotSpotIntrinsicCandidate public final short compareAndExchangeShortRelease(Object o, long offset, short expected, short x) { - return compareAndExchangeShortVolatile(o, offset, expected, x); + return compareAndExchangeShort(o, offset, expected, x); } @ForceInline @@ -1548,17 +1548,17 @@ public final class Unsafe { } @ForceInline - public final boolean compareAndSwapChar(Object o, long offset, - char expected, - char x) { - return compareAndSwapShort(o, offset, c2s(expected), c2s(x)); + public final boolean compareAndSetChar(Object o, long offset, + char expected, + char x) { + return compareAndSetShort(o, offset, c2s(expected), c2s(x)); } @ForceInline - public final char compareAndExchangeCharVolatile(Object o, long offset, - char expected, - char x) { - return s2c(compareAndExchangeShortVolatile(o, offset, c2s(expected), c2s(x))); + public final char compareAndExchangeChar(Object o, long offset, + char expected, + char x) { + return s2c(compareAndExchangeShort(o, offset, c2s(expected), c2s(x))); } @ForceInline @@ -1576,31 +1576,31 @@ public final class Unsafe { } @ForceInline - public final boolean weakCompareAndSwapCharVolatile(Object o, long offset, - char expected, - char x) { - return weakCompareAndSwapShortVolatile(o, offset, c2s(expected), c2s(x)); + public final boolean weakCompareAndSetChar(Object o, long offset, + char expected, + char x) { + return weakCompareAndSetShort(o, offset, c2s(expected), c2s(x)); } @ForceInline - public final boolean weakCompareAndSwapCharAcquire(Object o, long offset, - char expected, - char x) { - return weakCompareAndSwapShortAcquire(o, offset, c2s(expected), c2s(x)); + public final boolean weakCompareAndSetCharAcquire(Object o, long offset, + char expected, + char x) { + return weakCompareAndSetShortAcquire(o, offset, c2s(expected), c2s(x)); } @ForceInline - public final boolean weakCompareAndSwapCharRelease(Object o, long offset, - char expected, - char x) { - return weakCompareAndSwapShortRelease(o, offset, c2s(expected), c2s(x)); + public final boolean weakCompareAndSetCharRelease(Object o, long offset, + char expected, + char x) { + return weakCompareAndSetShortRelease(o, offset, c2s(expected), c2s(x)); } @ForceInline - public final boolean weakCompareAndSwapChar(Object o, long offset, - char expected, - char x) { - return weakCompareAndSwapShort(o, offset, c2s(expected), c2s(x)); + public final boolean weakCompareAndSetCharPlain(Object o, long offset, + char expected, + char x) { + return weakCompareAndSetShortPlain(o, offset, c2s(expected), c2s(x)); } /** @@ -1653,17 +1653,17 @@ public final class Unsafe { } @ForceInline - public final boolean compareAndSwapBoolean(Object o, long offset, - boolean expected, - boolean x) { - return compareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x)); + public final boolean compareAndSetBoolean(Object o, long offset, + boolean expected, + boolean x) { + return compareAndSetByte(o, offset, bool2byte(expected), bool2byte(x)); } @ForceInline - public final boolean compareAndExchangeBooleanVolatile(Object o, long offset, - boolean expected, - boolean x) { - return byte2bool(compareAndExchangeByteVolatile(o, offset, bool2byte(expected), bool2byte(x))); + public final boolean compareAndExchangeBoolean(Object o, long offset, + boolean expected, + boolean x) { + return byte2bool(compareAndExchangeByte(o, offset, bool2byte(expected), bool2byte(x))); } @ForceInline @@ -1681,31 +1681,31 @@ public final class Unsafe { } @ForceInline - public final boolean weakCompareAndSwapBooleanVolatile(Object o, long offset, - boolean expected, - boolean x) { - return weakCompareAndSwapByteVolatile(o, offset, bool2byte(expected), bool2byte(x)); + public final boolean weakCompareAndSetBoolean(Object o, long offset, + boolean expected, + boolean x) { + return weakCompareAndSetByte(o, offset, bool2byte(expected), bool2byte(x)); } @ForceInline - public final boolean weakCompareAndSwapBooleanAcquire(Object o, long offset, - boolean expected, - boolean x) { - return weakCompareAndSwapByteAcquire(o, offset, bool2byte(expected), bool2byte(x)); + public final boolean weakCompareAndSetBooleanAcquire(Object o, long offset, + boolean expected, + boolean x) { + return weakCompareAndSetByteAcquire(o, offset, bool2byte(expected), bool2byte(x)); } @ForceInline - public final boolean weakCompareAndSwapBooleanRelease(Object o, long offset, - boolean expected, - boolean x) { - return weakCompareAndSwapByteRelease(o, offset, bool2byte(expected), bool2byte(x)); + public final boolean weakCompareAndSetBooleanRelease(Object o, long offset, + boolean expected, + boolean x) { + return weakCompareAndSetByteRelease(o, offset, bool2byte(expected), bool2byte(x)); } @ForceInline - public final boolean weakCompareAndSwapBoolean(Object o, long offset, - boolean expected, - boolean x) { - return weakCompareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x)); + public final boolean weakCompareAndSetBooleanPlain(Object o, long offset, + boolean expected, + boolean x) { + return weakCompareAndSetBytePlain(o, offset, bool2byte(expected), bool2byte(x)); } /** @@ -1718,21 +1718,21 @@ public final class Unsafe { * @return {@code true} if successful */ @ForceInline - public final boolean compareAndSwapFloat(Object o, long offset, - float expected, - float x) { - return compareAndSwapInt(o, offset, + public final boolean compareAndSetFloat(Object o, long offset, + float expected, + float x) { + return compareAndSetInt(o, offset, Float.floatToRawIntBits(expected), Float.floatToRawIntBits(x)); } @ForceInline - public final float compareAndExchangeFloatVolatile(Object o, long offset, - float expected, - float x) { - int w = compareAndExchangeIntVolatile(o, offset, - Float.floatToRawIntBits(expected), - Float.floatToRawIntBits(x)); + public final float compareAndExchangeFloat(Object o, long offset, + float expected, + float x) { + int w = compareAndExchangeInt(o, offset, + Float.floatToRawIntBits(expected), + Float.floatToRawIntBits(x)); return Float.intBitsToFloat(w); } @@ -1757,37 +1757,37 @@ public final class Unsafe { } @ForceInline - public final boolean weakCompareAndSwapFloat(Object o, long offset, - float expected, - float x) { - return weakCompareAndSwapInt(o, offset, + public final boolean weakCompareAndSetFloatPlain(Object o, long offset, + float expected, + float x) { + return weakCompareAndSetIntPlain(o, offset, Float.floatToRawIntBits(expected), Float.floatToRawIntBits(x)); } @ForceInline - public final boolean weakCompareAndSwapFloatAcquire(Object o, long offset, - float expected, - float x) { - return weakCompareAndSwapIntAcquire(o, offset, - Float.floatToRawIntBits(expected), - Float.floatToRawIntBits(x)); - } - - @ForceInline - public final boolean weakCompareAndSwapFloatRelease(Object o, long offset, - float expected, - float x) { - return weakCompareAndSwapIntRelease(o, offset, - Float.floatToRawIntBits(expected), - Float.floatToRawIntBits(x)); - } - - @ForceInline - public final boolean weakCompareAndSwapFloatVolatile(Object o, long offset, + public final boolean weakCompareAndSetFloatAcquire(Object o, long offset, float expected, float x) { - return weakCompareAndSwapIntVolatile(o, offset, + return weakCompareAndSetIntAcquire(o, offset, + Float.floatToRawIntBits(expected), + Float.floatToRawIntBits(x)); + } + + @ForceInline + public final boolean weakCompareAndSetFloatRelease(Object o, long offset, + float expected, + float x) { + return weakCompareAndSetIntRelease(o, offset, + Float.floatToRawIntBits(expected), + Float.floatToRawIntBits(x)); + } + + @ForceInline + public final boolean weakCompareAndSetFloat(Object o, long offset, + float expected, + float x) { + return weakCompareAndSetInt(o, offset, Float.floatToRawIntBits(expected), Float.floatToRawIntBits(x)); } @@ -1802,21 +1802,21 @@ public final class Unsafe { * @return {@code true} if successful */ @ForceInline - public final boolean compareAndSwapDouble(Object o, long offset, - double expected, - double x) { - return compareAndSwapLong(o, offset, - Double.doubleToRawLongBits(expected), - Double.doubleToRawLongBits(x)); + public final boolean compareAndSetDouble(Object o, long offset, + double expected, + double x) { + return compareAndSetLong(o, offset, + Double.doubleToRawLongBits(expected), + Double.doubleToRawLongBits(x)); } @ForceInline - public final double compareAndExchangeDoubleVolatile(Object o, long offset, - double expected, - double x) { - long w = compareAndExchangeLongVolatile(o, offset, - Double.doubleToRawLongBits(expected), - Double.doubleToRawLongBits(x)); + public final double compareAndExchangeDouble(Object o, long offset, + double expected, + double x) { + long w = compareAndExchangeLong(o, offset, + Double.doubleToRawLongBits(expected), + Double.doubleToRawLongBits(x)); return Double.longBitsToDouble(w); } @@ -1841,37 +1841,37 @@ public final class Unsafe { } @ForceInline - public final boolean weakCompareAndSwapDouble(Object o, long offset, - double expected, - double x) { - return weakCompareAndSwapLong(o, offset, + public final boolean weakCompareAndSetDoublePlain(Object o, long offset, + double expected, + double x) { + return weakCompareAndSetLongPlain(o, offset, Double.doubleToRawLongBits(expected), Double.doubleToRawLongBits(x)); } @ForceInline - public final boolean weakCompareAndSwapDoubleAcquire(Object o, long offset, - double expected, - double x) { - return weakCompareAndSwapLongAcquire(o, offset, + public final boolean weakCompareAndSetDoubleAcquire(Object o, long offset, + double expected, + double x) { + return weakCompareAndSetLongAcquire(o, offset, Double.doubleToRawLongBits(expected), Double.doubleToRawLongBits(x)); } @ForceInline - public final boolean weakCompareAndSwapDoubleRelease(Object o, long offset, - double expected, - double x) { - return weakCompareAndSwapLongRelease(o, offset, + public final boolean weakCompareAndSetDoubleRelease(Object o, long offset, + double expected, + double x) { + return weakCompareAndSetLongRelease(o, offset, Double.doubleToRawLongBits(expected), Double.doubleToRawLongBits(x)); } @ForceInline - public final boolean weakCompareAndSwapDoubleVolatile(Object o, long offset, - double expected, - double x) { - return weakCompareAndSwapLongVolatile(o, offset, + public final boolean weakCompareAndSetDouble(Object o, long offset, + double expected, + double x) { + return weakCompareAndSetLong(o, offset, Double.doubleToRawLongBits(expected), Double.doubleToRawLongBits(x)); } @@ -1886,55 +1886,55 @@ public final class Unsafe { * @return {@code true} if successful */ @HotSpotIntrinsicCandidate - public final native boolean compareAndSwapLong(Object o, long offset, - long expected, - long x); + public final native boolean compareAndSetLong(Object o, long offset, + long expected, + long x); @HotSpotIntrinsicCandidate - public final native long compareAndExchangeLongVolatile(Object o, long offset, - long expected, - long x); + public final native long compareAndExchangeLong(Object o, long offset, + long expected, + long x); @HotSpotIntrinsicCandidate public final long compareAndExchangeLongAcquire(Object o, long offset, long expected, long x) { - return compareAndExchangeLongVolatile(o, offset, expected, x); + return compareAndExchangeLong(o, offset, expected, x); } @HotSpotIntrinsicCandidate public final long compareAndExchangeLongRelease(Object o, long offset, long expected, long x) { - return compareAndExchangeLongVolatile(o, offset, expected, x); + return compareAndExchangeLong(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapLong(Object o, long offset, - long expected, - long x) { - return compareAndSwapLong(o, offset, expected, x); + public final boolean weakCompareAndSetLongPlain(Object o, long offset, + long expected, + long x) { + return compareAndSetLong(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapLongAcquire(Object o, long offset, - long expected, - long x) { - return compareAndSwapLong(o, offset, expected, x); + public final boolean weakCompareAndSetLongAcquire(Object o, long offset, + long expected, + long x) { + return compareAndSetLong(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapLongRelease(Object o, long offset, - long expected, - long x) { - return compareAndSwapLong(o, offset, expected, x); + public final boolean weakCompareAndSetLongRelease(Object o, long offset, + long expected, + long x) { + return compareAndSetLong(o, offset, expected, x); } @HotSpotIntrinsicCandidate - public final boolean weakCompareAndSwapLongVolatile(Object o, long offset, - long expected, - long x) { - return compareAndSwapLong(o, offset, expected, x); + public final boolean weakCompareAndSetLong(Object o, long offset, + long expected, + long x) { + return compareAndSetLong(o, offset, expected, x); } /** @@ -2316,7 +2316,7 @@ public final class Unsafe { int v; do { v = getIntVolatile(o, offset); - } while (!weakCompareAndSwapIntVolatile(o, offset, v, v + delta)); + } while (!weakCompareAndSetInt(o, offset, v, v + delta)); return v; } @@ -2325,7 +2325,7 @@ public final class Unsafe { int v; do { v = getInt(o, offset); - } while (!weakCompareAndSwapIntRelease(o, offset, v, v + delta)); + } while (!weakCompareAndSetIntRelease(o, offset, v, v + delta)); return v; } @@ -2334,7 +2334,7 @@ public final class Unsafe { int v; do { v = getIntAcquire(o, offset); - } while (!weakCompareAndSwapIntAcquire(o, offset, v, v + delta)); + } while (!weakCompareAndSetIntAcquire(o, offset, v, v + delta)); return v; } @@ -2354,7 +2354,7 @@ public final class Unsafe { long v; do { v = getLongVolatile(o, offset); - } while (!weakCompareAndSwapLongVolatile(o, offset, v, v + delta)); + } while (!weakCompareAndSetLong(o, offset, v, v + delta)); return v; } @@ -2363,7 +2363,7 @@ public final class Unsafe { long v; do { v = getLong(o, offset); - } while (!weakCompareAndSwapLongRelease(o, offset, v, v + delta)); + } while (!weakCompareAndSetLongRelease(o, offset, v, v + delta)); return v; } @@ -2372,7 +2372,7 @@ public final class Unsafe { long v; do { v = getLongAcquire(o, offset); - } while (!weakCompareAndSwapLongAcquire(o, offset, v, v + delta)); + } while (!weakCompareAndSetLongAcquire(o, offset, v, v + delta)); return v; } @@ -2381,7 +2381,7 @@ public final class Unsafe { byte v; do { v = getByteVolatile(o, offset); - } while (!weakCompareAndSwapByteVolatile(o, offset, v, (byte) (v + delta))); + } while (!weakCompareAndSetByte(o, offset, v, (byte) (v + delta))); return v; } @@ -2390,7 +2390,7 @@ public final class Unsafe { byte v; do { v = getByte(o, offset); - } while (!weakCompareAndSwapByteRelease(o, offset, v, (byte) (v + delta))); + } while (!weakCompareAndSetByteRelease(o, offset, v, (byte) (v + delta))); return v; } @@ -2399,7 +2399,7 @@ public final class Unsafe { byte v; do { v = getByteAcquire(o, offset); - } while (!weakCompareAndSwapByteAcquire(o, offset, v, (byte) (v + delta))); + } while (!weakCompareAndSetByteAcquire(o, offset, v, (byte) (v + delta))); return v; } @@ -2408,7 +2408,7 @@ public final class Unsafe { short v; do { v = getShortVolatile(o, offset); - } while (!weakCompareAndSwapShortVolatile(o, offset, v, (short) (v + delta))); + } while (!weakCompareAndSetShort(o, offset, v, (short) (v + delta))); return v; } @@ -2417,7 +2417,7 @@ public final class Unsafe { short v; do { v = getShort(o, offset); - } while (!weakCompareAndSwapShortRelease(o, offset, v, (short) (v + delta))); + } while (!weakCompareAndSetShortRelease(o, offset, v, (short) (v + delta))); return v; } @@ -2426,7 +2426,7 @@ public final class Unsafe { short v; do { v = getShortAcquire(o, offset); - } while (!weakCompareAndSwapShortAcquire(o, offset, v, (short) (v + delta))); + } while (!weakCompareAndSetShortAcquire(o, offset, v, (short) (v + delta))); return v; } @@ -2455,7 +2455,7 @@ public final class Unsafe { // may result in the loop not terminating. expectedBits = getIntVolatile(o, offset); v = Float.intBitsToFloat(expectedBits); - } while (!weakCompareAndSwapIntVolatile(o, offset, + } while (!weakCompareAndSetInt(o, offset, expectedBits, Float.floatToRawIntBits(v + delta))); return v; } @@ -2470,7 +2470,7 @@ public final class Unsafe { // may result in the loop not terminating. expectedBits = getInt(o, offset); v = Float.intBitsToFloat(expectedBits); - } while (!weakCompareAndSwapIntRelease(o, offset, + } while (!weakCompareAndSetIntRelease(o, offset, expectedBits, Float.floatToRawIntBits(v + delta))); return v; } @@ -2485,7 +2485,7 @@ public final class Unsafe { // may result in the loop not terminating. expectedBits = getIntAcquire(o, offset); v = Float.intBitsToFloat(expectedBits); - } while (!weakCompareAndSwapIntAcquire(o, offset, + } while (!weakCompareAndSetIntAcquire(o, offset, expectedBits, Float.floatToRawIntBits(v + delta))); return v; } @@ -2500,7 +2500,7 @@ public final class Unsafe { // may result in the loop not terminating. expectedBits = getLongVolatile(o, offset); v = Double.longBitsToDouble(expectedBits); - } while (!weakCompareAndSwapLongVolatile(o, offset, + } while (!weakCompareAndSetLong(o, offset, expectedBits, Double.doubleToRawLongBits(v + delta))); return v; } @@ -2515,7 +2515,7 @@ public final class Unsafe { // may result in the loop not terminating. expectedBits = getLong(o, offset); v = Double.longBitsToDouble(expectedBits); - } while (!weakCompareAndSwapLongRelease(o, offset, + } while (!weakCompareAndSetLongRelease(o, offset, expectedBits, Double.doubleToRawLongBits(v + delta))); return v; } @@ -2530,7 +2530,7 @@ public final class Unsafe { // may result in the loop not terminating. expectedBits = getLongAcquire(o, offset); v = Double.longBitsToDouble(expectedBits); - } while (!weakCompareAndSwapLongAcquire(o, offset, + } while (!weakCompareAndSetLongAcquire(o, offset, expectedBits, Double.doubleToRawLongBits(v + delta))); return v; } @@ -2551,7 +2551,7 @@ public final class Unsafe { int v; do { v = getIntVolatile(o, offset); - } while (!weakCompareAndSwapIntVolatile(o, offset, v, newValue)); + } while (!weakCompareAndSetInt(o, offset, v, newValue)); return v; } @@ -2560,7 +2560,7 @@ public final class Unsafe { int v; do { v = getInt(o, offset); - } while (!weakCompareAndSwapIntRelease(o, offset, v, newValue)); + } while (!weakCompareAndSetIntRelease(o, offset, v, newValue)); return v; } @@ -2569,7 +2569,7 @@ public final class Unsafe { int v; do { v = getIntAcquire(o, offset); - } while (!weakCompareAndSwapIntAcquire(o, offset, v, newValue)); + } while (!weakCompareAndSetIntAcquire(o, offset, v, newValue)); return v; } @@ -2589,7 +2589,7 @@ public final class Unsafe { long v; do { v = getLongVolatile(o, offset); - } while (!weakCompareAndSwapLongVolatile(o, offset, v, newValue)); + } while (!weakCompareAndSetLong(o, offset, v, newValue)); return v; } @@ -2598,7 +2598,7 @@ public final class Unsafe { long v; do { v = getLong(o, offset); - } while (!weakCompareAndSwapLongRelease(o, offset, v, newValue)); + } while (!weakCompareAndSetLongRelease(o, offset, v, newValue)); return v; } @@ -2607,7 +2607,7 @@ public final class Unsafe { long v; do { v = getLongAcquire(o, offset); - } while (!weakCompareAndSwapLongAcquire(o, offset, v, newValue)); + } while (!weakCompareAndSetLongAcquire(o, offset, v, newValue)); return v; } @@ -2627,7 +2627,7 @@ public final class Unsafe { Object v; do { v = getObjectVolatile(o, offset); - } while (!weakCompareAndSwapObjectVolatile(o, offset, v, newValue)); + } while (!weakCompareAndSetObject(o, offset, v, newValue)); return v; } @@ -2636,7 +2636,7 @@ public final class Unsafe { Object v; do { v = getObject(o, offset); - } while (!weakCompareAndSwapObjectRelease(o, offset, v, newValue)); + } while (!weakCompareAndSetObjectRelease(o, offset, v, newValue)); return v; } @@ -2645,7 +2645,7 @@ public final class Unsafe { Object v; do { v = getObjectAcquire(o, offset); - } while (!weakCompareAndSwapObjectAcquire(o, offset, v, newValue)); + } while (!weakCompareAndSetObjectAcquire(o, offset, v, newValue)); return v; } @@ -2654,7 +2654,7 @@ public final class Unsafe { byte v; do { v = getByteVolatile(o, offset); - } while (!weakCompareAndSwapByteVolatile(o, offset, v, newValue)); + } while (!weakCompareAndSetByte(o, offset, v, newValue)); return v; } @@ -2663,7 +2663,7 @@ public final class Unsafe { byte v; do { v = getByte(o, offset); - } while (!weakCompareAndSwapByteRelease(o, offset, v, newValue)); + } while (!weakCompareAndSetByteRelease(o, offset, v, newValue)); return v; } @@ -2672,7 +2672,7 @@ public final class Unsafe { byte v; do { v = getByteAcquire(o, offset); - } while (!weakCompareAndSwapByteAcquire(o, offset, v, newValue)); + } while (!weakCompareAndSetByteAcquire(o, offset, v, newValue)); return v; } @@ -2696,7 +2696,7 @@ public final class Unsafe { short v; do { v = getShortVolatile(o, offset); - } while (!weakCompareAndSwapShortVolatile(o, offset, v, newValue)); + } while (!weakCompareAndSetShort(o, offset, v, newValue)); return v; } @@ -2705,7 +2705,7 @@ public final class Unsafe { short v; do { v = getShort(o, offset); - } while (!weakCompareAndSwapShortRelease(o, offset, v, newValue)); + } while (!weakCompareAndSetShortRelease(o, offset, v, newValue)); return v; } @@ -2714,7 +2714,7 @@ public final class Unsafe { short v; do { v = getShortAcquire(o, offset); - } while (!weakCompareAndSwapShortAcquire(o, offset, v, newValue)); + } while (!weakCompareAndSetShortAcquire(o, offset, v, newValue)); return v; } @@ -2824,7 +2824,7 @@ public final class Unsafe { byte current; do { current = getByteVolatile(o, offset); - } while (!weakCompareAndSwapByteVolatile(o, offset, + } while (!weakCompareAndSetByte(o, offset, current, (byte) (current | mask))); return current; } @@ -2834,7 +2834,7 @@ public final class Unsafe { byte current; do { current = getByte(o, offset); - } while (!weakCompareAndSwapByteRelease(o, offset, + } while (!weakCompareAndSetByteRelease(o, offset, current, (byte) (current | mask))); return current; } @@ -2845,7 +2845,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getByte(o, offset); - } while (!weakCompareAndSwapByteAcquire(o, offset, + } while (!weakCompareAndSetByteAcquire(o, offset, current, (byte) (current | mask))); return current; } @@ -2855,7 +2855,7 @@ public final class Unsafe { byte current; do { current = getByteVolatile(o, offset); - } while (!weakCompareAndSwapByteVolatile(o, offset, + } while (!weakCompareAndSetByte(o, offset, current, (byte) (current & mask))); return current; } @@ -2865,7 +2865,7 @@ public final class Unsafe { byte current; do { current = getByte(o, offset); - } while (!weakCompareAndSwapByteRelease(o, offset, + } while (!weakCompareAndSetByteRelease(o, offset, current, (byte) (current & mask))); return current; } @@ -2876,7 +2876,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getByte(o, offset); - } while (!weakCompareAndSwapByteAcquire(o, offset, + } while (!weakCompareAndSetByteAcquire(o, offset, current, (byte) (current & mask))); return current; } @@ -2886,7 +2886,7 @@ public final class Unsafe { byte current; do { current = getByteVolatile(o, offset); - } while (!weakCompareAndSwapByteVolatile(o, offset, + } while (!weakCompareAndSetByte(o, offset, current, (byte) (current ^ mask))); return current; } @@ -2896,7 +2896,7 @@ public final class Unsafe { byte current; do { current = getByte(o, offset); - } while (!weakCompareAndSwapByteRelease(o, offset, + } while (!weakCompareAndSetByteRelease(o, offset, current, (byte) (current ^ mask))); return current; } @@ -2907,7 +2907,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getByte(o, offset); - } while (!weakCompareAndSwapByteAcquire(o, offset, + } while (!weakCompareAndSetByteAcquire(o, offset, current, (byte) (current ^ mask))); return current; } @@ -2964,7 +2964,7 @@ public final class Unsafe { short current; do { current = getShortVolatile(o, offset); - } while (!weakCompareAndSwapShortVolatile(o, offset, + } while (!weakCompareAndSetShort(o, offset, current, (short) (current | mask))); return current; } @@ -2974,7 +2974,7 @@ public final class Unsafe { short current; do { current = getShort(o, offset); - } while (!weakCompareAndSwapShortRelease(o, offset, + } while (!weakCompareAndSetShortRelease(o, offset, current, (short) (current | mask))); return current; } @@ -2985,7 +2985,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getShort(o, offset); - } while (!weakCompareAndSwapShortAcquire(o, offset, + } while (!weakCompareAndSetShortAcquire(o, offset, current, (short) (current | mask))); return current; } @@ -2995,7 +2995,7 @@ public final class Unsafe { short current; do { current = getShortVolatile(o, offset); - } while (!weakCompareAndSwapShortVolatile(o, offset, + } while (!weakCompareAndSetShort(o, offset, current, (short) (current & mask))); return current; } @@ -3005,7 +3005,7 @@ public final class Unsafe { short current; do { current = getShort(o, offset); - } while (!weakCompareAndSwapShortRelease(o, offset, + } while (!weakCompareAndSetShortRelease(o, offset, current, (short) (current & mask))); return current; } @@ -3016,7 +3016,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getShort(o, offset); - } while (!weakCompareAndSwapShortAcquire(o, offset, + } while (!weakCompareAndSetShortAcquire(o, offset, current, (short) (current & mask))); return current; } @@ -3026,7 +3026,7 @@ public final class Unsafe { short current; do { current = getShortVolatile(o, offset); - } while (!weakCompareAndSwapShortVolatile(o, offset, + } while (!weakCompareAndSetShort(o, offset, current, (short) (current ^ mask))); return current; } @@ -3036,7 +3036,7 @@ public final class Unsafe { short current; do { current = getShort(o, offset); - } while (!weakCompareAndSwapShortRelease(o, offset, + } while (!weakCompareAndSetShortRelease(o, offset, current, (short) (current ^ mask))); return current; } @@ -3047,7 +3047,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getShort(o, offset); - } while (!weakCompareAndSwapShortAcquire(o, offset, + } while (!weakCompareAndSetShortAcquire(o, offset, current, (short) (current ^ mask))); return current; } @@ -3058,7 +3058,7 @@ public final class Unsafe { int current; do { current = getIntVolatile(o, offset); - } while (!weakCompareAndSwapIntVolatile(o, offset, + } while (!weakCompareAndSetInt(o, offset, current, current | mask)); return current; } @@ -3068,7 +3068,7 @@ public final class Unsafe { int current; do { current = getInt(o, offset); - } while (!weakCompareAndSwapIntRelease(o, offset, + } while (!weakCompareAndSetIntRelease(o, offset, current, current | mask)); return current; } @@ -3079,7 +3079,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getInt(o, offset); - } while (!weakCompareAndSwapIntAcquire(o, offset, + } while (!weakCompareAndSetIntAcquire(o, offset, current, current | mask)); return current; } @@ -3100,7 +3100,7 @@ public final class Unsafe { int current; do { current = getIntVolatile(o, offset); - } while (!weakCompareAndSwapIntVolatile(o, offset, + } while (!weakCompareAndSetInt(o, offset, current, current & mask)); return current; } @@ -3110,7 +3110,7 @@ public final class Unsafe { int current; do { current = getInt(o, offset); - } while (!weakCompareAndSwapIntRelease(o, offset, + } while (!weakCompareAndSetIntRelease(o, offset, current, current & mask)); return current; } @@ -3121,7 +3121,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getInt(o, offset); - } while (!weakCompareAndSwapIntAcquire(o, offset, + } while (!weakCompareAndSetIntAcquire(o, offset, current, current & mask)); return current; } @@ -3131,7 +3131,7 @@ public final class Unsafe { int current; do { current = getIntVolatile(o, offset); - } while (!weakCompareAndSwapIntVolatile(o, offset, + } while (!weakCompareAndSetInt(o, offset, current, current ^ mask)); return current; } @@ -3141,7 +3141,7 @@ public final class Unsafe { int current; do { current = getInt(o, offset); - } while (!weakCompareAndSwapIntRelease(o, offset, + } while (!weakCompareAndSetIntRelease(o, offset, current, current ^ mask)); return current; } @@ -3152,7 +3152,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getInt(o, offset); - } while (!weakCompareAndSwapIntAcquire(o, offset, + } while (!weakCompareAndSetIntAcquire(o, offset, current, current ^ mask)); return current; } @@ -3163,7 +3163,7 @@ public final class Unsafe { long current; do { current = getLongVolatile(o, offset); - } while (!weakCompareAndSwapLongVolatile(o, offset, + } while (!weakCompareAndSetLong(o, offset, current, current | mask)); return current; } @@ -3173,7 +3173,7 @@ public final class Unsafe { long current; do { current = getLong(o, offset); - } while (!weakCompareAndSwapLongRelease(o, offset, + } while (!weakCompareAndSetLongRelease(o, offset, current, current | mask)); return current; } @@ -3184,7 +3184,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getLong(o, offset); - } while (!weakCompareAndSwapLongAcquire(o, offset, + } while (!weakCompareAndSetLongAcquire(o, offset, current, current | mask)); return current; } @@ -3194,7 +3194,7 @@ public final class Unsafe { long current; do { current = getLongVolatile(o, offset); - } while (!weakCompareAndSwapLongVolatile(o, offset, + } while (!weakCompareAndSetLong(o, offset, current, current & mask)); return current; } @@ -3204,7 +3204,7 @@ public final class Unsafe { long current; do { current = getLong(o, offset); - } while (!weakCompareAndSwapLongRelease(o, offset, + } while (!weakCompareAndSetLongRelease(o, offset, current, current & mask)); return current; } @@ -3215,7 +3215,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getLong(o, offset); - } while (!weakCompareAndSwapLongAcquire(o, offset, + } while (!weakCompareAndSetLongAcquire(o, offset, current, current & mask)); return current; } @@ -3225,7 +3225,7 @@ public final class Unsafe { long current; do { current = getLongVolatile(o, offset); - } while (!weakCompareAndSwapLongVolatile(o, offset, + } while (!weakCompareAndSetLong(o, offset, current, current ^ mask)); return current; } @@ -3235,7 +3235,7 @@ public final class Unsafe { long current; do { current = getLong(o, offset); - } while (!weakCompareAndSwapLongRelease(o, offset, + } while (!weakCompareAndSetLongRelease(o, offset, current, current ^ mask)); return current; } @@ -3246,7 +3246,7 @@ public final class Unsafe { do { // Plain read, the value is a hint, the acquire CAS does the work current = getLong(o, offset); - } while (!weakCompareAndSwapLongAcquire(o, offset, + } while (!weakCompareAndSetLongAcquire(o, offset, current, current ^ mask)); return current; } diff --git a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java index a77109ce49c..c4fe1d90e3a 100644 --- a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java +++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -872,7 +872,7 @@ public final class Unsafe { public final boolean compareAndSwapObject(Object o, long offset, Object expected, Object x) { - return theInternalUnsafe.compareAndSwapObject(o, offset, expected, x); + return theInternalUnsafe.compareAndSetObject(o, offset, expected, x); } /** @@ -888,7 +888,7 @@ public final class Unsafe { public final boolean compareAndSwapInt(Object o, long offset, int expected, int x) { - return theInternalUnsafe.compareAndSwapInt(o, offset, expected, x); + return theInternalUnsafe.compareAndSetInt(o, offset, expected, x); } /** @@ -904,7 +904,7 @@ public final class Unsafe { public final boolean compareAndSwapLong(Object o, long offset, long expected, long x) { - return theInternalUnsafe.compareAndSwapLong(o, offset, expected, x); + return theInternalUnsafe.compareAndSetLong(o, offset, expected, x); } /** From 8f060891682e2a97e253fc4639be8053ec106e17 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 6 Jun 2017 11:11:12 +0530 Subject: [PATCH 05/59] 8181401: Error in Javadoc for JTabbedPane getAccessibleName() Reviewed-by: serb, ssadetsky --- jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java index 184ca2c2d0b..b6d50b4ade4 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java @@ -1900,7 +1900,7 @@ public class JTabbedPane extends JComponent * Returns the accessible name of this object, or {@code null} if * there is no accessible name. * - * @return the accessible name of this object, nor {@code null}. + * @return the accessible name of this object, or {@code null}. * @since 1.6 */ public String getAccessibleName() { From 7034b5747396ce834bb7524bec1b20a926a7806d Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 6 Jun 2017 11:56:01 +0530 Subject: [PATCH 06/59] 8181640: Spelling mistake in javadoc javax.swing.JEditorPane.scrollToReference(String) Reviewed-by: serb --- jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java index 9fdafb65e0a..f80c41f1f98 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JEditorPane.java @@ -812,7 +812,7 @@ public class JEditorPane extends JTextComponent { /** * Scrolls the view to the given reference location - * (that is, the value returned by the UL.getRef + * (that is, the value returned by the URL.getRef * method for the URL being displayed). By default, this * method only knows how to locate a reference in an * HTMLDocument. The implementation calls the From 77532f2533ebe5f99587c7eddc41fedd2bc41bdc Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Tue, 6 Jun 2017 14:38:19 +0530 Subject: [PATCH 07/59] 8172510: This test fails for me on OS X consistently with result: Expected : 01230123 Actual : 001122303011223 Reviewed-by: serb, prr --- jdk/test/java/awt/List/ItemEventTest/ItemEventTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/awt/List/ItemEventTest/ItemEventTest.java b/jdk/test/java/awt/List/ItemEventTest/ItemEventTest.java index 65cbc5f9c9d..c5d45379905 100644 --- a/jdk/test/java/awt/List/ItemEventTest/ItemEventTest.java +++ b/jdk/test/java/awt/List/ItemEventTest/ItemEventTest.java @@ -24,7 +24,7 @@ /* * @test * @key headful - * @bug 8033936 + * @bug 8033936 8172510 * @summary Verify that correct ItemEvent is received while selection & * deselection of multi select List items. */ @@ -109,14 +109,16 @@ public class ItemEventTest extends Frame boolean isMac = osName.contains("Mac") || osName.contains("mac"); if(isMac) { robot.keyPress(KeyEvent.VK_META); + robot.waitForIdle(); } // First loop to select & Second loop to deselect the list items. for (int j = 0; j < 2; ++j) { for (int i = 0; i < list.getItemCount(); ++i) { robot.mouseMove(loc.x, loc.y + i * dY); + robot.waitForIdle(); robot.mousePress(InputEvent.BUTTON1_MASK); - robot.delay(100); + robot.waitForIdle(); robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.waitForIdle(); } From fc92cc69ef02e50899ca8120d06fe8001921faa2 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 7 Jun 2017 10:03:41 +0800 Subject: [PATCH 08/59] 8181461: sun/security/krb5/auto/KdcPolicy.java fails with java.lang.Exception: Does not match Reviewed-by: xuelei --- jdk/test/sun/security/krb5/auto/KdcPolicy.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/sun/security/krb5/auto/KdcPolicy.java b/jdk/test/sun/security/krb5/auto/KdcPolicy.java index f4501a5779b..6eca564b96f 100644 --- a/jdk/test/sun/security/krb5/auto/KdcPolicy.java +++ b/jdk/test/sun/security/krb5/auto/KdcPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import sun.security.krb5.Config; /* * @test - * @bug 8164656 + * @bug 8164656 8181461 * @run main/othervm KdcPolicy udp * @run main/othervm KdcPolicy tcp * @summary krb5.kdc.bad.policy test @@ -110,7 +110,7 @@ public class KdcPolicy { // It is possible the real KDC cannot fulfil the request // in 3s, so it might fail (either 1st time or 2nd time). writeConf(1, 3000, p1, p3); - test("a3000c3000c3000|a3000c3000-|a3000c3000c3000-"); + test("a3000c3000c3000|a3000c3000-|a3000c3000c3000a3000-"); // If a test case won't use a real KDC, it can be sped up. writeConf(3, 5, p1, p2); From 644aec52123fb47e0e4523b1f2fcb60c52661467 Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Wed, 7 Jun 2017 15:05:35 -0400 Subject: [PATCH 09/59] 8181195: Mark java.se.ee aggregator module deprecated and for removal Reviewed-by: joehw, alanb, mchung --- jdk/src/java.se.ee/share/classes/module-info.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/java.se.ee/share/classes/module-info.java b/jdk/src/java.se.ee/share/classes/module-info.java index 983a4c7c71d..3a77d4e94c5 100644 --- a/jdk/src/java.se.ee/share/classes/module-info.java +++ b/jdk/src/java.se.ee/share/classes/module-info.java @@ -34,6 +34,7 @@ */ @SuppressWarnings({"deprecation", "removal"}) // java.corba and other modules +@Deprecated(since="9", forRemoval=true) module java.se.ee { requires transitive java.se; From 0e7374e99c2ff812959d353ef10ddf3a3d8b8d8f Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Wed, 7 Jun 2017 18:47:54 -0400 Subject: [PATCH 10/59] 8181702: Mark jdk.xml.bind and jdk.xml.ws modules deprecated and for removal Reviewed-by: alanb, mchung --- jaxws/src/jdk.xml.bind/share/classes/module-info.java | 8 ++++++++ jaxws/src/jdk.xml.ws/share/classes/module-info.java | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/jaxws/src/jdk.xml.bind/share/classes/module-info.java b/jaxws/src/jdk.xml.bind/share/classes/module-info.java index 8757ce45f33..2f1896cd970 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/module-info.java +++ b/jaxws/src/jdk.xml.bind/share/classes/module-info.java @@ -23,6 +23,14 @@ * questions. */ +/** + * Defines tools for JAXB classes and XML schema generation. + * + * @moduleGraph + * @since 9 + * + */ +@Deprecated(since="9", forRemoval=true) module jdk.xml.bind { requires java.activation; requires java.compiler; diff --git a/jaxws/src/jdk.xml.ws/share/classes/module-info.java b/jaxws/src/jdk.xml.ws/share/classes/module-info.java index dbec9c537b0..31aaee681e6 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/module-info.java +++ b/jaxws/src/jdk.xml.ws/share/classes/module-info.java @@ -23,6 +23,13 @@ * questions. */ +/** + * Defines tools for JAXWS classes and WSDL generation + * + * @moduleGraph + * @since 9 + */ +@Deprecated(since="9", forRemoval=true) module jdk.xml.ws { requires java.compiler; requires java.logging; From fd73998610c7514f808c47064290089fb50607fd Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 18:54:45 -0700 Subject: [PATCH 11/59] 8181696: Package versioning link does not exist in JAR file specification Reviewed-by: alanb --- .../java.base/share/classes/java/lang/ClassLoader.java | 2 -- jdk/src/java.base/share/classes/java/lang/Package.java | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index 9aee833e141..0dbccf5d7d8 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -2146,8 +2146,6 @@ public abstract class ClassLoader { * @revised 9 * @spec JPMS * - * @see - * The JAR File Specification: Package Versioning * @see * The JAR File Specification: Package Sealing */ diff --git a/jdk/src/java.base/share/classes/java/lang/Package.java b/jdk/src/java.base/share/classes/java/lang/Package.java index 25bf4a751fd..39760af1a24 100644 --- a/jdk/src/java.base/share/classes/java/lang/Package.java +++ b/jdk/src/java.base/share/classes/java/lang/Package.java @@ -102,9 +102,13 @@ import jdk.internal.reflect.Reflection; * with the {@link Package#getPackages Package.getPackages()} and * {@link ClassLoader#getDefinedPackages} methods. * + * @implNote + * The builtin class loaders + * do not explicitly define {@code Package} objects for packages in + * named modules. Instead those packages are automatically defined + * and have no specification and implementation versioning information. + * * @jvms 5.3 Run-time package - * @see - * The JAR File Specification: Package Versioning * @see * The JAR File Specification: Package Sealing * @see ClassLoader#definePackage(String, String, String, String, String, String, String, URL) From 0369442aa03b18d72256dca9b3b98f9a3e4da1b8 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 18:57:24 -0700 Subject: [PATCH 12/59] 8181639: Add tool and services information to module summary Reviewed-by: alanb, psandoz, lancea --- .../share/classes/module-info.java | 3 + .../share/classes/module-info.java | 11 +- .../share/classes/module-info.java | 175 +++++++++++------- 3 files changed, 124 insertions(+), 65 deletions(-) diff --git a/nashorn/src/jdk.dynalink/share/classes/module-info.java b/nashorn/src/jdk.dynalink/share/classes/module-info.java index 3faffbd7f7a..fe534406e17 100644 --- a/nashorn/src/jdk.dynalink/share/classes/module-info.java +++ b/nashorn/src/jdk.dynalink/share/classes/module-info.java @@ -24,6 +24,7 @@ */ /** + * Defines the API for dynamic linking of high-level operations on objects. *

* Dynalink is a library for dynamic linking of high-level operations on objects. * These operations include "read a property", @@ -217,6 +218,8 @@ * from B will get a chance to link the call site in A when it encounters the * object from B. * + * @uses jdk.dynalink.linker.GuardingDynamicLinkerExporter + * * @moduleGraph * @since 9 */ diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/module-info.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/module-info.java index 2ed4857862b..94ce60e239f 100644 --- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/module-info.java +++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/module-info.java @@ -24,8 +24,17 @@ */ /** - * Nashorn shell module + * Defines Nashorn shell module. * + *

This module includes the command line tool {@index jjs jjs tool} + * to invoke the Nashorn engine. + * + *

+ *
Tool Guides: + *
{@extLink jjs_tool_reference jjs} + *
+ * + * @moduleGraph * @since 9 */ module jdk.scripting.nashorn.shell { diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java b/nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java index 00aeab11923..dbe121fcd94 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/module-info.java @@ -24,74 +24,121 @@ */ /** -

-Nashorn is a runtime environment for programs written in ECMAScript 5.1. -

-

Usage

-The recommended way to use Nashorn is through the JSR-223 -"Scripting for the Java Platform" APIs found in the {@link javax.script} package. Usually, you'll obtain a -{@link javax.script.ScriptEngine} instance for Nashorn using: -
+ * Provides the implementation of Nashorn script engine and
+ * the runtime environment for programs written in ECMAScript 5.1.
+ * 

+ * Nashorn is a runtime environment for programs written in ECMAScript 5.1. + *

+ * + *

Usage

+ * + * The recommended way to use Nashorn is through the + * JSR-223 + * "Scripting for the Java Platform" APIs found in the + * {@link javax.script} package. Usually, you'll obtain a + * {@link javax.script.ScriptEngine} instance for Nashorn using: + *
 import javax.script.*;
 ...
 ScriptEngine nashornEngine = new ScriptEngineManager().getEngineByName("nashorn");
 
-and then use it just as you would any other JSR-223 script engine. See -{@code jdk.nashorn.api.scripting} package -for details. -

Compatibility

-Nashorn is 100% compliant with the ECMA-262 Standard, Edition 5.1. It requires a Java Virtual Machine that implements the -JSR-292 "Supporting Dynamically Typed Languages on the Java -Platform" specification (often referred to as "invokedynamic"), as well as the already mentioned JSR-223. -

Interoperability with the Java platform

-In addition to being a 100% ECMAScript 5.1 runtime, Nashorn provides features for interoperability of the ECMAScript -programs with the Java platform. In general, any Java object put into the script engine's context will be visible from -the script. In terms of the standard, such Java objects are not considered "native objects", but rather "host objects", -as defined in section 4.3.8. This distinction allows certain semantical differences in handling them compared to native -objects. For most purposes, Java objects behave just as native objects do: you can invoke their methods, get and set -their properties. In most cases, though, you can't add arbitrary properties to them, nor can you remove existing -properties. -

Java collection handling

-Native Java arrays and {@link java.util.List}s support indexed access to their elements through the property accessors, -and {@link java.util.Map}s support both property and element access through both dot and square-bracket property -accessors, with the difference being that dot operator gives precedence to object properties (its fields and properties -defined as {@code getXxx} and {@code setXxx} methods) while the square bracket operator gives precedence to map -elements. Native Java arrays expose the {@code length} property. -

ECMAScript primitive types

-ECMAScript primitive types for number, string, and boolean are represented with {@link java.lang.Number}, -{@link java.lang.CharSequence}, and {@link java.lang.Boolean} objects. While the most often used number type is -{@link java.lang.Double} and the most often used string type is {@link java.lang.String}, don't rely on it as various -internal optimizations cause other subclasses of {@code Number} and internal implementations of {@code CharSequence} to -be used. -

Type conversions

-When a method on a Java object is invoked, the arguments are converted to the formal parameter types of the Java method -using all allowed ECMAScript conversions. This can be surprising, as in general, conversions from string to number will -succeed according to Standard's section 9.3 "ToNumber" and so on; string to boolean, number to boolean, Object to -number, Object to string all work. Note that if the Java method's declared parameter type is {@code java.lang.Object}, -Nashorn objects are passed without any conversion whatsoever; specifically if the JavaScript value being passed is of -primitive string type, you can only rely on it being a {@code java.lang.CharSequence}, and if the value is a number, you -can only rely on it being a {@code java.lang.Number}. If the Java method declared parameter type is more specific (e.g. -{@code java.lang.String} or {@code java.lang.Double}), then Nashorn will of course ensure the required type is passed. -

SAM types

-As a special extension when invoking Java methods, ECMAScript function objects can be passed in place of an argument -whose Java type is so-called "single abstract method" or "SAM" type. While this name usually covers single-method -interfaces, Nashorn is a bit more versatile, and it recognizes a type as a SAM type if all its abstract methods are -overloads of the same name, and it is either an interface, or it is an abstract class with -a no-arg constructor. The type itself must be public, while the constructor and the methods can be either public or -protected. If there are multiple abstract overloads of the same name, the single function will serve as the shared -implementation for all of them, and additionally it will also override any non-abstract methods of the same name. -This is done to be consistent with the fact that ECMAScript does not have the concept of overloaded methods. -

The {@code Java} object

-Nashorn exposes a non-standard global object named {@code Java} that is the primary API entry point into Java -platform-specific functionality. You can use it to create instances of Java classes, convert from Java arrays to native -arrays and back, and so on. -

Other non-standard built-in objects

-In addition to {@code Java}, Nashorn also exposes some other non-standard built-in objects: -{@code JSAdapter}, {@code JavaImporter}, {@code Packages} - -@moduleGraph -@since 9 + * + * and then use it just as you would any other JSR-223 script engine. See + * + * {@code jdk.nashorn.api.scripting} package for details. + *

Compatibility

+ * Nashorn is 100% compliant with the + * ECMA-262 Standard, Edition 5.1. + * It requires a Java Virtual Machine that implements the + * + * JSR-292 "Supporting Dynamically Typed Languages on the Java Platform" + * specification (often referred to as "invokedynamic"), as well as + * the already mentioned JSR-223. + * + *

Interoperability with the Java platform

+ * + * In addition to being a 100% ECMAScript 5.1 runtime, Nashorn provides features + * for interoperability of the ECMAScript programs with the Java platform. + * In general, any Java object put into the script engine's context will be + * visible from the script. In terms of the standard, such Java objects are not + * considered "native objects", but rather "host objects", as defined in + * section 4.3.8. This distinction allows certain semantical differences + * in handling them compared to native objects. For most purposes, Java objects + * behave just as native objects do: you can invoke their methods, get and set + * their properties. In most cases, though, you can't add arbitrary properties + * to them, nor can you remove existing properties. + * + *

Java collection handling

+ * + * Native Java arrays and {@link java.util.List}s support indexed access to + * their elements through the property accessors, and {@link java.util.Map}s + * support both property and element access through both dot and square-bracket + * property accessors, with the difference being that dot operator gives + * precedence to object properties (its fields and properties defined as + * {@code getXxx} and {@code setXxx} methods) while the square bracket + * operator gives precedence to map elements. Native Java arrays expose + * the {@code length} property. + * + *

ECMAScript primitive types

+ * + * ECMAScript primitive types for number, string, and boolean are represented + * with {@link java.lang.Number}, {@link java.lang.CharSequence}, and + * {@link java.lang.Boolean} objects. While the most often used number type + * is {@link java.lang.Double} and the most often used string type is + * {@link java.lang.String}, don't rely on it as various internal optimizations + * cause other subclasses of {@code Number} and internal implementations of + * {@code CharSequence} to be used. + * + *

Type conversions

+ * + * When a method on a Java object is invoked, the arguments are converted to + * the formal parameter types of the Java method using all allowed ECMAScript + * conversions. This can be surprising, as in general, conversions from string + * to number will succeed according to Standard's section 9.3 "ToNumber" + * and so on; string to boolean, number to boolean, Object to number, + * Object to string all work. Note that if the Java method's declared parameter + * type is {@code java.lang.Object}, Nashorn objects are passed without any + * conversion whatsoever; specifically if the JavaScript value being passed + * is of primitive string type, you can only rely on it being a + * {@code java.lang.CharSequence}, and if the value is a number, you can only + * rely on it being a {@code java.lang.Number}. If the Java method declared + * parameter type is more specific (e.g. {@code java.lang.String} or + * {@code java.lang.Double}), then Nashorn will of course ensure + * the required type is passed. + * + *

SAM types

+ * + * As a special extension when invoking Java methods, ECMAScript function + * objects can be passed in place of an argument whose Java type is so-called + * "single abstract method" or "SAM" type. While this name usually covers + * single-method interfaces, Nashorn is a bit more versatile, and it + * recognizes a type as a SAM type if all its abstract methods are + * overloads of the same name, and it is either an interface, or it is an + * abstract class with a no-arg constructor. The type itself must be public, + * while the constructor and the methods can be either public or protected. + * If there are multiple abstract overloads of the same name, the single + * function will serve as the shared implementation for all of them, + * and additionally it will also override any non-abstract methods of + * the same name. This is done to be consistent with the fact that + * ECMAScript does not have the concept of overloaded methods. + * + *

The {@code Java} object

+ * + * Nashorn exposes a non-standard global object named {@code Java} that is + * the primary API entry point into Java platform-specific functionality. + * You can use it to create instances of Java classes, convert from Java arrays + * to native arrays and back, and so on. + * + *

Other non-standard built-in objects

+ * + * In addition to {@code Java}, Nashorn also exposes some other + * non-standard built-in objects: + * {@code JSAdapter}, {@code JavaImporter}, {@code Packages} + * + * @provides javax.script.ScriptEngineFactory + * @moduleGraph + * @since 9 */ module jdk.scripting.nashorn { requires java.logging; From 848c1f69fb64c4e3311a59d0f93f1b318ebc982d Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 18:57:35 -0700 Subject: [PATCH 13/59] 8181639: Add tool and services information to module summary Reviewed-by: alanb, psandoz, lancea --- .../src/jdk.hotspot.agent/share/classes/module-info.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java index a5308d46ea2..2c9f4f26da5 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java @@ -26,6 +26,15 @@ /** * Defines the implementation of the HotSpot Serviceability Agent. * + *

This module includes the {@index jhsdb jhsdb tool} tool to + * attach to a running Java Virtual Machine (JVM) or launch a postmortem + * debugger to analyze the content of a core-dump from a crashed JVM. + * + *

+ *
Tool Guides:
+ *
{@extLink jhsdb_tool_reference jhsdb}
+ *
+ * * @moduleGraph * @since 9 */ From 5e82a2de08a9565e55d54daf4e0bb31592a109c3 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 21:08:37 -0700 Subject: [PATCH 14/59] 8181639: Add tool and services information to module summary Reviewed-by: alanb, psandoz, lancea --- jaxp/src/java.xml/share/classes/module-info.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jaxp/src/java.xml/share/classes/module-info.java b/jaxp/src/java.xml/share/classes/module-info.java index af2e5d6daf8..683c524c87f 100644 --- a/jaxp/src/java.xml/share/classes/module-info.java +++ b/jaxp/src/java.xml/share/classes/module-info.java @@ -27,6 +27,17 @@ * Defines the Java API for XML Processing (JAXP), the Streaming API for XML (StAX), * the Simple API for XML (SAX), and the W3C Document Object Model (DOM) API. * + * @uses javax.xml.datatype.DatatypeFactory + * @uses javax.xml.parsers.DocumentBuilderFactory + * @uses javax.xml.parsers.SAXParserFactory + * @uses javax.xml.stream.XMLEventFactory + * @uses javax.xml.stream.XMLInputFactory + * @uses javax.xml.stream.XMLOutputFactory + * @uses javax.xml.transform.TransformerFactory + * @uses javax.xml.validation.SchemaFactory + * @uses javax.xml.xpath.XPathFactory + * @uses org.xml.sax.XMLReader + * * @moduleGraph * @since 9 */ From 76800fef736593e36316033077790f487ae79e98 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 21:14:58 -0700 Subject: [PATCH 15/59] 8181639: Add tool and services information to module summary Reviewed-by: alanb, psandoz, lancea --- .../src/java.xml.bind/share/classes/module-info.java | 2 ++ jaxws/src/java.xml.ws/share/classes/module-info.java | 6 ++++++ jaxws/src/jdk.xml.bind/share/classes/module-info.java | 11 +++++++++-- jaxws/src/jdk.xml.ws/share/classes/module-info.java | 10 +++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/jaxws/src/java.xml.bind/share/classes/module-info.java b/jaxws/src/java.xml.bind/share/classes/module-info.java index c871b6f0d47..61f80413966 100644 --- a/jaxws/src/java.xml.bind/share/classes/module-info.java +++ b/jaxws/src/java.xml.bind/share/classes/module-info.java @@ -26,6 +26,8 @@ /** * Defines the Java Architecture for XML Binding (JAXB) API. * + * @uses javax.xml.bind.JAXBContextFactory + * * @moduleGraph * @since 9 */ diff --git a/jaxws/src/java.xml.ws/share/classes/module-info.java b/jaxws/src/java.xml.ws/share/classes/module-info.java index a1f9cfb66bb..67ab3d18f0b 100644 --- a/jaxws/src/java.xml.ws/share/classes/module-info.java +++ b/jaxws/src/java.xml.ws/share/classes/module-info.java @@ -27,6 +27,12 @@ * Defines the Java API for XML-Based Web Services (JAX-WS), and * the Web Services Metadata API. * + * @uses javax.xml.soap.MessageFactory + * @uses javax.xml.soap.SAAJMetaFactory + * @uses javax.xml.soap.SOAPConnectionFactory + * @uses javax.xml.soap.SOAPFactory + * @uses javax.xml.ws.spi.Provider + * * @moduleGraph * @since 9 */ diff --git a/jaxws/src/jdk.xml.bind/share/classes/module-info.java b/jaxws/src/jdk.xml.bind/share/classes/module-info.java index 2f1896cd970..3f33b76c05f 100644 --- a/jaxws/src/jdk.xml.bind/share/classes/module-info.java +++ b/jaxws/src/jdk.xml.bind/share/classes/module-info.java @@ -24,11 +24,18 @@ */ /** - * Defines tools for JAXB classes and XML schema generation. + * Defines tools for JAXB classes and XML schema generation, + * including the {@index schemagen schemagen tool} + * and {@index xjc xjc tool} tools. + * + *
+ *
Tool Guides: + *
{@extLink schemagen_tool_reference schemagen}, + * {@extLink xjc_tool_reference xjc} + *
* * @moduleGraph * @since 9 - * */ @Deprecated(since="9", forRemoval=true) module jdk.xml.bind { diff --git a/jaxws/src/jdk.xml.ws/share/classes/module-info.java b/jaxws/src/jdk.xml.ws/share/classes/module-info.java index 31aaee681e6..81a6d04e44f 100644 --- a/jaxws/src/jdk.xml.ws/share/classes/module-info.java +++ b/jaxws/src/jdk.xml.ws/share/classes/module-info.java @@ -24,7 +24,15 @@ */ /** - * Defines tools for JAXWS classes and WSDL generation + * Defines tools for JAX-WS classes and WSDL generation, + * including the {@index wsgen wsgen tool} + * and {@index wsimport wsimport tool} tools. + * + *
+ *
Tool Guides: + *
{@extLink wsgen_tool_reference wsgen}, + * {@extLink wsimport_tool_reference wsimport} + *
* * @moduleGraph * @since 9 From 08c80bdefc7d92e2f4302782bb96f8f7590b3b16 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 21:15:06 -0700 Subject: [PATCH 16/59] 8181639: Add tool and services information to module summary Reviewed-by: alanb, psandoz, lancea --- .../tools/docs/docs-module-groups.properties | 4 +- .../java.base/share/classes/module-info.java | 45 +++++++++++++++++++ .../share/classes/module-info.java | 18 ++++++++ .../share/classes/module-info.java | 36 +++++++-------- .../share/classes/module-info.java | 3 ++ .../java.prefs/share/classes/module-info.java | 3 +- .../java.rmi/share/classes/module-info.java | 15 +++++++ .../share/classes/module-info.java | 14 +++++- .../java.se/share/classes/module-info.java | 9 ++++ .../share/classes/module-info.java | 3 +- .../java.sql/share/classes/module-info.java | 3 +- .../jdk.attach/share/classes/module-info.java | 3 +- .../share/classes/module-info.java | 5 ++- .../share/classes/module-info.java | 5 ++- .../share/classes/module-info.java | 5 ++- .../windows/classes/module-info.java | 3 +- .../solaris/classes/module-info.java | 3 +- .../share/classes/module-info.java | 2 +- .../share/classes/module-info.java | 3 +- .../share/classes/module-info.java | 17 ++++++- .../jdk.jcmd/share/classes/module-info.java | 16 ++++++- .../share/classes/module-info.java | 12 ++++- .../jdk.jdi/share/classes/module-info.java | 19 ++++++-- .../share/classes/module-info.java | 5 ++- .../jdk.jlink/share/classes/module-info.java | 26 ++++++++++- .../jdk.jstatd/share/classes/module-info.java | 9 +++- .../share/classes/module-info.java | 2 +- .../share/classes/module-info.java | 7 ++- .../share/classes/module-info.java | 4 +- .../share/classes/module-info.java | 4 +- .../jdk.pack/share/classes/module-info.java | 11 ++++- .../share/classes/module-info.java | 9 +++- .../jdk.rmic/share/classes/module-info.java | 9 +++- .../share/classes/module-info.java | 6 +-- .../jdk.zipfs/share/classes/module-info.java | 9 +++- 35 files changed, 282 insertions(+), 65 deletions(-) diff --git a/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties b/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties index 98a34b91e2e..093a294a505 100644 --- a/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties +++ b/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties @@ -10,7 +10,9 @@ java.corba \ java.transaction \ java.xml.bind \ java.xml.ws \ -java.xml.ws.annotation +java.xml.ws.annotation \ +jdk.xml.bind \ +jdk.xml.ws aggregator_modules=\ java.se \ diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index e637bc34d7d..1880e1c8cdb 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -26,6 +26,51 @@ /** * Defines the foundational APIs of the Java SE Platform. * + *
+ *
Providers:
+ *
The JDK implementation of this module provides an implementation of + * the {@index jrt jrt} {@linkplain java.nio.file.spi.FileSystemProvider + * file system provider} to enumerate and read the class and resource + * files in a run-time image. + * The jrt file system can be created by calling + * {@link java.nio.file.FileSystems#newFileSystem + * FileSystems.newFileSystem(URI.create("jrt:/"))}. + *

+ *
Tool Guides:
+ *
{@extLink java_tool_reference java launcher}, + * {@extLink keytool_tool_reference keytool}
+ *
+ * + * @provides java.nio.file.spi.FileSystemProvider + * + * @uses java.lang.System.LoggerFinder + * @uses java.net.ContentHandlerFactory + * @uses java.net.spi.URLStreamHandlerProvider + * @uses java.nio.channels.spi.AsynchronousChannelProvider + * @uses java.nio.channels.spi.SelectorProvider + * @uses java.nio.charset.spi.CharsetProvider + * @uses java.nio.file.spi.FileSystemProvider + * @uses java.nio.file.spi.FileTypeDetector + * @uses java.security.Provider + * @uses java.text.spi.BreakIteratorProvider + * @uses java.text.spi.CollatorProvider + * @uses java.text.spi.DateFormatProvider + * @uses java.text.spi.DateFormatSymbolsProvider + * @uses java.text.spi.DecimalFormatSymbolsProvider + * @uses java.text.spi.NumberFormatProvider + * @uses java.time.chrono.AbstractChronology + * @uses java.time.chrono.Chronology + * @uses java.time.zone.ZoneRulesProvider + * @uses java.util.spi.CalendarDataProvider + * @uses java.util.spi.CalendarNameProvider + * @uses java.util.spi.CurrencyNameProvider + * @uses java.util.spi.LocaleNameProvider + * @uses java.util.spi.ResourceBundleControlProvider + * @uses java.util.spi.ResourceBundleProvider + * @uses java.util.spi.TimeZoneNameProvider + * @uses java.util.spi.ToolProvider + * @uses javax.security.auth.spi.LoginModule + * * @moduleGraph * @since 9 */ diff --git a/jdk/src/java.desktop/share/classes/module-info.java b/jdk/src/java.desktop/share/classes/module-info.java index 658becc98c3..7670c7148a1 100644 --- a/jdk/src/java.desktop/share/classes/module-info.java +++ b/jdk/src/java.desktop/share/classes/module-info.java @@ -27,6 +27,24 @@ * Defines the AWT and Swing user interface toolkits, plus APIs for * accessibility, audio, imaging, printing, and JavaBeans. * + * @uses java.awt.im.spi.InputMethodDescriptor + * @uses javax.accessibility.AccessibilityProvider + * @uses javax.imageio.spi.ImageInputStreamSpi + * @uses javax.imageio.spi.ImageOutputStreamSpi + * @uses javax.imageio.spi.ImageReaderSpi + * @uses javax.imageio.spi.ImageTranscoderSpi + * @uses javax.imageio.spi.ImageWriterSpi + * @uses javax.print.PrintServiceLookup + * @uses javax.print.StreamPrintServiceFactory + * @uses javax.sound.midi.spi.MidiDeviceProvider + * @uses javax.sound.midi.spi.MidiFileReader + * @uses javax.sound.midi.spi.MidiFileWriter + * @uses javax.sound.midi.spi.SoundbankReader + * @uses javax.sound.sampled.spi.AudioFileReader + * @uses javax.sound.sampled.spi.AudioFileWriter + * @uses javax.sound.sampled.spi.FormatConversionProvider + * @uses javax.sound.sampled.spi.MixerProvider + * * @moduleGraph * @since 9 */ diff --git a/jdk/src/java.management.rmi/share/classes/module-info.java b/jdk/src/java.management.rmi/share/classes/module-info.java index ac6eabc83e3..57ef45396ed 100644 --- a/jdk/src/java.management.rmi/share/classes/module-info.java +++ b/jdk/src/java.management.rmi/share/classes/module-info.java @@ -24,27 +24,27 @@ */ /** - * Defines the RMI Connector for the Java Management Extensions (JMX) Remote API. - *

- * The {@linkplain javax.management.remote.rmi RMI connector} is a connector - * for the JMX Remote API that uses RMI to transmit client requests to a remote - * MBean server. + * Defines the {@linkplain javax.management.remote.rmi RMI connector} + * for the Java Management Extensions (JMX) Remote API. + * + *

+ *
Providers:
+ *
This module provides + * {@link javax.management.remote.JMXConnectorProvider} service + * that creates the JMX connector clients using RMI protocol. + * Instances of {@code JMXConnector} can be obtained via the + * {@link javax.management.remote.JMXConnectorFactory#newJMXConnector + * JMXConnectorFactory.newJMXConnector} factory method. + * It also provides {@link javax.management.remote.JMXConnectorServerProvider} service + * that creates the JMX connector servers using RMI protocol. + * Instances of {@code JMXConnectorServer} can be obtained via the + * {@link javax.management.remote.JMXConnectorServerFactory#newJMXConnectorServer + * JMXConnectorServerFactory.newJMXConnectorServer} factory method. + *
+ *
* * @provides javax.management.remote.JMXConnectorProvider - * A provider of {@code JMXConnector} for the RMI protocol.
- * Instances of {@code JMXConnector} using the RMI protocol - * are usually created by the {@link - * javax.management.remote.JMXConnectorFactory} which will locate - * and load the appropriate {@code JMXConnectorProvider} service - * implementation for the given protocol. - * * @provides javax.management.remote.JMXConnectorServerProvider - * A provider of {@code JMXConnectorServer} for the RMI protocol.
- * Instances of {@code JMXConnectorServer} using the RMI protocol - * are usually created by the {@link - * javax.management.remote.JMXConnectorServerFactory} which will locate - * and load the appropriate {@code JMXConnectorServerProvider} service - * implementation for the given protocol. * * @moduleGraph * @since 9 diff --git a/jdk/src/java.management/share/classes/module-info.java b/jdk/src/java.management/share/classes/module-info.java index c407821e505..bd9a74946c2 100644 --- a/jdk/src/java.management/share/classes/module-info.java +++ b/jdk/src/java.management/share/classes/module-info.java @@ -29,6 +29,9 @@ * The JMX API consists of interfaces for monitoring and management of the * JVM and other components in the Java runtime. * + * @uses javax.management.remote.JMXConnectorProvider + * @uses javax.management.remote.JMXConnectorServerProvider + * * @moduleGraph * @since 9 */ diff --git a/jdk/src/java.prefs/share/classes/module-info.java b/jdk/src/java.prefs/share/classes/module-info.java index b20d962967c..45c4449b64d 100644 --- a/jdk/src/java.prefs/share/classes/module-info.java +++ b/jdk/src/java.prefs/share/classes/module-info.java @@ -26,6 +26,8 @@ /** * Defines the Preferences API. * + * @uses java.util.prefs.PreferencesFactory + * * @moduleGraph * @since 9 */ @@ -35,4 +37,3 @@ module java.prefs { exports java.util.prefs; uses java.util.prefs.PreferencesFactory; } - diff --git a/jdk/src/java.rmi/share/classes/module-info.java b/jdk/src/java.rmi/share/classes/module-info.java index 6509952de9a..3b097bde0aa 100644 --- a/jdk/src/java.rmi/share/classes/module-info.java +++ b/jdk/src/java.rmi/share/classes/module-info.java @@ -26,6 +26,21 @@ /** * Defines the Remote Method Invocation (RMI) API. * + *

The JDK implementation of this module includes + * the {@index rmiregistry rmiregistry tool} tool to start a remote + * object registry, and the {@index rmid rmid tool} tool to start + * the activation system daemon. + * + *

+ *

+ *
Tool Guides:
+ *
{@extLink rmiregistry_tool_reference rmiregistry}, + * {@extLink rmid_tool_reference rmid} + *
+ *
+ * + * @uses java.rmi.server.RMIClassLoaderSpi + * * @moduleGraph * @since 9 */ diff --git a/jdk/src/java.scripting/share/classes/module-info.java b/jdk/src/java.scripting/share/classes/module-info.java index 42854afc437..c0ad091c4d4 100644 --- a/jdk/src/java.scripting/share/classes/module-info.java +++ b/jdk/src/java.scripting/share/classes/module-info.java @@ -26,6 +26,19 @@ /** * Defines the Scripting API. * + *

The JDK implementation of this module includes a language-independent + * command-line script shell, {@index jrunscript jrunscript tool}, + * that supports executing JavaScript and other languages if its corresponding + * script engine is installed. + * + *

+ *

+ *
Tool Guides: + *
{@extLink jrunscript_tool_reference jrunscript}
+ *
+ * + * @uses javax.script.ScriptEngineFactory + * * @moduleGraph * @since 9 */ @@ -33,4 +46,3 @@ module java.scripting { exports javax.script; uses javax.script.ScriptEngineFactory; } - diff --git a/jdk/src/java.se/share/classes/module-info.java b/jdk/src/java.se/share/classes/module-info.java index 33b99b1c13c..4ff78b70454 100644 --- a/jdk/src/java.se/share/classes/module-info.java +++ b/jdk/src/java.se/share/classes/module-info.java @@ -29,6 +29,15 @@ * The modules defining CORBA and Java EE APIs are not required by * this module, but they are required by {@code java.se.ee}. * + *
+ *
Optional for Java SE Platform:
+ *
+ * Java Native Interface (JNI)
+ * Java Virtual Machine Tool Interface (JVM TI)
+ * Java Debug Wire Protocol (JDWP)
+ *
+ *
+ * * @moduleGraph * @since 9 */ diff --git a/jdk/src/java.sql.rowset/share/classes/module-info.java b/jdk/src/java.sql.rowset/share/classes/module-info.java index 02413903f9c..fe9689aca6c 100644 --- a/jdk/src/java.sql.rowset/share/classes/module-info.java +++ b/jdk/src/java.sql.rowset/share/classes/module-info.java @@ -26,6 +26,8 @@ /** * Defines the JDBC RowSet API. * + * @uses javax.sql.rowset.RowSetFactory + * * @moduleGraph * @since 9 */ @@ -39,4 +41,3 @@ module java.sql.rowset { exports javax.sql.rowset.spi; uses javax.sql.rowset.RowSetFactory; } - diff --git a/jdk/src/java.sql/share/classes/module-info.java b/jdk/src/java.sql/share/classes/module-info.java index 1e232ec122e..f9531f5f4a8 100644 --- a/jdk/src/java.sql/share/classes/module-info.java +++ b/jdk/src/java.sql/share/classes/module-info.java @@ -26,6 +26,8 @@ /** * Defines the JDBC API. * + * @uses java.sql.Driver + * * @moduleGraph * @since 9 */ @@ -38,4 +40,3 @@ module java.sql { exports javax.transaction.xa; uses java.sql.Driver; } - diff --git a/jdk/src/jdk.attach/share/classes/module-info.java b/jdk/src/jdk.attach/share/classes/module-info.java index 29f0cd67a7f..2a320d0e91b 100644 --- a/jdk/src/jdk.attach/share/classes/module-info.java +++ b/jdk/src/jdk.attach/share/classes/module-info.java @@ -26,6 +26,8 @@ /** * Defines the attach API. * + * @uses com.sun.tools.attach.spi.AttachProvider + * * @moduleGraph * @since 9 */ @@ -39,4 +41,3 @@ module jdk.attach { uses com.sun.tools.attach.spi.AttachProvider; provides com.sun.tools.attach.spi.AttachProvider with sun.tools.attach.AttachProviderImpl; } - diff --git a/jdk/src/jdk.charsets/share/classes/module-info.java b/jdk/src/jdk.charsets/share/classes/module-info.java index 8d40e575d30..336ed77a2ab 100644 --- a/jdk/src/jdk.charsets/share/classes/module-info.java +++ b/jdk/src/jdk.charsets/share/classes/module-info.java @@ -24,9 +24,11 @@ */ /** - * {@link java.nio.charset.Charset Charset} provider for the charsets that + * Provides {@link java.nio.charset.Charset charsets} that * are not in {@code java.base} (mostly double byte and IBM charsets). * + * @provides java.nio.charset.spi.CharsetProvider + * * @moduleGraph * @since 9 */ @@ -34,4 +36,3 @@ module jdk.charsets { provides java.nio.charset.spi.CharsetProvider with sun.nio.cs.ext.ExtendedCharsets; } - diff --git a/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java b/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java index 82c2cde442e..0e79fdcb6c7 100644 --- a/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java +++ b/jdk/src/jdk.crypto.cryptoki/share/classes/module-info.java @@ -24,7 +24,9 @@ */ /** - * The SunPKCS11 security provider. + * Provides the implementation of the SunPKCS11 security provider. + * + * @provides java.security.Provider * * @moduleGraph * @since 9 @@ -34,4 +36,3 @@ module jdk.crypto.cryptoki { requires jdk.crypto.ec; provides java.security.Provider with sun.security.pkcs11.SunPKCS11; } - diff --git a/jdk/src/jdk.crypto.ec/share/classes/module-info.java b/jdk/src/jdk.crypto.ec/share/classes/module-info.java index 54f22b68609..9ba6e6195e3 100644 --- a/jdk/src/jdk.crypto.ec/share/classes/module-info.java +++ b/jdk/src/jdk.crypto.ec/share/classes/module-info.java @@ -24,7 +24,9 @@ */ /** - * The SunEC security provider. + * Provides the implementation of the SunEC security provider. + * + * @provides java.security.Provider * * @moduleGraph * @since 9 @@ -32,4 +34,3 @@ module jdk.crypto.ec { provides java.security.Provider with sun.security.ec.SunEC; } - diff --git a/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java b/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java index 0121f613e5e..6bbad56ca09 100644 --- a/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java +++ b/jdk/src/jdk.crypto.mscapi/windows/classes/module-info.java @@ -24,8 +24,9 @@ */ /** - * The SunMSCAPI security provider. + * Provides the implementation of the SunMSCAPI security provider. * + * @provides java.security.Provider * @moduleGraph * @since 9 */ diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java index 3d96987b3c5..e79f76bfb1e 100644 --- a/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java +++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/module-info.java @@ -24,8 +24,9 @@ */ /** - * The OracleUCrypto security provider. + * Provides the implementation of the OracleUCrypto security provider. * + * @provides java.security.Provider * @moduleGraph * @since 9 */ diff --git a/jdk/src/jdk.editpad/share/classes/module-info.java b/jdk/src/jdk.editpad/share/classes/module-info.java index 57077ed9008..78645303f78 100644 --- a/jdk/src/jdk.editpad/share/classes/module-info.java +++ b/jdk/src/jdk.editpad/share/classes/module-info.java @@ -24,7 +24,7 @@ */ /** - * Implementation of the edit pad service. + * Provides the implementation of the edit pad service used by {@link jdk.jshell}. * * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.httpserver/share/classes/module-info.java b/jdk/src/jdk.httpserver/share/classes/module-info.java index e6c7173e8db..c58aa6ef2e6 100644 --- a/jdk/src/jdk.httpserver/share/classes/module-info.java +++ b/jdk/src/jdk.httpserver/share/classes/module-info.java @@ -26,6 +26,8 @@ /** * Defines the JDK-specific API for HTTP server. * + * @uses com.sun.net.httpserver.spi.HttpServerProvider + * * @moduleGraph * @since 9 */ @@ -35,4 +37,3 @@ module jdk.httpserver { exports com.sun.net.httpserver.spi; uses com.sun.net.httpserver.spi.HttpServerProvider; } - diff --git a/jdk/src/jdk.jartool/share/classes/module-info.java b/jdk/src/jdk.jartool/share/classes/module-info.java index d852ee780d3..e866b74c418 100644 --- a/jdk/src/jdk.jartool/share/classes/module-info.java +++ b/jdk/src/jdk.jartool/share/classes/module-info.java @@ -25,7 +25,21 @@ /** * Defines tools for manipulating Java Archive (JAR) files, - * including the jar and jarsigner tools. + * including the {@index jar jar tool} and + * {@index jarsigner jarsigner tool} tools. + * + *

This module provides the equivalent of command-line access to + * jar via the {@link java.util.spi.ToolProvider ToolProvider} SPI. + * Instances of the tool can be obtained by calling + * {@link java.util.spi.ToolProvider#findFirst ToolProvider.findFirst} + * or the {@link java.util.ServiceLoader service loader} with the name + * {@code "jar"}. + * + *

+ *
Tool Guides: + *
{@extLink jar_tool_reference jar}, + * {@extLink jarsigner_tool_reference jarsigner} + *
* * @moduleGraph * @since 9 @@ -36,4 +50,3 @@ module jdk.jartool { provides java.util.spi.ToolProvider with sun.tools.jar.JarToolProvider; } - diff --git a/jdk/src/jdk.jcmd/share/classes/module-info.java b/jdk/src/jdk.jcmd/share/classes/module-info.java index 4cda0283f1b..9a5df56cdb5 100644 --- a/jdk/src/jdk.jcmd/share/classes/module-info.java +++ b/jdk/src/jdk.jcmd/share/classes/module-info.java @@ -24,8 +24,20 @@ */ /** - * Defines tools for diagnostics and troubleshooting a JVM, - * including the jcmd, jps, jstat and other diagnostics tools. + * Defines tools for diagnostics and troubleshooting a JVM + * such as the {@index jcmd jcmd tool}, {@index jps jps tool}, + * {@index jstat jstat tool} tools. + * + *
+ *
Tool Guides: + *
+ * {@extLink jcmd_tool_reference jcmd}, + * {@extLink jinfo_tool_reference jinfo}, + * {@extLink jmap_tool_reference jmap}, + * {@extLink jps_tool_reference jps}, + * {@extLink jstack_tool_reference jstack}, + * {@extLink jstat_tool_reference jstat} + *
* * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.jconsole/share/classes/module-info.java b/jdk/src/jdk.jconsole/share/classes/module-info.java index 7e1841a9bea..dd7671d04df 100644 --- a/jdk/src/jdk.jconsole/share/classes/module-info.java +++ b/jdk/src/jdk.jconsole/share/classes/module-info.java @@ -24,8 +24,16 @@ */ /** - * Defines the JMX graphical tool, jconsole, for monitoring and managing - * a running application. + * Defines the JMX graphical tool, {@index jconsole jconsole}, + * for monitoring and managing a running application. + * + *
+ *
Tool Guides: + *
{@extLink jconsole_tool_reference jconsole}, + * {@extLink using_jconsole Using JConsole} + *
+ * + * @uses com.sun.tools.jconsole.JConsolePlugin * * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.jdi/share/classes/module-info.java b/jdk/src/jdk.jdi/share/classes/module-info.java index e778655cf37..e7c45f37064 100644 --- a/jdk/src/jdk.jdi/share/classes/module-info.java +++ b/jdk/src/jdk.jdi/share/classes/module-info.java @@ -45,8 +45,7 @@ * Platform Debugger Architecture documentation for this release and the Java Platform Debugger Architecture * website. - *

- * Global Exceptions: + *

Global Exceptions

*

* This section documents exceptions which apply to the entire API and are thus * not documented on individual methods. @@ -103,6 +102,21 @@ * unloaded. * * + *

jdb

+ * + * {@index jdb jdb tool} is a simple command-line debugger provided + * in this module. + * + *
+ *
Tool Guides: + *
{@extLink jdb_tool_reference jdb} + *
+ * + * @provides com.sun.jdi.connect.Connector + * + * @uses com.sun.jdi.connect.Connector + * @uses com.sun.jdi.connect.spi.TransportService + * * @moduleGraph * @since 9 */ @@ -127,4 +141,3 @@ module jdk.jdi { com.sun.tools.jdi.SocketListeningConnector, com.sun.tools.jdi.SunCommandLineLauncher; } - diff --git a/jdk/src/jdk.jdwp.agent/share/classes/module-info.java b/jdk/src/jdk.jdwp.agent/share/classes/module-info.java index 82d4c86056a..c4f683ff801 100644 --- a/jdk/src/jdk.jdwp.agent/share/classes/module-info.java +++ b/jdk/src/jdk.jdwp.agent/share/classes/module-info.java @@ -24,11 +24,12 @@ */ /** - * Java Debug Wire Protocol. + * Provides the implementation of the Java Debug Wire Protocol (JDWP) agent. * * @moduleGraph * @since 9 + * @see JDWP Specification + * @see JDWP Transport Specification */ module jdk.jdwp.agent { } - diff --git a/jdk/src/jdk.jlink/share/classes/module-info.java b/jdk/src/jdk.jlink/share/classes/module-info.java index 510b4ac0bb1..140a7619d6f 100644 --- a/jdk/src/jdk.jlink/share/classes/module-info.java +++ b/jdk/src/jdk.jlink/share/classes/module-info.java @@ -24,7 +24,31 @@ */ /** - * Defines the Java linker tool, jlink. + * Defines the {@index jlink jlink tool} tool for creating run-time + * images, the {@index jmod jmod tool} tool for creating and manipulating + * JMOD files, and the {@index jimage jimage tool} tool for inspecting + * the JDK implementation-specific container file for classes and resources. + * + *

This module provides the equivalent of command-line access to the + * {@extLink jlink_tool_reference jlink} and + * {@extLink jmod_tool_reference jmod} tools via the + * {@link java.util.spi.ToolProvider ToolProvider} SPI. + * Instances of the tools can be obtained by calling + * {@link java.util.spi.ToolProvider#findFirst ToolProvider.findFirst} + * or the {@link java.util.ServiceLoader service loader} with the name + * {@code "jlink"} or {@code "jmod"} as appropriate. + * + *

{@extLink jimage_tool_reference jimage} only exists + * as a command-line tool, and does not provide any direct API. + * + *

+ *
Tool Guides: + *
{@extLink jlink_tool_reference jlink}, + * {@extLink jmod_tool_reference jmod}, + * {@extLink jimage_tool_reference jimage} + *
+ * + * @provides java.util.spi.ToolProvider * * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.jstatd/share/classes/module-info.java b/jdk/src/jdk.jstatd/share/classes/module-info.java index b3e3195c262..a56a45f036d 100644 --- a/jdk/src/jdk.jstatd/share/classes/module-info.java +++ b/jdk/src/jdk.jstatd/share/classes/module-info.java @@ -24,8 +24,13 @@ */ /** - * Defines the tool for starting a daemon for the jstat tool to monitor - * JVM statistics remotely. + * Defines the {@index jstatd jstatd tool} tool for starting a daemon + * for the jstat tool to monitor JVM statistics remotely. + * + *
+ *
Tool Guides: + *
{@extLink jstatd_tool_reference jstatd} + *
* * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.localedata/share/classes/module-info.java b/jdk/src/jdk.localedata/share/classes/module-info.java index ac27dc329c5..fadb091a92f 100644 --- a/jdk/src/jdk.localedata/share/classes/module-info.java +++ b/jdk/src/jdk.localedata/share/classes/module-info.java @@ -24,7 +24,7 @@ */ /** - * Locale data provider for locales other than {@linkplain java.util.Locale#US US locale}. + * Provides the locale data for locales other than {@linkplain java.util.Locale#US US locale}. * * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.management.agent/share/classes/module-info.java b/jdk/src/jdk.management.agent/share/classes/module-info.java index 81bccdb0e2b..921744822b6 100644 --- a/jdk/src/jdk.management.agent/share/classes/module-info.java +++ b/jdk/src/jdk.management.agent/share/classes/module-info.java @@ -24,7 +24,12 @@ */ /** - * Define the JMX management agent. + * Defines the JMX management agent. + * + *

This module allows a Java Virtual Machine to be monitored and managed + * via JMX API. See more information from the + * {@extLink monitoring_and_management_using_jmx_technology + * Monitoring and Management Using JMX} guide. * * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.naming.dns/share/classes/module-info.java b/jdk/src/jdk.naming.dns/share/classes/module-info.java index 71d3725440a..b1deb8aa8c7 100644 --- a/jdk/src/jdk.naming.dns/share/classes/module-info.java +++ b/jdk/src/jdk.naming.dns/share/classes/module-info.java @@ -24,8 +24,9 @@ */ /** - * DNS Java Naming provider. + * Provides the implementation of the DNS Java Naming provider. * + * @provides javax.naming.spi.InitialContextFactory * @moduleGraph * @since 9 */ @@ -38,4 +39,3 @@ module jdk.naming.dns { provides javax.naming.spi.InitialContextFactory with com.sun.jndi.dns.DnsContextFactory; } - diff --git a/jdk/src/jdk.naming.rmi/share/classes/module-info.java b/jdk/src/jdk.naming.rmi/share/classes/module-info.java index bba4557c935..289654c7c80 100644 --- a/jdk/src/jdk.naming.rmi/share/classes/module-info.java +++ b/jdk/src/jdk.naming.rmi/share/classes/module-info.java @@ -24,8 +24,9 @@ */ /** - * RMI Java Naming provider. + * Provides the implementation of the RMI Java Naming provider. * + * @provides javax.naming.spi.InitialContextFactory * @moduleGraph * @since 9 */ @@ -39,4 +40,3 @@ module jdk.naming.rmi { exports com.sun.jndi.url.rmi to java.naming; exports com.sun.jndi.rmi.registry to java.rmi; } - diff --git a/jdk/src/jdk.pack/share/classes/module-info.java b/jdk/src/jdk.pack/share/classes/module-info.java index f65a5ca61b7..cd04808ec2e 100644 --- a/jdk/src/jdk.pack/share/classes/module-info.java +++ b/jdk/src/jdk.pack/share/classes/module-info.java @@ -25,8 +25,15 @@ /** * Defines tools for transforming a JAR file into a compressed pack200 file - * and transforming a packed file into a JAR file, including the pack200, - * and unpack200 tools. + * and transforming a packed file into a JAR file, including the + * {@index pack200 pack200 tool} and + * {@index unpack200 unpack200 tool} tools. + * + *

+ *
Tool Guides: + *
{@extLink pack200_tool_reference pack200}, + * {@extLink unpack200_tool_reference unpack200} + *
* * @moduleGraph * @since 9 diff --git a/jdk/src/jdk.policytool/share/classes/module-info.java b/jdk/src/jdk.policytool/share/classes/module-info.java index 9a3818692f0..30117263f83 100644 --- a/jdk/src/jdk.policytool/share/classes/module-info.java +++ b/jdk/src/jdk.policytool/share/classes/module-info.java @@ -24,7 +24,13 @@ */ /** - * GUI tool for managing policy files. + * Defines the GUI tool for managing policy files + * called {@index policytool policytool}. + * + *
+ *
Tool Guides: + *
{@extLink policytool_tool_reference policytool} + *
* * @since 9 * @deprecated @@ -39,4 +45,3 @@ module jdk.policytool { requires java.security.jgss; requires jdk.security.jgss; } - diff --git a/jdk/src/jdk.rmic/share/classes/module-info.java b/jdk/src/jdk.rmic/share/classes/module-info.java index 03806a6bced..ba6ac3db30c 100644 --- a/jdk/src/jdk.rmic/share/classes/module-info.java +++ b/jdk/src/jdk.rmic/share/classes/module-info.java @@ -24,10 +24,15 @@ */ /** - * Defines the rmic compiler for generating stubs and skeletons using - * the Java Remote Method Protocol (JRMP) and + * Defines the {@index rmic rmic} compiler for generating stubs and + * skeletons using the Java Remote Method Protocol (JRMP) and * stubs and tie class files (IIOP protocol) for remote objects. * + *
+ *
Tool Guides: + *
{@extLink rmic_tool_reference rmic} + *
+ * * @moduleGraph * @since 9 */ diff --git a/jdk/src/jdk.security.auth/share/classes/module-info.java b/jdk/src/jdk.security.auth/share/classes/module-info.java index 59e9f996aaf..e1d322fb730 100644 --- a/jdk/src/jdk.security.auth/share/classes/module-info.java +++ b/jdk/src/jdk.security.auth/share/classes/module-info.java @@ -24,9 +24,10 @@ */ /** - * Contains the implementation of the javax.security.auth.* interfaces and - * various authentication modules. + * Provides the implementation of the {@code javax.security.auth.*} + * interfaces and various authentication modules. * + * @provides javax.security.auth.spi.LoginModule * @moduleGraph * @since 9 */ @@ -47,4 +48,3 @@ module jdk.security.auth { com.sun.security.auth.module.LdapLoginModule, com.sun.security.auth.module.NTLoginModule; } - diff --git a/jdk/src/jdk.zipfs/share/classes/module-info.java b/jdk/src/jdk.zipfs/share/classes/module-info.java index bcd281f459a..9c9503a7360 100644 --- a/jdk/src/jdk.zipfs/share/classes/module-info.java +++ b/jdk/src/jdk.zipfs/share/classes/module-info.java @@ -24,12 +24,17 @@ */ /** - * Zip file system provider. + * Provides the implementation of the zip file system provider. * + *

The zip file system provider treats a zip or JAR file as a file system + * and provides the ability to manipulate the contents of the file. + * The zip file system provider can be created by + * {@link java.nio.file.FileSystems#newFileSystem} if installed. + * + * @provides java.nio.file.spi.FileSystemProvider * @moduleGraph * @since 9 */ module jdk.zipfs { provides java.nio.file.spi.FileSystemProvider with jdk.nio.zipfs.ZipFileSystemProvider; } - From 57cdb9b6426992c176b76c7726c1401228b29fe6 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 7 Jun 2017 21:15:31 -0700 Subject: [PATCH 17/59] 8181639: Add tool and services information to module summary Reviewed-by: alanb, psandoz, lancea --- make/common/Modules.gmk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index d65adcd6aef..de979bc3b83 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -175,10 +175,13 @@ DOCS_MODULES += \ jdk.policytool \ jdk.rmic \ jdk.scripting.nashorn \ + jdk.scripting.nashorn.shell \ jdk.sctp \ jdk.security.auth \ jdk.security.jgss \ + jdk.xml.bind \ jdk.xml.dom \ + jdk.xml.ws \ jdk.zipfs \ # From a171cafd32541674ea53751320c82c55cff5c792 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 8 Jun 2017 11:24:46 +0200 Subject: [PATCH 18/59] 8181776: Move back specs to closed Reviewed-by: erikj --- .../share/specs/serialization/class.md | 362 -- .../share/specs/serialization/examples.md | 111 - .../share/specs/serialization/exceptions.md | 97 - .../specs/serialization/images/version.gif | Bin 3325 -> 0 bytes .../share/specs/serialization/index.md | 132 - .../share/specs/serialization/input.md | 672 ---- .../share/specs/serialization/output.md | 514 --- .../share/specs/serialization/protocol.md | 504 --- .../share/specs/serialization/security.md | 38 - .../share/specs/serialization/serial-arch.md | 575 --- .../share/specs/serialization/version.md | 304 -- .../share/specs/AWT_Native_Interface.html | 776 ---- .../share/specs/JVM-MANAGEMENT-MIB.mib | 3266 ----------------- 13 files changed, 7351 deletions(-) delete mode 100644 jdk/src/java.base/share/specs/serialization/class.md delete mode 100644 jdk/src/java.base/share/specs/serialization/examples.md delete mode 100644 jdk/src/java.base/share/specs/serialization/exceptions.md delete mode 100644 jdk/src/java.base/share/specs/serialization/images/version.gif delete mode 100644 jdk/src/java.base/share/specs/serialization/index.md delete mode 100644 jdk/src/java.base/share/specs/serialization/input.md delete mode 100644 jdk/src/java.base/share/specs/serialization/output.md delete mode 100644 jdk/src/java.base/share/specs/serialization/protocol.md delete mode 100644 jdk/src/java.base/share/specs/serialization/security.md delete mode 100644 jdk/src/java.base/share/specs/serialization/serial-arch.md delete mode 100644 jdk/src/java.base/share/specs/serialization/version.md delete mode 100644 jdk/src/java.desktop/share/specs/AWT_Native_Interface.html delete mode 100644 jdk/src/java.management/share/specs/JVM-MANAGEMENT-MIB.mib diff --git a/jdk/src/java.base/share/specs/serialization/class.md b/jdk/src/java.base/share/specs/serialization/class.md deleted file mode 100644 index 03b94b7d099..00000000000 --- a/jdk/src/java.base/share/specs/serialization/class.md +++ /dev/null @@ -1,362 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](input.html) | [NEXT](version.html)' -include-after: '[CONTENTS](index.html) | [PREV](input.html) | [NEXT](version.html)' - -title: 'Java Object Serialization Specification: 4 - Class Descriptors' ---- - -- [The ObjectStreamClass Class](#the-objectstreamclass-class) -- [Dynamic Proxy Class Descriptors](#dynamic-proxy-class-descriptors) -- [Serialized Form](#serialized-form) -- [The ObjectStreamField Class](#the-objectstreamfield-class) -- [Inspecting Serializable Classes](#inspecting-serializable-classes) -- [Stream Unique Identifiers](#stream-unique-identifiers) - -------------------------------------------------------------------------------- - -## 4.1 The ObjectStreamClass Class - -The `ObjectStreamClass` provides information about classes that are saved in a -Serialization stream. The descriptor provides the fully-qualified name of the -class and its serialization version UID. A `SerialVersionUID` identifies the -unique original class version for which this class is capable of writing -streams and from which it can read. - -``` -package java.io; - -public class ObjectStreamClass -{ - public static ObjectStreamClass lookup(Class cl); - - public static ObjectStreamClass lookupAny(Class cl); - - public String getName(); - - public Class forClass(); - - public ObjectStreamField[] getFields(); - - public long getSerialVersionUID(); - - public String toString(); -} -``` - -The `lookup` method returns the `ObjectStreamClass` descriptor for the -specified class in the virtual machine. If the class has defined -`serialVersionUID` it is retrieved from the class. If the `serialVersionUID` is -not defined by the class, it is computed from the definition of the class in -the virtual machine. *I*f the specified class is not serializable or -externalizable, *null* is returned. - -The `lookupAny` method behaves like the `lookup` method, except that it returns -the descriptor for any class, regardless of whether it implements -`Serializable`. The `serialVersionUID` of a class that does not implement -`Serializable` is *0L.* - -The `getName` method returns the name of the class, in the same format that is -used by the `Class.getName` method. - -The `forClass` method returns the `Class` in the local virtual machine if one -was found by `ObjectInputStream.resolveClass` method. Otherwise, it returns -*null*. - -The `getFields` method returns an array of `ObjectStreamField` objects that -represent the serializable fields of this class. - -The `getSerialVersionUID` method returns the `serialVersionUID` of this class. -Refer to [Section 4.6, "Stream Unique -Identifiers"](#stream-unique-identifiers). If not specified by the class, the -value returned is a hash computed from the class's name, interfaces, methods, -and fields using the Secure Hash Algorithm (SHA) as defined by the National -Institute of Standards. - -The `toString` method returns a printable representation of the class -descriptor including the name of the class and the `serialVersionUID`. - -## 4.2 Dynamic Proxy Class Descriptors - -ObjectStreamClass descriptors are also used to provide information about -dynamic proxy classes (e.g., classes obtained via calls to the getProxyClass -method of java.lang.reflect.Proxy) saved in a serialization stream. A dynamic -proxy class itself has no serializable fields and a serialVersionUID of 0L. In -other words, when the Class object for a dynamic proxy class is passed to the -static lookup method of ObjectStreamClass, the returned ObjectStreamClass -instance will have the following properties: - -- Invoking its getSerialVersionUID method will return 0L. -- Invoking its getFields method will return an array of length zero. -- Invoking its getField method with any String argument will return null. - -## 4.3 Serialized Form - -The serialized form of an ObjectStreamClass instance depends on whether or not -the Class object it represents is serializable, externalizable, or a dynamic -proxy class. - -When an `ObjectStreamClass` instance that does not represent a dynamic proxy -class is written to the stream, it writes the class name and -`serialVersionUID`, flags, and the number of fields. Depending on the class, -additional information may be written: - -- For non-serializable classes, the number of fields is always zero. Neither - the `SC_SERIALIZABLE` nor the `SC_EXTERNALIZABLE` flag bits are set. - -- For serializable classes, the `SC_SERIALIZABLE` flag is set, the number of - fields counts the number of serializable fields and is followed by a - descriptor for each serializable field. The descriptors are written in - canonical order. The descriptors for primitive typed fields are written - first sorted by field name followed by descriptors for the object typed - fields sorted by field name. The names are sorted using `String.compareTo`. - For details of the format, refer to [Section 6.4, "Grammar for the Stream - Format"](protocol.html#grammar-for-the-stream-format). - -- For externalizable classes, flags includes the `SC_EXTERNALIZABLE` flag, - and the number of fields is always zero. - -- For enum types, flags includes the `SC_ENUM` flag, and the number of fields - is always zero. - -When an ObjectOutputStream serializes the ObjectStreamClass descriptor for a -dynamic proxy class, as determined by passing its Class object to the -isProxyClass method of java.lang.reflect.Proxy, it writes the number of -interfaces that the dynamic proxy class implements, followed by the interface -names. Interfaces are listed in the order that they are returned by invoking -the getInterfaces method on the Class object of the dynamic proxy class. - -The serialized representations of ObjectStreamClass descriptors for dynamic -proxy classes and non-dynamic proxy classes are differentiated through the use -of different typecodes (`TC_PROXYCLASSDESC` and `TC_CLASSDESC`, respectively); -for a more detailed specification of the grammar, see [Section 6.4, "Grammar -for the Stream Format"](protocol.html#grammar-for-the-stream-format). - -## 4.4 The ObjectStreamField Class - -An `ObjectStreamField` represents a serializable field of a serializable class. -The serializable fields of a class can be retrieved from the -`ObjectStreamClass`. - -The special static serializable field, `serialPersistentFields`, is an array of -`ObjectStreamField` components that is used to override the default -serializable fields. - -``` -package java.io; - -public class ObjectStreamField implements Comparable { - - public ObjectStreamField(String fieldName, - Class fieldType); - - public ObjectStreamField(String fieldName, - Class fieldType, - boolean unshared); - - public String getName(); - - public Class getType(); - - public String getTypeString(); - - public char getTypeCode(); - - public boolean isPrimitive(); - - public boolean isUnshared(); - - public int getOffset(); - - protected void setOffset(int offset); - - public int compareTo(Object obj); - - public String toString(); -} -``` - -`ObjectStreamField` objects are used to specify the serializable fields of a -class or to describe the fields present in a stream. Its constructors accept -arguments describing the field to represent: a string specifying the name of -the field, a `Class` object specifying the type of the field, and a `boolean` -flag (implicitly `false` for the two-argument constructor) indicating whether -or not values of the represented field should be read and written as "unshared" -objects if default serialization/deserialization is in use (see the -descriptions of the `ObjectInputStream.readUnshared` and -`ObjectOutputStream.writeUnshared` methods in [Section 3.1, "The -ObjectInputStream Class"](input.html#the-objectinputstream-class) and [Section -2.1, "The ObjectOutputStream Class"](output.html#the-objectoutputstream-class), -respectively). - -The `getName` method returns the name of the serializable field. - -The `getType` method returns the type of the field. - -The `getTypeString` method returns the type signature of the field. - -The `getTypeCode` method returns a character encoding of the field type ('`B`' -for `byte`, '`C`' for `char`, '`D`' for `double`, '`F`' for `float`, '`I`' for -`int`, '`J`' for `long`, '`L`' for non-array object types, '`S`' for `short`, -'`Z`' for `boolean`, and '`[`' for arrays). - -The `isPrimitive` method returns `true` if the field is of primitive type, or -`false` otherwise. - -The `isUnshared` method returns `true` if values of the field should be written -as "unshared" objects, or `false` otherwise. - -The `getOffset` method returns the offset of the field's value within instance -data of the class defining the field. - -The `setOffset` method allows `ObjectStreamField` subclasses to modify the -offset value returned by the `getOffset` method. - -The `compareTo` method compares `ObjectStreamFields` for use in sorting. -Primitive fields are ranked as "smaller" than non-primitive fields; fields -otherwise equal are ranked alphabetically. - -The `toString` method returns a printable representation with name and type. - -## 4.5 Inspecting Serializable Classes - -The program *serialver* can be used to find out if a class is serializable and -to get its `serialVersionUID`. - -When invoked on the command line with one or more class names, serialver prints -the `serialVersionUID` for each class in a form suitable for copying into an -evolving class. When invoked with no arguments, it prints a usage line. - -## 4.6 Stream Unique Identifiers - -Each versioned class must identify the original class version for which it is -capable of writing streams and from which it can read. For example, a versioned -class must declare: - -``` -private static final long serialVersionUID = 3487495895819393L; -``` - -The stream-unique identifier is a 64-bit hash of the class name, interface -class names, methods, and fields. The value must be declared in all versions of -a class except the first. It may be declared in the original class but is not -required. The value is fixed for all compatible classes. If the SUID is not -declared for a class, the value defaults to the hash for that class. The -`serialVersionUID` for dynamic proxy classes and enum types always have the -value *0L*. Array classes cannot declare an explicit `serialVersionUID`, so -they always have the default computed value, but the requirement for matching -`serialVersionUID` values is waived for array classes. - -**Note:** It is strongly recommended that all serializable classes explicitly -declare `serialVersionUID` values, since the default `serialVersionUID` -computation is highly sensitive to class details that may vary depending on -compiler implementations, and can thus result in unexpected `serialVersionUID` -conflicts during deserialization, causing deserialization to fail. - -The initial version of an `Externalizable` class must output a stream data -format that is extensible in the future. The initial version of the method -`readExternal` has to be able to read the output format of all future versions -of the method `writeExternal`. - -The `serialVersionUID` is computed using the signature of a stream of bytes -that reflect the class definition. The National Institute of Standards and -Technology (NIST) Secure Hash Algorithm (SHA-1) is used to compute a signature -for the stream. The first two 32-bit quantities are used to form a 64-bit hash. -A `java.lang.DataOutputStream` is used to convert primitive data types to a -sequence of bytes. The values input to the stream are defined by the Java -Virtual Machine (VM) specification for classes. Class modifiers may include the -`ACC_PUBLIC`, `ACC_FINAL`, `ACC_INTERFACE`, and `ACC_ABSTRACT` flags; other -flags are ignored and do not affect `serialVersionUID` computation. Similarly, -for field modifiers, only the `ACC_PUBLIC`, `ACC_PRIVATE`, `ACC_PROTECTED`, -`ACC_STATIC`, `ACC_FINAL`, `ACC_VOLATILE`, and `ACC_TRANSIENT` flags are used -when computing `serialVersionUID` values. For constructor and method modifiers, -only the `ACC_PUBLIC`, `ACC_PRIVATE`, `ACC_PROTECTED`, `ACC_STATIC`, -`ACC_FINAL`, `ACC_SYNCHRONIZED`, `ACC_NATIVE`, `ACC_ABSTRACT` and `ACC_STRICT` -flags are used. Names and descriptors are written in the format used by the -`java.io.DataOutputStream.writeUTF` method. - -The sequence of items in the stream is as follows: - -1. The class name. - -2. The class modifiers written as a 32-bit integer. - -3. The name of each interface sorted by name. - -4. For each field of the class sorted by field name (except `private static` - and `private transient` fields: - - a. The name of the field. - - b. The modifiers of the field written as a 32-bit integer. - - c. The descriptor of the field. - -5. If a class initializer exists, write out the following: - - a. The name of the method, ``. - - b. The modifier of the method, `java.lang.reflect.Modifier.STATIC`, - written as a 32-bit integer. - - c. The descriptor of the method, `()V`. - -6. For each non-`private` constructor sorted by method name and signature: - - a. The name of the method, ``. - - b. The modifiers of the method written as a 32-bit integer. - - c. The descriptor of the method. - -7. For each non-`private` method sorted by method name and signature: - - a. The name of the method. - - b. The modifiers of the method written as a 32-bit integer. - - c. The descriptor of the method. - -8. The SHA-1 algorithm is executed on the stream of bytes produced by - `DataOutputStream` and produces five 32-bit values `sha[0..4]`. - -9. The hash value is assembled from the first and second 32-bit values of the - SHA-1 message digest. If the result of the message digest, the five 32-bit - words `H0 H1 H2 H3 H4`, is in an array of five `int` values named `sha`, - the hash value would be computed as follows: - -``` - long hash = ((sha[0] >>> 24) & 0xFF) | - ((sha[0] >>> 16) & 0xFF) << 8 | - ((sha[0] >>> 8) & 0xFF) << 16 | - ((sha[0] >>> 0) & 0xFF) << 24 | - ((sha[1] >>> 24) & 0xFF) << 32 | - ((sha[1] >>> 16) & 0xFF) << 40 | - ((sha[1] >>> 8) & 0xFF) << 48 | - ((sha[1] >>> 0) & 0xFF) << 56; -``` - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/examples.md b/jdk/src/java.base/share/specs/serialization/examples.md deleted file mode 100644 index 3817fca2889..00000000000 --- a/jdk/src/java.base/share/specs/serialization/examples.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](exceptions.html) | NEXT' -include-after: '[CONTENTS](index.html) | [PREV](exceptions.html) | NEXT' - -title: 'Java Object Serialization Specification: C - Example of Serializable Fields' ---- - -- [Example Alternate Implementation of - java.io.File](#c.1-example-alternate-implementation-of-java.io.file) - -------------------------------------------------------------------------------- - -## C.1 Example Alternate Implementation of java.io.File - -This appendix provides a brief example of how an existing class could be -specified and implemented to interoperate with the existing implementation but -without requiring the same assumptions about the representation of the file -name as a *String*. - -The system class `java.io.File` represents a filename and has methods for -parsing, manipulating files and directories by name. It has a single private -field that contains the current file name. The semantics of the methods that -parse paths depend on the current path separator which is held in a static -field. This path separator is part of the serialized state of a file so that -file name can be adjusted when read. - -The serialized state of a `File` object is defined as the serializable fields -and the sequence of data values for the file. In this case, there is one of -each. - -``` -Serializable Fields: - String path; // path name with embedded separators -Serializable Data: - char // path name separator for path name -``` - -An alternate implementation might be defined as follows: - -``` -class File implements java.io.Serializable { - ... - private String[] pathcomponents; - // Define serializable fields with the ObjectStreamClass - - /** - * @serialField path String - * Path components separated by separator. - */ - - private static final ObjectStreamField[] serialPersistentFields - = { new ObjectStreamField("path", String.class) }; - ... - /** - * @serialData Default fields followed by separator character. - */ - - private void writeObject(ObjectOutputStream s) - throws IOException - { - ObjectOutputStream.PutField fields = s.putFields(); - StringBuffer str = new StringBuffer(); - for(int i = 0; i < pathcomponents; i++) { - str.append(separator); - str.append(pathcomponents[i]); - } - fields.put("path", str.toString()); - s.writeFields(); - s.writeChar(separatorChar); // Add the separator character - } - ... - - private void readObject(ObjectInputStream s) - throws IOException - { - ObjectInputStream.GetField fields = s.readFields(); - String path = (String)fields.get("path", null); - ... - char sep = s.readChar(); // read the previous separator char - - // parse path into components using the separator - // and store into pathcomponents array. - } -} -``` - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/exceptions.md b/jdk/src/java.base/share/specs/serialization/exceptions.md deleted file mode 100644 index a476d62c8a8..00000000000 --- a/jdk/src/java.base/share/specs/serialization/exceptions.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](security.html) | [NEXT](examples.html)' -include-after: '[CONTENTS](index.html) | [PREV](security.html) | [NEXT](examples.html)' - -title: 'Java Object Serialization Specification: B - Exceptions In Object Serialization' ---- - -------------------------------------------------------------------------------- - -All exceptions thrown by serialization classes are subclasses of -`ObjectStreamException` which is a subclass of `IOException`. - -### `ObjectStreamException` - -Superclass of all serialization exceptions. - -### `InvalidClassException` - -Thrown when a class cannot be used to restore objects for any of these reasons: - -- The class does not match the serial version of the class in the stream. -- The class contains fields with invalid primitive data types. -- The `Externalizable` class does not have a public no-arg constructor. -- The `Serializable` class can not access the no-arg constructor of its - closest non-Serializable superclass. - -### `NotSerializableException` - -Thrown by a `readObject` or `writeObject` method to terminate serialization or -deserialization. - -### `StreamCorruptedException` - -Thrown: - -- If the stream header is invalid. -- If control information not found. -- If control information is invalid. -- JDK 1.1.5 or less attempts to call `readExternal` on a `PROTOCOL_VERSION_2` - stream. - -### `NotActiveException` - -Thrown if `writeObject` state is invalid within the following -`ObjectOutputStream` methods: - -- `defaultWriteObject` -- `putFields` -- `writeFields` - -Thrown if `readObject` state is invalid within the following -`ObjectInputStream` methods: - -- `defaultReadObject` -- `readFields` -- `registerValidation` - -### `InvalidObjectException` - -Thrown when a restored object cannot be made valid. - -### `OptionalDataException` - -Thrown by `readObject` when there is primitive data in the stream and an object -is expected. The length field of the exception indicates the number of bytes -that are available in the current block. - -### `WriteAbortedException` - -Thrown when reading a stream terminated by an exception that occurred while the -stream was being written. - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/images/version.gif b/jdk/src/java.base/share/specs/serialization/images/version.gif deleted file mode 100644 index 79be14380d4fdb47fe961bd8cadb207aa73f5cdb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3325 zcmeH``8yQ;7RNs`s;`tK6_QjWhLEz8x)R1($ub&S_NB39tjSVLls!usCHppGW|)~Q zQ@&)Mv2Ph6l`UgQh?vXwKF|FR?r-<}aGvM$`Mf``_c`ZzjvicBRmCA6A_iFpd%f!bVE232o{~)iG!|IG z0DVOO{S2NZfx1QjhydUK!0z$>1N(6USn2E@g#mB@2WJ3?1^!8py+_sm%Ao+NE@9-f ztAZHqCJyRu5etAj0thIA%ym$s2n1*#asgOH0KfsL|FC$$Of>*m0K{`Zcp5?Zo-qdp z-~>PhfU}-J2mlxW?f@L#WeI>Y09*n<2?)~w<_Gw*1ca3UrWXt+?RF_73<<+Pzz2W< zY#~4k06%U5YS^gJw^_PZR#aav4~fY2Ht*7KCPPoQ`j#HWHykoFYzG2qXjm za1-pA>{dPjz;Ce2+8ymbO@o;j0Db}qRRER%q!rMhV95?#EZ@~OE&<{NfLj7U${T=# zKn#F<@c;OqPvF9y!`?0c&KuxqUG6sZJt_Xzp1u6GIs@@WqD51AzD|D-_NQt?<=?* zt&6etnD4)3r<5MQk3=pWaf{MvRQX?^th zkc4hmXn+P{)Q_+ei#Ng6&8=|Xni`;LuDG2 zeohM-s2REMlGo~UV{I~A*(vw=*~_(IK3Q9c0s zdgo_})YNkstyT$)jUVj$WBZ*Tag6X>QAUub@alMmL-Rq`Z0Ab|N373Vm{?RN_w2b8 zTj{5gnT|PXMQL}*t;rz)1hpY;Z>~*A*GL03$y}LBPbJ@Gp+mmK^JUFC6=w2mI!8pJ ztV@a*PlPk_c18k%>@%OX!>0?1Kb4eXpVYLvVyGS^^96Cr!Dn-?Bz#H^h#(Akg+J_t zd6YJ-#fiV5+#9uj*#|Lnt{7j@cXYTc7MfY$$TOUe?{ucxR}Dp-#8W4sYH#1E&&^C% z4-*fSMoBysmX0%WR!jK+@J(k;2KOT`^^G0Vlyb|%%Gm(4bdl*Hb}HgiQXQ&3`t zbJ7iMxzl!D(zUaQj=F>cKO4vB$Q45sl9v@@|IZ&Ok)+>sgzg)V1>qi@6JsxW)6U8s z?X&+^J*iIxq4q0Kbll?WAX3G^YREno`>PXn%NX74Dvu?5dU`6MNA>HuReWxDZKpEP zLl%KMpEW1xf!^Wl1+$4L!TSM|fu|ETZgt7!s7@yEeh&KjP{t$}m1?J@`1PeXDtOwo zg==#vD^WCLwlH)jcuqW?QDcIqvEIxRy;W@&uC^r9F4QdId=_bzr!$V0O-`D=> z>9ecdrcbeJc0QG{>)Fzic60kwHK7TN2-0=m;1GbDvVzm9&bFJ!Ja*U|LM*B%c zPIaCgdh|;UhtE3tYWxiPV^028T<^%Qj@MM`lua_-oiGLU1>G^I>$ySbLZy#0-Qqi{ z`$XKL^i@{*e5LgM81TPXY5X}`?reN`WF%bZhUB1EoN3jF<6z9+(r;y*k!c7a{4kko zpXi5*Prj_SHge4)a=&50lJfaX~rbX;z+>&);6GwHFDnSh4cX7HW$|Zco~9# z7|aU~sBnGgdE1i95)SPue^4Q#_{$njT@zXkt$ZJ^TJx!A$`-Eig+Wdhr) z{Hnwu#H>C#`FX_;K3FJX-G@wSLYBK!Y$Ccv*9e8&&4@ap$$UgpJq~X=4FR9OAvMt>=D~_;~CNF zSzNMoU?udkcS!%7(K`nDJ>sk6-BWcFbuktVEQy>0ydy?I=#7SVW_;VCuy*}8#hSQ% zgjGHf#y-k$lIe}*%aeL1|C9)Znrio5Dv_R2>QQZReOaJ!P+971OLYsZkZ@^#(3Bf= zjxwOR9J?IUI~cXn*7{K*Jam@s{kK9A1NzezkF2mn1%I?b744Y9>Rh;L77w} zo9%zHnuA2D`|^wBGIHqdVoHYZ$VZ&ZR<_8w>nid%6wBAuc;0$+bCAlY#s$*nZMQau zKJbt$V~u~@JGnL7YCjj$kgJM}7d-B6eHvzv$rSnmDs*dff`>wFF=qL_ z+G5U_P-=$gEOhPG7)#e?t$*LQLzcKvv)hE%3Zoa_1cgL|@Hn4j3tzkT<&_b#x<7&y zfUmrVK>ogzTF*~f@-OMQw#MbxIRAr?Fdsi^xVcfagLalpiD%vszuHf=5be3`l6?pM zMX-Z(_`Vc(*-b$Ms{ZSjxDJsxteReWrq*Ry+k@NF*YSaLbHh>-2yE6T%&H(qPV&s@ z`WXp9i}(bTOfmaaiPn1h+jF#lVm+*RzcsO^9`_65fL-vh)1W`qFcQGWG0Z8MReU&! zG(+ZBg`usw-s2n6#xS@VUg;^VPCnkX+VC(%MzW{c2iJ_ccz9g(yT3Uuw_UU4h{{O0 zxjO}~(w!c5d3)=8hO6Og^^x^kSL$3%w?2*TtWmq_S%FJF3w%h%vV~e+ZK6F#0-wYl{D>weC7GBZCMBACZ;R7nG*bPc|J#RBI9>WLN$z3 zCjH&oG`M?9qB84{=+|wYg#q{UpzMtLxsNO7?q>vF5e(cXg+hG~1H%urdIQ{w{8$wK z1H&?bEfG9IDA)m`7prJwOGN*)WP)p?4&{;l^n;fxk9spg!W@DvfB8mFM><-bcPg@W zca3c56_<03Qb-Lq(7S(P#%Et|@NvoTWLE<*E4ic7!6*KDl>No`OO;9anpcIMN3?R_ z_*zKn0oi@TFoOp=gp4SpP|Q8m7$>V3m!KH8%oq=9jMs1sY9q!+DArFk_JLI_Iw&^C K4F!P!jei3m3YZ4~ diff --git a/jdk/src/java.base/share/specs/serialization/index.md b/jdk/src/java.base/share/specs/serialization/index.md deleted file mode 100644 index 1ad49f7cbdc..00000000000 --- a/jdk/src/java.base/share/specs/serialization/index.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: 'CONTENTS | PREV | [NEXT](serial-arch.html)' -include-after: 'CONTENTS | PREV | [NEXT](serial-arch.html)' - -title: 'Java Object Serialization Specification: Contents' ---- - -------------------------------------------------------------------------------- - -## Table of Contents - -### 1 [System Architecture](serial-arch.html) - -- 1.1 [Overview](serial-arch.html#overview) -- 1.2 [Writing to an Object - Stream](serial-arch.html#writing-to-an-object-stream) -- 1.3 [Reading from an Object - Stream](serial-arch.html#reading-from-an-object-stream) -- 1.4 [Object Streams as - Containers](serial-arch.html#object-streams-as-containers) -- 1.5 [Defining Serializable Fields for a - Class](serial-arch.html#defining-serializable-fields-for-a-class) -- 1.6 [Documenting Serializable Fields and Data for a - Class](serial-arch.html#documenting-serializable-fields-and-data-for-a-class) -- 1.7 [Accessing Serializable Fields of a - Class](serial-arch.html#accessing-serializable-fields-of-a-class) -- 1.8 [The ObjectOutput - Interface](serial-arch.html#the-objectoutput-interface) -- 1.9 [The ObjectInput Interface](serial-arch.html#the-objectinput-interface) -- 1.10 [The Serializable - Interface](serial-arch.html#the-serializable-interface) -- 1.11 [The Externalizable - Interface](serial-arch.html#the-externalizable-interface) -- 1.12 [Serialization of Enum - Constants](serial-arch.html#serialization-of-enum-constants) -- 1.13 [Protecting Sensitive - Information](serial-arch.html#protecting-sensitive-information) - -### 2 [Object Output Classes](output.html) - -- 2.1 [The ObjectOutputStream - Class](output.html#the-objectoutputstream-class) -- 2.2 [The ObjectOutputStream.PutField - Class](output.html#the-objectoutputstream.putfield-class) -- 2.3 [The writeObject Method](output.html#the-writeobject-method) -- 2.4 [The writeExternal Method](output.html#the-writeexternal-method) -- 2.5 [The writeReplace Method](output.html#the-writereplace-method) -- 2.6 [The useProtocolVersion - Method](output.html#the-useprotocolversion-method) - -### 3 [Object Input Classes](input.html) - -- 3.1 [The ObjectInputStream Class](input.html#the-objectinputstream-class) -- 3.2 [The ObjectInputStream.GetField - Class](input.html#the-objectinputstream.getfield-class) -- 3.3 [The ObjectInputValidation - Interface](input.html#the-objectinputvalidation-interface) -- 3.4 [The readObject Method](input.html#the-readobject-method) -- 3.5 [The readObjectNoData Method](input.html#the-readobjectnodata-method) -- 3.6 [The readExternal Method](input.html#the-readexternal-method) -- 3.7 [The readResolve Method](input.html#the-readresolve-method) - -### 4 [Class Descriptors](class.html) - -- 4.1 [The ObjectStreamClass Class](class.html#the-objectstreamclass-class) -- 4.2 [Dynamic Proxy Class - Descriptors](class.html#dynamic-proxy-class-descriptors) -- 4.3 [Serialized Form](class.html#serialized-form) -- 4.4 [The ObjectStreamField Class](class.html#the-objectstreamfield-class) -- 4.5 [Inspecting Serializable - Classes](class.html#inspecting-serializable-classes) -- 4.6 [Stream Unique Identifiers](class.html#stream-unique-identifiers) - -### 5 [Versioning of Serializable Objects](version.html) - -- 5.1 [Overview](version.html#overview) -- 5.2 [Goals](version.html#goals) -- 5.3 [Assumptions](version.html#assumptions) -- 5.4 [Who's Responsible for Versioning of - Streams](version.html#whos-responsible-for-versioning-of-streams) -- 5.5 [Compatible Java Type - Evolution](version.html#compatible-java-type-evolution) -- 5.6 [Type Changes Affecting - Serialization](version.html#type-changes-affecting-serialization) - - 5.6.1 [Incompatible Changes](version.html#incompatible-changes) - - 5.6.2 [Compatible Changes](version.html#compatible-changes) - -### 6 [Object Serialization Stream Protocol](protocol.html) - -- 6.1 [Overview](protocol.html#overview) -- 6.2 [Stream Elements](protocol.html#stream-elements) -- 6.3 [Stream Protocol Versions](protocol.html#stream-protocol-versions) -- 6.4 [Grammar for the Stream - Format](protocol.html#grammar-for-the-stream-format) - - 6.4.1 [Rules of the Grammar](protocol.html#rules-of-the-grammar) - - 6.4.2 [Terminal Symbols and - Constants](protocol.html#terminal-symbols-and-constants) - -### A [Security in Object Serialization](security.html) - -### B [Exceptions In Object Serialization](exceptions.html) - -### C [Example of Serializable Fields](examples.html) - -- [C.1 Example Alternate Implementation of - `java.io.File`](examples.html#c.1-example-alternate-implementation-of-java.io.file) - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/input.md b/jdk/src/java.base/share/specs/serialization/input.md deleted file mode 100644 index dd3e2b21a35..00000000000 --- a/jdk/src/java.base/share/specs/serialization/input.md +++ /dev/null @@ -1,672 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](output.html) | [NEXT](class.html)' -include-after: '[CONTENTS](index.html) | [PREV](output.html) | [NEXT](class.html)' - -title: 'Java Object Serialization Specification: 3 - Object Input Classes' ---- - -- [The ObjectInputStream Class](#the-objectinputstream-class) -- [The ObjectInputStream.GetField - Class](#the-objectinputstream.getfield-class) -- [The ObjectInputValidation Interface](#the-objectinputvalidation-interface) -- [The readObject Method](#the-readobject-method) -- [The readExternal Method](#the-readexternal-method) -- [The readResolve Method](#the-readresolve-method) - -------------------------------------------------------------------------------- - -## 3.1 The ObjectInputStream Class - -Class `ObjectInputStream` implements object deserialization. It maintains the -state of the stream including the set of objects already deserialized. Its -methods allow primitive types and objects to be read from a stream written by -`ObjectOutputStream`. It manages restoration of the object and the objects that -it refers to from the stream. - -``` -package java.io; - -public class ObjectInputStream - extends InputStream - implements ObjectInput, ObjectStreamConstants -{ - public ObjectInputStream(InputStream in) - throws StreamCorruptedException, IOException; - - public final Object readObject() - throws OptionalDataException, ClassNotFoundException, - IOException; - - public Object readUnshared() - throws OptionalDataException, ClassNotFoundException, - IOException; - - public void defaultReadObject() - throws IOException, ClassNotFoundException, - NotActiveException; - - public GetField readFields() - throws IOException; - - public synchronized void registerValidation( - ObjectInputValidation obj, int prio) - throws NotActiveException, InvalidObjectException; - - protected ObjectStreamClass readClassDescriptor() - throws IOException, ClassNotFoundException; - - protected Class resolveClass(ObjectStreamClass v) - throws IOException, ClassNotFoundException; - - protected Object resolveObject(Object obj) - throws IOException; - - protected boolean enableResolveObject(boolean enable) - throws SecurityException; - - protected void readStreamHeader() - throws IOException, StreamCorruptedException; - - public int read() throws IOException; - - public int read(byte[] data, int offset, int length) - throws IOException - - public int available() throws IOException; - - public void close() throws IOException; - - public boolean readBoolean() throws IOException; - - public byte readByte() throws IOException; - - public int readUnsignedByte() throws IOException; - - public short readShort() throws IOException; - - public int readUnsignedShort() throws IOException; - - public char readChar() throws IOException; - - public int readInt() throws IOException; - - public long readLong() throws IOException; - - public float readFloat() throws IOException; - - public double readDouble() throws IOException; - - public void readFully(byte[] data) throws IOException; - - public void readFully(byte[] data, int offset, int size) - throws IOException; - - public int skipBytes(int len) throws IOException; - - public String readLine() throws IOException; - - public String readUTF() throws IOException; - - // Class to provide access to serializable fields. - static abstract public class GetField - { - public ObjectStreamClass getObjectStreamClass(); - - public boolean defaulted(String name) - throws IOException, IllegalArgumentException; - - public char get(String name, char default) - throws IOException, IllegalArgumentException; - - public boolean get(String name, boolean default) - throws IOException, IllegalArgumentException; - - public byte get(String name, byte default) - throws IOException, IllegalArgumentException; - - public short get(String name, short default) - throws IOException, IllegalArgumentException; - - public int get(String name, int default) - throws IOException, IllegalArgumentException; - - public long get(String name, long default) - throws IOException, IllegalArgumentException; - - public float get(String name, float default) - throws IOException, IllegalArgumentException; - - public double get(String name, double default) - throws IOException, IllegalArgumentException; - - public Object get(String name, Object default) - throws IOException, IllegalArgumentException; - } - - protected ObjectInputStream() - throws StreamCorruptedException, IOException; - - protected readObjectOverride() - throws OptionalDataException, ClassNotFoundException, - IOException; -} -``` - -The single-argument `ObjectInputStream` constructor requires an `InputStream`. -The constructor calls `readStreamHeader` to read and verifies the header and -version written by the corresponding `ObjectOutputStream.writeStreamHeader` -method. If a security manager is installed, this constructor checks for the -`"enableSubclassImplementation"` `SerializablePermission` when invoked directly -or indirectly by the constructor of a subclass which overrides the `readFields` -and/or `readUnshared` methods. - -**Note:** The `ObjectInputStream` constructor blocks until it completes reading -the serialization stream header. Code which waits for an `ObjectInputStream` to -be constructed before creating the corresponding `ObjectOutputStream` for that -stream will deadlock, since the `ObjectInputStream` constructor will block -until a header is written to the stream, and the header will not be written to -the stream until the `ObjectOutputStream` constructor executes. This problem -can be resolved by creating the `ObjectOutputStream` before the -`ObjectInputStream`, or otherwise removing the timing dependency between -completion of `ObjectInputStream` construction and the creation of the -`ObjectOutputStream`. - -The `readObject` method is used to deserialize an object from the stream. It -reads from the stream to reconstruct an object. - -1. If the `ObjectInputStream` subclass is overriding the implementation, call - the `readObjectOverride` method and return. Reimplementation is described - at the end of this section. - -2. If a block data record occurs in the stream, throw a `BlockDataException` - with the number of available bytes. - -3. If the object in the stream is null, return null. - -4. If the object in the stream is a handle to a previous object, return the - object. - -5. If the object in the stream is a `Class`, read its `ObjectStreamClass` - descriptor, add it and its handle to the set of known objects, and return - the corresponding `Class` object. - -6. If the object in the stream is an `ObjectStreamClass`, read in its data - according to the formats described in [Section 4.3, "Serialized - Form"](class.html#serialized-form). Add it and its handle to the set of - known objects. In versions 1.3 and later of the Java 2 SDK, Standard - Edition, the `readClassDescriptor` method is called to read in the - `ObjectStreamClass` if it represents a class that is not a dynamic proxy - class, as indicated in the stream data. If the class descriptor represents - a dynamic proxy class, call the `resolveProxyClass` method on the stream to - get the local class for the descriptor; otherwise, call the `resolveClass` - method on the stream to get the local class. If the class cannot be - resolved, throw a ClassNotFoundException. Return the resulting - `ObjectStreamClass` object. - -7. If the object in the stream is a `String`, read its length information - followed by the contents of the string encoded in modified UTF-8. For - details, refer to [Section 6.2, "Stream - Elements"](protocol.html#stream-elements). Add the `String` and its handle - to the set of known objects, and proceed to Step 12. - -8. If the object in the stream is an array, read its `ObjectStreamClass` and - the length of the array. Allocate the array, and add it and its handle in - the set of known objects. Read each element using the appropriate method - for its type and assign it to the array. Proceed to Step 12. - -9. If the object in the stream is an enum constant, read its - `ObjectStreamClass` and the enum constant name. If the `ObjectStreamClass` - represents a class that is not an enum type, an `InvalidClassException` is - thrown. Obtain a reference to the enum constant by calling the - `java.lang.Enum.valueOf` method, passing the enum type bound to the - received `ObjectStreamClass` along with the received name as arguments. If - the `valueOf` method throws an `IllegalArgumentException`, an - `InvalidObjectException` is thrown with the `IllegalArgumentException` as - its cause. Add the enum constant and its handle in the set of known - objects, and proceed to Step 12. - -10. For all other objects, the `ObjectStreamClass` of the object is read from - the stream. The local class for that `ObjectStreamClass` is retrieved. The - class must be serializable or externalizable, and must not be an enum type. - If the class does not satisfy these criteria, an `InvalidClassException` is - thrown. - -11. An instance of the class is allocated. The instance and its handle are - added to the set of known objects. The contents restored appropriately: - - a. For serializable objects, the no-arg constructor for the first - non-serializable supertype is run. For serializable classes, the fields - are initialized to the default value appropriate for its type. Then the - fields of each class are restored by calling class-specific - `readObject` methods, or if these are not defined, by calling the - `defaultReadObject` method. Note that field initializers and - constructors are not executed for serializable classes during - deserialization. In the normal case, the version of the class that - wrote the stream will be the same as the class reading the stream. In - this case, all of the supertypes of the object in the stream will match - the supertypes in the currently-loaded class. If the version of the - class that wrote the stream had different supertypes than the loaded - class, the `ObjectInputStream` must be more careful about restoring or - initializing the state of the differing classes. It must step through - the classes, matching the available data in the stream with the classes - of the object being restored. Data for classes that occur in the - stream, but do not occur in the object, is discarded. For classes that - occur in the object, but not in the stream, the class fields are set to - default values by default serialization. - - b. For externalizable objects, the no-arg constructor for the class is run - and then the `readExternal` method is called to restore the contents of - the object. - -12. Process potential substitutions by the class of the object and/or by a - subclass of `ObjectInputStream`: - - a. If the class of the object is not an enum type and defines the - appropriate `readResolve` method, the method is called to allow the - object to replace itself. - - b. Then if previously enabled by `enableResolveObject,` the - `resolveObject` method is called to allow subclasses of the stream to - examine and replace the object. If the previous step did replace the - original object, the `resolveObject` method is called with the - replacement object. If a replacement took place, the table of known - objects is updated so the replacement object is associated with the - handle. The replacement object is then returned from `readObject`. - -All of the methods for reading primitives types only consume bytes from the -block data records in the stream. If a read for primitive data occurs when the -next item in the stream is an object, the read methods return *-1* or the -`EOFException` as appropriate. The value of a primitive type is read by a -`DataInputStream` from the block data record. - -The exceptions thrown reflect errors during the traversal or exceptions that -occur on the underlying stream. If any exception is thrown, the underlying -stream is left in an unknown and unusable state. - -When the reset token occurs in the stream, all of the state of the stream is -discarded. The set of known objects is cleared. - -When the exception token occurs in the stream, the exception is read and a new -`WriteAbortedException` is thrown with the terminating exception as an -argument. The stream context is reset as described earlier. - -The `readUnshared` method is used to read "unshared" objects from the stream. -This method is identical to `readObject`, except that it prevents subsequent -calls to `readObject` and `readUnshared` from returning additional references -to the deserialized instance returned by the original call to `readUnshared`. -Specifically: - -- If `readUnshared` is called to deserialize a back-reference (the stream - representation of an object which has been written previously to the - stream), an `ObjectStreamException` will be thrown. - -- If `readUnshared` returns successfully, then any subsequent attempts to - deserialize back-references to the stream handle deserialized by - `readUnshared` will cause an `ObjectStreamException` to be thrown. - -Deserializing an object via `readUnshared` invalidates the stream handle -associated with the returned object. Note that this in itself does not always -guarantee that the reference returned by `readUnshared` is unique; the -deserialized object may define a `readResolve` method which returns an object -visible to other parties, or `readUnshared` may return a `Class` object or enum -constant obtainable elsewhere in the stream or through external means. If the -deserialized object defines a `readResolve` method and the invocation of that -method returns an array, then `readUnshared` returns a shallow clone of that -array; this guarantees that the returned array object is unique and cannot be -obtained a second time from an invocation of `readObject` or `readUnshared` on -the `ObjectInputStream`, even if the underlying data stream has been -manipulated. - -The `defaultReadObject` method is used to read the fields and object from the -stream. It uses the class descriptor in the stream to read the fields in the -canonical order by name and type from the stream. The values are assigned to -the matching fields by name in the current class. Details of the versioning -mechanism can be found in [Section 5.5, "Compatible Java Type -Evolution"](version.html#compatible-java-type-evolution). Any field of the -object that does not appear in the stream is set to its default value. Values -that appear in the stream, but not in the object, are discarded. This occurs -primarily when a later version of a class has written additional fields that do -not occur in the earlier version. This method may only be called from the -`readObject` method while restoring the fields of a class. When called at any -other time, the `NotActiveException` is thrown. - -The `readFields` method reads the values of the serializable fields from the -stream and makes them available via the `GetField` class. The `readFields` -method is only callable from within the `readObject` method of a serializable -class. It cannot be called more than once or if `defaultReadObject` has been -called. The `GetFields` object uses the current object's `ObjectStreamClass` to -verify the fields that can be retrieved for this class. The `GetFields` object -returned by `readFields` is only valid during this call to the classes -`readObject` method. The fields may be retrieved in any order. Additional data -may only be read directly from stream after `readFields` has been called. - -The `registerValidation` method can be called to request a callback when the -entire graph has been restored but before the object is returned to the -original caller of `readObject`. The order of validate callbacks can be -controlled using the priority. Callbacks registered with higher values are -called before those with lower values. The object to be validated must support -the `ObjectInputValidation` interface and implement the `validateObject` -method. It is only correct to register validations during a call to a class's -`readObject` method. Otherwise, a `NotActiveException` is thrown. If the -callback object supplied to `registerValidation` is null, an -`InvalidObjectException` is thrown. - -Starting with the Java SDK, Standard Edition, v1.3, the `readClassDescriptor` -method is used to read in all `ObjectStreamClass` objects. -`readClassDescriptor` is called when the `ObjectInputStream` expects a class -descriptor as the next item in the serialization stream. Subclasses of -`ObjectInputStream` may override this method to read in class descriptors that -have been written in non-standard formats (by subclasses of -`ObjectOutputStream` which have overridden the `writeClassDescriptor` method). -By default, this method reads class descriptors according to the format -described in [Section 6.4, "Grammar for the Stream -Format"](protocol.html#grammar-for-the-stream-format). - -The `resolveClass` method is called while a class is being deserialized, and -after the class descriptor has been read. Subclasses may extend this method to -read other information about the class written by the corresponding subclass of -`ObjectOutputStream`. The method must find and return the class with the given -name and `serialVersionUID`. The default implementation locates the class by -calling the class loader of the closest caller of `readObject` that has a class -loader. If the class cannot be found `ClassNotFoundException` should be thrown. -Prior to JDK 1.1.6, the `resolveClass` method was required to return the same -fully qualified class name as the class name in the stream. In order to -accommodate package renaming across releases, `method` `resolveClass` only -needs to return a class with the same base class name and `SerialVersionUID` in -JDK 1.1.6 and later versions. - -The `resolveObject` method is used by trusted subclasses to monitor or -substitute one object for another during deserialization. Resolving objects -must be enabled explicitly by calling `enableResolveObject` before calling -`readObject` for the first object to be resolved. Once enabled, `resolveObject` -is called once for each serializable object just prior to the first time it is -being returned from `readObject`. Note that the `resolveObject` method is not -called for objects of the specially handled classes, `Class`, -`ObjectStreamClass`, `String`, and arrays. A subclass's implementation of -`resolveObject` may return a substitute object that will be assigned or -returned instead of the original. The object returned must be of a type that is -consistent and assignable to every reference of the original object or else a -`ClassCastException` will be thrown. All assignments are type-checked. All -references in the stream to the original object will be replaced by references -to the substitute object. - -The `enableResolveObject` method is called by trusted subclasses of -`ObjectOutputStream` to enable the monitoring or substitution of one object for -another during deserialization. Replacing objects is disabled until -`enableResolveObject` is called with a `true` value. It may thereafter be -disabled by setting it to `false`. The previous setting is returned. The -`enableResolveObject` method checks if the stream has permission to request -substitution during serialization. To ensure that the private state of objects -is not unintentionally exposed, only trusted streams may use `resolveObject`. -Trusted classes are those classes with a class loader equal to null or belong -to a security protection domain that provides permission to enable -substitution. - -If the subclass of `ObjectInputStream` is not considered part of the system -domain, a line has to be added to the security policy file to provide to a -subclass of `ObjectInputStream` permission to call `enableResolveObject`. The -`SerializablePermission` to add is `"enableSubstitution"`. -`AccessControlException` is thrown if the protection domain of the subclass of -`ObjectStreamClass` does not have permission to `"enableSubstitution"` by -calling `enableResolveObject`. See the document Java Security Architecture (JDK -1.2) for additional information about the security model. - -The `readStreamHeader` method reads and verifies the magic number and version -of the stream. If they do not match, the `StreamCorruptedMismatch` is thrown. - -To override the implementation of deserialization, a subclass of -`ObjectInputStream` should call the protected no-arg `ObjectInputStream`, -constructor. There is a security check within the no-arg constructor for -`SerializablePermission "enableSubclassImplementation"` to ensure that only -trusted classes are allowed to override the default implementation. This -constructor does not allocate any private data for `ObjectInputStream` and sets -a flag that indicates that the final `readObject` method should invoke the -`readObjectOverride` method and return. All other `ObjectInputStream` methods -are not final and can be directly overridden by the subclass. - -## 3.2 The ObjectInputStream.GetField Class - -The class `ObjectInputStream.GetField` provides the API for getting the values -of serializable fields. The protocol of the stream is the same as used by -`defaultReadObject.` Using `readFields` to access the serializable fields does -not change the format of the stream. It only provides an alternate API to -access the values which does not require the class to have the corresponding -non-transient and non-static fields for each named serializable field. The -serializable fields are those declared using `serialPersistentFields` or if it -is not declared the non-transient and non-static fields of the object. When the -stream is read the available serializable fields are those written to the -stream when the object was serialized. If the class that wrote the stream is a -different version not all fields will correspond to the serializable fields of -the current class. The available fields can be retrieved from the -`ObjectStreamClass` of the `GetField` object. - -The `getObjectStreamClass` method returns an `ObjectStreamClass` object -representing the class in the stream. It contains the list of serializable -fields. - -The `defaulted` method returns *true* if the field is not present in the -stream. An `IllegalArgumentException` is thrown if the requested field is not a -serializable field of the current class. - -Each `get` method returns the specified serializable field from the stream. I/O -exceptions will be thrown if the underlying stream throws an exception. An -`IllegalArgumentException` is thrown if the name or type does not match the -name and type of an field serializable field of the current class. The default -value is returned if the stream does not contain an explicit value for the -field. - -## 3.3 The ObjectInputValidation Interface - -This interface allows an object to be called when a complete graph of objects -has been deserialized. If the object cannot be made valid, it should throw the -`ObjectInvalidException`. Any exception that occurs during a call to -`validateObject` will terminate the validation process, and the -`InvalidObjectException` will be thrown. - -``` -package java.io; - -public interface ObjectInputValidation -{ - public void validateObject() - throws InvalidObjectException; -} -``` - -## 3.4 The readObject Method - -For serializable objects, the `readObject` method allows a class to control the -deserialization of its own fields. Here is its signature: - -``` -private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException; -``` - -Each subclass of a serializable object may define its own `readObject` method. -If a class does not implement the method, the default serialization provided by -`defaultReadObject` will be used. When implemented, the class is only -responsible for restoring its own fields, not those of its supertypes or -subtypes. - -The `readObject` method of the class, if implemented, is responsible for -restoring the state of the class. The values of every field of the object -whether transient or not, static or not are set to the default value for the -fields type. Either `ObjectInputStream`'s `defaultReadObject` or `readFields` -method must be called once (and only once) before reading any optional data -written by the corresponding `writeObject` method; even if no optional data is -read, `defaultReadObject` or `readFields` must still be invoked once. If the -`readObject` method of the class attempts to read more data than is present in -the optional part of the stream for this class, the stream will return `-1` for -bytewise reads, throw an `EOFException` for primitive data reads (e.g., -`readInt`, `readFloat`), or throw an `OptionalDataException` with the `eof` -field set to `true` for object reads. - -The responsibility for the format, structure, and versioning of the optional -data lies completely with the class. The `@serialData` javadoc tag within the -javadoc comment for the `readObject` method should be used to document the -format and structure of the optional data. - -If the class being restored is not present in the stream being read, then its -`readObjectNoData` method, if defined, is invoked (instead of `readObject`); -otherwise, its fields are initialized to the appropriate default values. For -further detail, see [Section 3.5, "The readObjectNoData -Method"](#the-readobjectnodata-method). - -Reading an object from the `ObjectInputStream` is analogous to creating a new -object. Just as a new object's constructors are invoked in the order from the -superclass to the subclass, an object being read from a stream is deserialized -from superclass to subclass. The `readObject` or `readObjectNoData` method is -called instead of the constructor for each `Serializable` subclass during -deserialization. - -One last similarity between a constructor and a `readObject` method is that -both provide the opportunity to invoke a method on an object that is not fully -constructed. Any overridable (neither private, static nor final) method called -while an object is being constructed can potentially be overridden by a -subclass. Methods called during the construction phase of an object are -resolved by the actual type of the object, not the type currently being -initialized by either its constructor or `readObject`/`readObjectNoData` -method. Therefore, calling an overridable method from within a `readObject` or -`readObjectNoData` method may result in the unintentional invocation of a -subclass method before the superclass has been fully initialized. - -## 3.5 The readObjectNoData Method - -For serializable objects, the `readObjectNoData` method allows a class to -control the initialization of its own fields in the event that a subclass -instance is deserialized and the serialization stream does not list the class -in question as a superclass of the deserialized object. This may occur in cases -where the receiving party uses a different version of the deserialized -instance's class than the sending party, and the receiver's version extends -classes that are not extended by the sender's version. This may also occur if -the serialization stream has been tampered; hence, `readObjectNoData` is useful -for initializing deserialized objects properly despite a "hostile" or -incomplete source stream. - -``` -private void readObjectNoData() throws ObjectStreamException; -``` - -Each serializable class may define its own `readObjectNoData` method. If a -serializable class does not define a `readObjectNoData` method, then in the -circumstances listed above the fields of the class will be initialized to their -default values (as listed in The Java Language Specification); this behavior is -consistent with that of `ObjectInputStream` prior to version 1.4 of the Java 2 -SDK, Standard Edition, when support for `readObjectNoData` methods was -introduced. If a serializable class does define a `readObjectNoData` method and -the aforementioned conditions arise, then `readObjectNoData` will be invoked at -the point during deserialization when a class-defined `readObject` method would -otherwise be called had the class in question been listed by the stream as a -superclass of the instance being deserialized. - -## 3.6 The readExternal Method - -Objects implementing `java.io.Externalizable` must implement the `readExternal` -method to restore the entire state of the object. It must coordinate with its -superclasses to restore their state. All of the methods of `ObjectInput` are -available to restore the object's primitive typed fields and object fields. - -``` -public void readExternal(ObjectInput stream) - throws IOException; -``` - -**Note:** The `readExternal` method is public, and it raises the risk of a -client being able to overwrite an existing object from a stream. The class may -add its own checks to insure that this is only called when appropriate. - -A new stream protocol version has been introduced in JDK 1.2 to correct a -problem with `Externalizable` objects. The old definition of `Externalizable` -objects required the local virtual machine to find a `readExternal` method to -be able to properly read an `Externalizable` object from the stream. The new -format adds enough information to the stream protocol so serialization can skip -an `Externalizable` object when the local `readExternal` method is not -available. Due to class evolution rules, serialization must be able to skip an -`Externalizable` object in the input stream if there is not a mapping for the -object using the local classes. - -An additional benefit of the new `Externalizable` stream format is that -`ObjectInputStream` can detect attempts to read more External data than is -available, and can also skip by any data that is left unconsumed by a -`readExternal` method. The behavior of `ObjectInputStream` in response to a -read past the end of External data is the same as the behavior when a -class-defined `readObject` method attempts to read past the end of its optional -data: bytewise reads will return `-1`, primitive reads will throw -`EOFException`s, and object reads will throw `OptionalDataException`s with the -`eof` field set to `true`. - -Due to the format change, JDK 1.1.6 and earlier releases are not able to read -the new format. `StreamCorruptedException` is thrown when JDK 1.1.6 or earlier -attempts to read an `Externalizable` object from a stream written in -`PROTOCOL_VERSION_2`. Compatibility issues are discussed in more detail in -[Section 6.3, "Stream Protocol -Versions"](protocol.html#stream-protocol-versions). - -## 3.7 The readResolve Method - -For Serializable and Externalizable classes, the `readResolve` method allows a -class to replace/resolve the object read from the stream before it is returned -to the caller. By implementing the `readResolve` method, a class can directly -control the types and instances of its own instances being deserialized. The -method is defined as follows: - -``` -ANY-ACCESS-MODIFIER Object readResolve() - throws ObjectStreamException; -``` - -The `readResolve` method is called when `ObjectInputStream` has read an object -from the stream and is preparing to return it to the caller. -`ObjectInputStream` checks whether the class of the object defines the -`readResolve` method. If the method is defined, the `readResolve` method is -called to allow the object in the stream to designate the object to be -returned. The object returned should be of a type that is compatible with all -uses. If it is not compatible, a `ClassCastException` will be thrown when the -type mismatch is discovered. - -For example, a `Symbol` class could be created for which only a single instance -of each symbol binding existed within a virtual machine. The `readResolve` -method would be implemented to determine if that symbol was already defined and -substitute the preexisting equivalent `Symbol` object to maintain the identity -constraint. In this way the uniqueness of `Symbol` objects can be maintained -across serialization. - -**Note:** The `readResolve` method is not invoked on the object until the -object is fully constructed, so any references to this object in its object -graph will not be updated to the new object nominated by `readResolve`. -However, during the serialization of an object with the `writeReplace` method, -all references to the original object in the replacement object's object graph -are replaced with references to the replacement object. Therefore in cases -where an object being serialized nominates a replacement object whose object -graph has a reference to the original object, deserialization will result in an -incorrect graph of objects. Furthermore, if the reference types of the object -being read (nominated by `writeReplace`) and the original object are not -compatible, the construction of the object graph will raise a -`ClassCastException`. - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/output.md b/jdk/src/java.base/share/specs/serialization/output.md deleted file mode 100644 index 46b47cc45e6..00000000000 --- a/jdk/src/java.base/share/specs/serialization/output.md +++ /dev/null @@ -1,514 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](serial-arch.html) | [NEXT](input.html)' -include-after: '[CONTENTS](index.html) | [PREV](serial-arch.html) | [NEXT](input.html)' - -title: 'Java Object Serialization Specification: 2 - Object Output Classes' ---- - -- [The ObjectOutputStream Class](#the-objectoutputstream-class) -- [The ObjectOutputStream.PutField - Class](#the-objectoutputstream.putfield-class) -- [The writeObject Method](#the-writeobject-method) -- [The writeExternal Method](#the-writeexternal-method) -- [The writeReplace Method](#the-writereplace-method) -- [The useProtocolVersion Method](#the-useprotocolversion-method) - -------------------------------------------------------------------------------- - -## 2.1 The ObjectOutputStream Class - -Class `ObjectOutputStream` implements object serialization. It maintains the -state of the stream including the set of objects already serialized. Its -methods control the traversal of objects to be serialized to save the specified -objects and the objects to which they refer. - -``` -package java.io; - -public class ObjectOutputStream - extends OutputStream - implements ObjectOutput, ObjectStreamConstants -{ - public ObjectOutputStream(OutputStream out) - throws IOException; - - public final void writeObject(Object obj) - throws IOException; - - public void writeUnshared(Object obj) - throws IOException; - - public void defaultWriteObject() - throws IOException, NotActiveException; - - public PutField putFields() - throws IOException; - - public writeFields() - throws IOException; - - public void reset() throws IOException; - - protected void annotateClass(Class cl) throws IOException; - - protected void writeClassDescriptor(ObjectStreamClass desc) - throws IOException; - - protected Object replaceObject(Object obj) throws IOException; - - protected boolean enableReplaceObject(boolean enable) - throws SecurityException; - - protected void writeStreamHeader() throws IOException; - - public void write(int data) throws IOException; - - public void write(byte b[]) throws IOException; - - public void write(byte b[], int off, int len) throws IOException; - - public void flush() throws IOException; - - protected void drain() throws IOException; - - public void close() throws IOException; - - public void writeBoolean(boolean data) throws IOException; - - public void writeByte(int data) throws IOException; - - public void writeShort(int data) throws IOException; - - public void writeChar(int data) throws IOException; - - public void writeInt(int data) throws IOException; - - public void writeLong(long data) throws IOException; - - public void writeFloat(float data) throws IOException; - - public void writeDouble(double data) throws IOException; - - public void writeBytes(String data) throws IOException; - - public void writeChars(String data) throws IOException; - - public void writeUTF(String data) throws IOException; - - // Inner class to provide access to serializable fields. - abstract static public class PutField - { - public void put(String name, boolean value) - throws IOException, IllegalArgumentException; - - public void put(String name, char data) - throws IOException, IllegalArgumentException; - - public void put(String name, byte data) - throws IOException, IllegalArgumentException; - - public void put(String name, short data) - throws IOException, IllegalArgumentException; - - public void put(String name, int data) - throws IOException, IllegalArgumentException; - - public void put(String name, long data) - throws IOException, IllegalArgumentException; - - public void put(String name, float data) - throws IOException, IllegalArgumentException; - - public void put(String name, double data) - throws IOException, IllegalArgumentException; - - public void put(String name, Object data) - throws IOException, IllegalArgumentException; - } - - public void useProtocolVersion(int version) throws IOException; - - protected ObjectOutputStream() - throws IOException; - - protected writeObjectOverride() - throws NotActiveException, IOException; -} -``` - -The single-argument `ObjectOutputStream` constructor creates an -`ObjectOutputStream` that serializes objects to the given `OutputStream`. The -constructor calls `writeStreamHeader` to write a magic number and version to -the stream that will be read and verified by a corresponding call to -`readStreamHeader` in the single-argument `ObjectInputStream` constructor. If a -security manager is installed, this constructor checks for the -`"enableSubclassImplementation"` `SerializablePermission` when invoked directly -or indirectly by the constructor of a subclass which overrides the `putFields` -and/or `writeUnshared` methods. - -The `writeObject` method is used to serialize an object to the stream. An -object is serialized as follows: - -1. If a subclass is overriding the implementation, call the - `writeObjectOverride` method and return. Overriding the implementation is - described at the end of this section. - -2. If there is data in the block-data buffer, the data is written to the - stream and the buffer is reset. - -3. If the object is null, null is put in the stream and `writeObject` returns. - -4. If the object has been previously replaced, as described in Step 8, write - the handle of the replacement to the stream and `writeObject` returns. - -5. If the object has already been written to the stream, its handle is written - to the stream and `writeObject` returns. - -6. If the object is a `Class`, the corresponding `ObjectStreamClass` is - written to the stream, a handle is assigned for the class, and - `writeObject` returns. - -7. If the object is an `ObjectStreamClass`, a handle is assigned to the - object, after which it is written to the stream using one of the class - descriptor formats described in [Section 4.3, "Serialized - Form"](class.html#serialized-form). In versions 1.3 and later of the Java 2 - SDK, Standard Edition, the `writeClassDescriptor` method is called to - output the `ObjectStreamClass` if it represents a class that is not a - dynamic proxy class, as determined by passing the associated `Class` object - to the `isProxyClass` method of `java.lang.reflect.Proxy`. Afterwards, an - annotation for the represented class is written: if the class is a dynamic - proxy class, then the `annotateProxyClass` method is called; otherwise, the - `annotateClass` method is called. The `writeObject` method then returns. - -8. Process potential substitutions by the class of the object and/or by a - subclass of `ObjectInputStream`. - - a. If the class of an object is not an enum type and defines the - appropriate `writeReplace` method, the method is called. Optionally, it - can return a substitute object to be serialized. - - b. Then, if enabled by calling the `enableReplaceObject` method, the - `replaceObject` method is called to allow subclasses of - `ObjectOutputStream` to substitute for the object being serialized. If - the original object was replaced in the previous step, the - `replaceObject` method is called with the replacement object. - - If the original object was replaced by either one or both steps above, the - mapping from the original object to the replacement is recorded for later - use in Step 4. Then, Steps 3 through 7 are repeated on the new object. - - If the replacement object is not one of the types covered by Steps 3 - through 7, processing resumes using the replacement object at Step 10. - -9. - If the object is a `java.lang.String,` the string is written as length - information followed by the contents of the string encoded in modified - UTF-8. For details, refer to [Section 6.2, "Stream - Elements"](protocol.html#stream-elements). A handle is assigned to the - string, and `writeObject` returns. - -10. If the object is an array, `writeObject` is called recursively to write the - `ObjectStreamClass` of the array. The handle for the array is assigned. It - is followed by the length of the array. Each element of the array is then - written to the stream, after which `writeObject` returns. - -11. If the object is an enum constant, the `ObjectStreamClass` for the enum - type of the constant is written by recursively calling `writeObject`. It - will appear in the stream only the first time it is referenced. A handle is - assigned for the enum constant. Next, the value returned by the `name` - method of the enum constant is written as a `String` object, as described - in step 9. Note that if the same name string has appeared previously in the - stream, a back reference to it will be written. The `writeObject` method - then returns. - -12. For regular objects, the `ObjectStreamClass` for the class of the object is - written by recursively calling `writeObject`. It will appear in the stream - only the first time it is referenced. A handle is assigned for the object. - -13. The contents of the object are written to the stream. - - a. If the object is serializable, the highest serializable class is - located. For that class, and each derived class, that class's fields - are written. If the class does not have a `writeObject` method, the - `defaultWriteObject` method is called to write the serializable fields - to the stream. If the class does have a `writeObject` method, it is - called. It may call `defaultWriteObject` or `putFields` and - `writeFields` to save the state of the object, and then it can write - other information to the stream. - - b. If the object is externalizable, the `writeExternal` method of the - object is called. - - c. If the object is neither serializable or externalizable, the - `NotSerializableException` is thrown. - -Exceptions may occur during the traversal or may occur in the underlying -stream. For any subclass of `IOException`, the exception is written to the -stream using the exception protocol and the stream state is discarded. If a -second `IOException` is thrown while attempting to write the first exception -into the stream, the stream is left in an unknown state and -`StreamCorruptedException` is thrown from `writeObject`. For other exceptions, -the stream is aborted and left in an unknown and unusable state. - -The `writeUnshared` method writes an "unshared" object to the -`ObjectOutputStream`. This method is identical to `writeObject`, except that it -always writes the given object as a new, unique object in the stream (as -opposed to a back-reference pointing to a previously serialized instance). -Specifically: - -- An object written via `writeUnshared` is always serialized in the same - manner as a newly appearing object (an object that has not been written to - the stream yet), regardless of whether or not the object has been written - previously. - -- If `writeObject` is used to write an object that has been previously - written with `writeUnshared`, the previous `writeUnshared` operation is - treated as if it were a write of a separate object. In other words, - `ObjectOutputStream` will never generate back-references to object data - written by calls to `writeUnshared`. - -While writing an object via `writeUnshared` does not in itself guarantee a -unique reference to the object when it is deserialized, it allows a single -object to be defined multiple times in a stream, so that multiple calls to the -`ObjectInputStream.readUnshared` method (see [Section 3.1, "The -ObjectInputStream Class"](input.html#the-objectinputstream-class)) by the -receiver will not conflict. Note that the rules described above only apply to -the base-level object written with `writeUnshared`, and not to any transitively -referenced sub-objects in the object graph to be serialized. - -The `defaultWriteObject` method implements the default serialization mechanism -for the current class. This method may be called only from a class's -`writeObject` method. The method writes all of the serializable fields of the -current class to the stream. If called from outside the `writeObject` method, -the `NotActiveException` is thrown. - -The `putFields` method returns a `PutField` object the caller uses to set the -values of the serializable fields in the stream. The fields may be set in any -order. After all of the fields have been set, `writeFields` must be called to -write the field values in the canonical order to the stream. If a field is not -set, the default value appropriate for its type will be written to the stream. -This method may only be called from within the `writeObject` method of a -serializable class. It may not be called more than once or if -`defaultWriteObject` has been called. Only after `writeFields` has been called -can other data be written to the stream. - -The `reset` method resets the stream state to be the same as if it had just -been constructed. `Reset` will discard the state of any objects already written -to the stream. The current point in the stream is marked as reset, so the -corresponding `ObjectInputStream` will reset at the same point. Objects -previously written to the stream will not be remembered as already having been -written to the stream. They will be written to the stream again. This is useful -when the contents of an object or objects must be sent again. `Reset` may not -be called while objects are being serialized. If called inappropriately, an -`IOException` is thrown. - -Starting with the Java 2 SDK, Standard Edition, v1.3, the -`writeClassDescriptor` method is called when an `ObjectStreamClass` needs to be -serialized. `writeClassDescriptor` is responsible for writing a representation -of the `ObjectStreamClass` to the serialization stream. Subclasses may override -this method to customize the way in which class descriptors are written to the -serialization stream. If this method is overridden, then the corresponding -`readClassDescriptor` method in `ObjectInputStream` should also be overridden -to reconstitute the class descriptor from its custom stream representation. By -default, `writeClassDescriptor` writes class descriptors according to the -format specified in [Section 6.4, "Grammar for the Stream -Format"](protocol.html#grammar-for-the-stream-format). Note that this method -will only be called if the `ObjectOutputStream` is not using the old -serialization stream format (see [Section 6.3, "Stream Protocol -Versions"](protocol.html#stream-protocol-versions)). If the serialization -stream is using the old format (`ObjectStreamConstants.PROTOCOL_VERSION_1`), -the class descriptor will be written internally in a manner that cannot be -overridden or customized. - -The `annotateClass` method is called while a `Class` is being serialized, and -after the class descriptor has been written to the stream. Subclasses may -extend this method and write other information to the stream about the class. -This information must be read by the `resolveClass` method in a corresponding -`ObjectInputStream` subclass. - -An `ObjectOutputStream` subclass can implement the `replaceObject` method to -monitor or replace objects during serialization. Replacing objects must be -enabled explicitly by calling `enableReplaceObject` before calling -`writeObject` with the first object to be replaced. Once enabled, -`replaceObject` is called for each object just prior to serializing the object -for the first time. Note that the `replaceObject` method is not called for -objects of the specially handled classes, `Class` and `ObjectStreamClass`. An -implementation of a subclass may return a substitute object that will be -serialized instead of the original. The substitute object must be serializable. -All references in the stream to the original object will be replaced by the -substitute object. - -When objects are being replaced, the subclass must ensure that the substituted -object is compatible with every field where the reference will be stored, or -that a complementary substitution will be made during deserialization. Objects, -whose type is not a subclass of the type of the field or array element, will -later abort the deserialization by raising a `ClassCastException` and the -reference will not be stored. - -The `enableReplaceObject` method can be called by trusted subclasses of -`ObjectOutputStream` to enable the substitution of one object for another -during serialization. Replacing objects is disabled until `enableReplaceObject` -is called with a `true` value. It may thereafter be disabled by setting it to -`false`. The previous setting is returned. The `enableReplaceObject` method -checks that the stream requesting the replacement can be trusted. To ensure -that the private state of objects is not unintentionally exposed, only trusted -stream subclasses may use `replaceObject`. Trusted classes are those classes -that belong to a security protection domain with permission to enable -Serializable substitution. - -If the subclass of `ObjectOutputStream` is not considered part of the system -domain, `SerializablePermission "enableSubstitution"` must be added to the -security policy file. `AccessControlException` is thrown if the protection -domain of the subclass of `ObjectInputStream` does not have permission to -`"enableSubstitution"` by calling `enableReplaceObject`. See the document Java -Security Architecture (JDK1.2) for additional information about the security -model. - -The `writeStreamHeader` method writes the magic number and version to the -stream. This information must be read by the `readStreamHeader` method of -`ObjectInputStream`. Subclasses may need to implement this method to identify -the stream's unique format. - -The `flush` method is used to empty any buffers being held by the stream and to -forward the flush to the underlying stream. The `drain` method may be used by -subclassers to empty only the `ObjectOutputStream`'s buffers without forcing -the underlying stream to be flushed. - -All of the write methods for primitive types encode their values using a -`DataOutputStream` to put them in the standard stream format. The bytes are -buffered into block data records so they can be distinguished from the encoding -of objects. This buffering allows primitive data to be skipped if necessary for -class versioning. It also allows the stream to be parsed without invoking -class-specific methods. - -To override the implementation of serialization, the subclass of -`ObjectOutputStream` should call the protected no-arg `ObjectOutputStream`, -constructor. There is a security check within the no-arg constructor for -`SerializablePermission "enableSubclassImplementation"` to ensure that only -trusted classes are allowed to override the default implementation. This -constructor does not allocate any private data for `ObjectOutputStream` and -sets a flag that indicates that the final `writeObject` method should invoke -the `writeObjectOverride` method and return. All other `ObjectOutputStream` -methods are not final and can be directly overridden by the subclass. - -## 2.2 The ObjectOutputStream.PutField Class - -Class `PutField` provides the API for setting values of the serializable fields -for a class when the class does not use default serialization. Each method puts -the specified named value into the stream. An `IllegalArgumentException` is -thrown if `name` does not match the name of a serializable field for the class -whose fields are being written, or if the type of the named field does not -match the second parameter type of the specific `put` method invoked. - -## 2.3 The writeObject Method - -For serializable objects, the `writeObject` method allows a class to control -the serialization of its own fields. Here is its signature: - -``` -private void writeObject(ObjectOutputStream stream) - throws IOException; -``` - -Each subclass of a serializable object may define its own `writeObject` method. -If a class does not implement the method, the default serialization provided by -`defaultWriteObject` will be used. When implemented, the class is only -responsible for writing its own fields, not those of its supertypes or -subtypes. - -The class's `writeObject` method, if implemented, is responsible for saving the -state of the class. Either `ObjectOutputStream`'s `defaultWriteObject` or -`writeFields` method must be called once (and only once) before writing any -optional data that will be needed by the corresponding `readObject` method to -restore the state of the object; even if no optional data is written, -`defaultWriteObject` or `writeFields` must still be invoked once. If -`defaultWriteObject` or `writeFields` is not invoked once prior to the writing -of optional data (if any), then the behavior of instance deserialization is -undefined in cases where the `ObjectInputStream` cannot resolve the class which -defined the `writeObject` method in question. - -The responsibility for the format, structure, and versioning of the optional -data lies completely with the class. - -## 2.4 The writeExternal Method - -Objects implementing `java.io.Externalizable` must implement the -`writeExternal` method to save the entire state of the object. It must -coordinate with its superclasses to save their state. All of the methods of -`ObjectOutput` are available to save the object's primitive typed fields and -object fields. - -``` -public void writeExternal(ObjectOutput stream) - throws IOException; -``` - -A new default format for writing Externalizable data has been introduced in JDK -1.2. The new format specifies that primitive data will be written in block data -mode by `writeExternal` methods. Additionally, a tag denoting the end of the -External object is appended to the stream after the `writeExternal` method -returns. The benefits of this format change are discussed in [Section 3.6, "The -readExternal Method"](input.html#the-readexternal-method). Compatibility issues -caused by this change are discussed in [Section 2.6, "The useProtocolVersion -Method"](#the-useprotocolversion-method). - -## 2.5 The writeReplace Method - -For Serializable and Externalizable classes, the `writeReplace` method allows a -class of an object to nominate its own replacement in the stream before the -object is written. By implementing the `writeReplace` method, a class can -directly control the types and instances of its own instances being serialized. - -The method is defined as follows: - -``` -ANY-ACCESS-MODIFIER Object writeReplace() - throws ObjectStreamException; -``` - -The `writeReplace` method is called when `ObjectOutputStream` is preparing to -write the object to the stream. The `ObjectOutputStream` checks whether the -class defines the `writeReplace` method. If the method is defined, the -`writeReplace` method is called to allow the object to designate its -replacement in the stream. The object returned should be either of the same -type as the object passed in or an object that when read and resolved will -result in an object of a type that is compatible with all references to the -object. If it is not, a `ClassCastException` will occur when the type mismatch -is discovered. - -## 2.6 The useProtocolVersion Method - -Due to a stream protocol change that was not backwards compatible, a mechanism -has been added to enable the current Virtual Machine to write a serialization -stream that is readable by a previous release. Of course, the problems that are -corrected by the new stream format will exist when using the backwards -compatible protocol. - -Stream protocol versions are discussed in [Section 6.3, "Stream Protocol -Versions"](protocol.html#stream-protocol-versions). - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/protocol.md b/jdk/src/java.base/share/specs/serialization/protocol.md deleted file mode 100644 index affc6886f98..00000000000 --- a/jdk/src/java.base/share/specs/serialization/protocol.md +++ /dev/null @@ -1,504 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](version.html) | [NEXT](security.html)' -include-after: '[CONTENTS](index.html) | [PREV](version.html) | [NEXT](security.html)' - -title: 'Java Object Serialization Specification: 6 - Object Serialization Stream Protocol' ---- - -- [Overview](#overview) -- [Stream Elements](#stream-elements) -- [Stream Protocol Versions](#stream-protocol-versions) -- [Grammar for the Stream Format](#grammar-for-the-stream-format) -- [Example](#example) - -------------------------------------------------------------------------------- - -## 6.1 Overview - -The stream format satisfies the following design goals: - -- Is compact and is structured for efficient reading. -- Allows skipping through the stream using only the knowledge of the - structure and format of the stream. Does not require invoking any per class - code. -- Requires only stream access to the data. - -## 6.2 Stream Elements - -A basic structure is needed to represent objects in a stream. Each attribute of -the object needs to be represented: its classes, its fields, and data written -and later read by class-specific methods. The representation of objects in the -stream can be described with a grammar. There are special representations for -null objects, new objects, classes, arrays, strings, and back references to any -object already in the stream. Each object written to the stream is assigned a -handle that is used to refer back to the object. Handles are assigned -sequentially starting from 0x7E0000. The handles restart at 0x7E0000 when the -stream is reset. - -A class object is represented by the following: - -- Its `ObjectStreamClass` object. - -An `ObjectStreamClass` object for a Class that is not a dynamic proxy class is -represented by the following: - -- The Stream Unique Identifier (SUID) of compatible classes. - -- A set of flags indicating various properties of the class, such as whether - the class defines a `writeObject` method, and whether the class is - serializable, externalizable, or an enum type - -- The number of serializable fields - -- The array of fields of the class that are serialized by the default - mechanismFor arrays and object fields, the type of the field is included as - a string which must be in "field descriptor" format (e.g., - "`Ljava/lang/Object;`") as specified in The Java Virtual Machine - Specification. - -- Optional block-data records or objects written by the `annotateClass` - method - -- The `ObjectStreamClass` of its supertype (null if the superclass is not - serializable) - -An `ObjectStreamClass` object for a dynamic proxy class is represented by the -following: - -- The number of interfaces that the dynamic proxy class implements - -- The names of all of the interfaces implemented by the dynamic proxy class, - listed in the order that they are returned by invoking the `getInterfaces` - method on the Class object. - -- Optional block-data records or objects written by the `annotateProxyClass` - method. - -- The ObjectStreamClass of its supertype, `java.lang.reflect.Proxy`. - -The representation of `String` objects consists of length information followed -by the contents of the string encoded in modified UTF-8. The modified UTF-8 -encoding is the same as used in the Java Virtual Machine and in the -`java.io.DataInput` and `DataOutput` interfaces; it differs from standard UTF-8 -in the representation of supplementary characters and of the null character. -The form of the length information depends on the length of the string in -modified UTF-8 encoding. If the modified UTF-8 encoding of the given `String` -is less than 65536 bytes in length, the length is written as 2 bytes -representing an unsigned 16-bit integer. Starting with the Java 2 platform, -Standard Edition, v1.3, if the length of the string in modified UTF-8 encoding -is 65536 bytes or more, the length is written in 8 bytes representing a signed -64-bit integer. The typecode preceding the `String` in the serialization stream -indicates which format was used to write the `String`. - -Arrays are represented by the following: - -- Their `ObjectStreamClass` object. - -- The number of elements. - -- The sequence of values. The type of the values is implicit in the type of - the array. for example the values of a byte array are of type byte. - -Enum constants are represented by the following: - -- The `ObjectStreamClass` object of the constant's base enum type. - -- The constant's name string. - -New objects in the stream are represented by the following: - -- The most derived class of the object. - -- Data for each serializable class of the object, with the highest superclass - first. For each class the stream contains the following: - - - The serializable fields.See [Section 1.5, "Defining Serializable Fields - for a - Class"](serial-arch.html#defining-serializable-fields-for-a-class). - - - If the class has `writeObject`/`readObject` methods, there may be - optional objects and/or block-data records of primitive types written - by the `writeObject` method followed by an `endBlockData` code. - -All primitive data written by classes is buffered and wrapped in block-data -records, regardless if the data is written to the stream within a `writeObject` -method or written directly to the stream from outside a `writeObject` method. -This data can only be read by the corresponding `readObject` methods or be read -directly from the stream. Objects written by the `writeObject` method terminate -any previous block-data record and are written either as regular objects or -null or back references, as appropriate. The block-data records allow error -recovery to discard any optional data. When called from within a class, the -stream can discard any data or objects until the `endBlockData`. - -## 6.3 Stream Protocol Versions - -It was necessary to make a change to the serialization stream format in JDK 1.2 -that is not backwards compatible to all minor releases of JDK 1.1. To provide -for cases where backwards compatibility is required, a capability has been -added to indicate what `PROTOCOL_VERSION` to use when writing a serialization -stream. The method `ObjectOutputStream.useProtocolVersion` takes as a parameter -the protocol version to use to write the serialization stream. - -The Stream Protocol Versions are as follows: - -- `ObjectStreamConstants.PROTOCOL_VERSION_1`: Indicates the initial stream - format. - -- `ObjectStreamConstants.PROTOCOL_VERSION_2`: Indicates the new external data - format. Primitive data is written in block data mode and is terminated with - `TC_ENDBLOCKDATA`. - - Block data boundaries have been standardized. Primitive data written in - block data mode is normalized to not exceed 1024 byte chunks. The benefit - of this change was to tighten the specification of serialized data format - within the stream. This change is fully backward and forward compatible. - -JDK 1.2 defaults to writing `PROTOCOL_VERSION_2`. - -JDK 1.1 defaults to writing `PROTOCOL_VERSION_1`. - -JDK 1.1.7 and greater can read both versions. - -Releases prior to JDK 1.1.7 can only read `PROTOCOL_VERSION_1`. - -## 6.4 Grammar for the Stream Format - -The table below contains the grammar for the stream format. Nonterminal symbols -are shown in italics. Terminal symbols in a *fixed width font*. Definitions of -nonterminals are followed by a ":". The definition is followed by one or more -alternatives, each on a separate line. The following table describes the -notation: - - ------------- -------------------------------------------------------------- - **Notation** **Meaning** - ------------- -------------------------------------------------------------- - (*datatype*) This token has the data type specified, such as byte. - - *token*\[n\] A predefined number of occurrences of the token, that is an - array. - - *x0001* A literal value expressed in hexadecimal. The number of hex - digits reflects the size of the value. - - <*xxx*> A value read from the stream used to indicate the length of an - array. - ------------- -------------------------------------------------------------- - -Note that the symbol (utf) is used to designate a string written using 2-byte -length information, and (long-utf) is used to designate a string written using -8-byte length information. For details, refer to [Section 6.2, "Stream -Elements"](#stream-elements). - -### 6.4.1 Rules of the Grammar - -A Serialized stream is represented by any stream satisfying the *stream* rule. - -``` -stream: - magic version contents - -contents: - content - contents content - -content: - object - blockdata - -object: - newObject - newClass - newArray - newString - newEnum - newClassDesc - prevObject - nullReference - exception - TC_RESET - -newClass: - TC_CLASS classDesc newHandle - -classDesc: - newClassDesc - nullReference - (ClassDesc)prevObject // an object required to be of type ClassDesc - -superClassDesc: - classDesc - -newClassDesc: - TC_CLASSDESC className serialVersionUID newHandle classDescInfo - TC_PROXYCLASSDESC newHandle proxyClassDescInfo - -classDescInfo: - classDescFlags fields classAnnotation superClassDesc - -className: - (utf) - -serialVersionUID: - (long) - -classDescFlags: - (byte) // Defined in Terminal Symbols and Constants - -proxyClassDescInfo: - (int) proxyInterfaceName[count] classAnnotation - superClassDesc - -proxyInterfaceName: - (utf) - -fields: - (short) fieldDesc[count] - -fieldDesc: - primitiveDesc - objectDesc - -primitiveDesc: - prim_typecode fieldName - -objectDesc: - obj_typecode fieldName className1 - -fieldName: - (utf) - -className1: - (String)object // String containing the field's type, - // in field descriptor format - -classAnnotation: - endBlockData - contents endBlockData // contents written by annotateClass - -prim_typecode: - 'B' // byte - 'C' // char - 'D' // double - 'F' // float - 'I' // integer - 'J' // long - 'S' // short - 'Z' // boolean - -obj_typecode: - '[' // array - 'L' // object - -newArray: - TC_ARRAY classDesc newHandle (int) values[size] - -newObject: - TC_OBJECT classDesc newHandle classdata[] // data for each class - -classdata: - nowrclass // SC_SERIALIZABLE & classDescFlag && - // !(SC_WRITE_METHOD & classDescFlags) - wrclass objectAnnotation // SC_SERIALIZABLE & classDescFlag && - // SC_WRITE_METHOD & classDescFlags - externalContents // SC_EXTERNALIZABLE & classDescFlag && - // !(SC_BLOCKDATA & classDescFlags - objectAnnotation // SC_EXTERNALIZABLE & classDescFlag&& - // SC_BLOCKDATA & classDescFlags - -nowrclass: - values // fields in order of class descriptor - -wrclass: - nowrclass - -objectAnnotation: - endBlockData - contents endBlockData // contents written by writeObject - // or writeExternal PROTOCOL_VERSION_2. - -blockdata: - blockdatashort - blockdatalong - -blockdatashort: - TC_BLOCKDATA (unsigned byte) (byte)[size] - -blockdatalong: - TC_BLOCKDATALONG (int) (byte)[size] - -endBlockData: - TC_ENDBLOCKDATA - -externalContent: // Only parseable by readExternal - (bytes) // primitive data - object - -externalContents: // externalContent written by - externalContent // writeExternal in PROTOCOL_VERSION_1. - externalContents externalContent - -newString: - TC_STRING newHandle (utf) - TC_LONGSTRING newHandle (long-utf) - -newEnum: - TC_ENUM classDesc newHandle enumConstantName - -enumConstantName: - (String)object - -prevObject: - TC_REFERENCE (int)handle - -nullReference: - TC_NULL - -exception: - TC_EXCEPTION reset (Throwable)object reset - -magic: - STREAM_MAGIC - -version: - STREAM_VERSION - -values: // The size and types are described by the - // classDesc for the current object - -newHandle: // The next number in sequence is assigned - // to the object being serialized or deserialized - -reset: // The set of known objects is discarded - // so the objects of the exception do not - // overlap with the previously sent objects - // or with objects that may be sent after - // the exception -``` - -### 6.4.2 Terminal Symbols and Constants - -The following symbols in `java.io.ObjectStreamConstants` define the terminal -and constant values expected in a stream. - -``` -final static short STREAM_MAGIC = (short)0xaced; -final static short STREAM_VERSION = 5; -final static byte TC_NULL = (byte)0x70; -final static byte TC_REFERENCE = (byte)0x71; -final static byte TC_CLASSDESC = (byte)0x72; -final static byte TC_OBJECT = (byte)0x73; -final static byte TC_STRING = (byte)0x74; -final static byte TC_ARRAY = (byte)0x75; -final static byte TC_CLASS = (byte)0x76; -final static byte TC_BLOCKDATA = (byte)0x77; -final static byte TC_ENDBLOCKDATA = (byte)0x78; -final static byte TC_RESET = (byte)0x79; -final static byte TC_BLOCKDATALONG = (byte)0x7A; -final static byte TC_EXCEPTION = (byte)0x7B; -final static byte TC_LONGSTRING = (byte) 0x7C; -final static byte TC_PROXYCLASSDESC = (byte) 0x7D; -final static byte TC_ENUM = (byte) 0x7E; -final static int baseWireHandle = 0x7E0000; -``` - -The flag byte *classDescFlags* may include values of - -``` -final static byte SC_WRITE_METHOD = 0x01; //if SC_SERIALIZABLE -final static byte SC_BLOCK_DATA = 0x08; //if SC_EXTERNALIZABLE -final static byte SC_SERIALIZABLE = 0x02; -final static byte SC_EXTERNALIZABLE = 0x04; -final static byte SC_ENUM = 0x10; -``` - -The flag `SC_WRITE_METHOD` is set if the Serializable class writing the stream -had a `writeObject` method that may have written additional data to the stream. -In this case a `TC_ENDBLOCKDATA` marker is always expected to terminate the -data for that class. - -The flag `SC_BLOCKDATA` is set if the `Externalizable` class is written into -the stream using `STREAM_PROTOCOL_2`. By default, this is the protocol used to -write `Externalizable` objects into the stream in JDK 1.2. JDK 1.1 writes -`STREAM_PROTOCOL_1`. - -The flag `SC_SERIALIZABLE` is set if the class that wrote the stream extended -`java.io.Serializable` but not `java.io.Externalizable`, the class reading the -stream must also extend `java.io.Serializable` and the default serialization -mechanism is to be used. - -The flag `SC_EXTERNALIZABLE` is set if the class that wrote the stream extended -`java.io.Externalizable`, the class reading the data must also extend -`Externalizable` and the data will be read using its `writeExternal` and -`readExternal` methods. - -The flag `SC_ENUM` is set if the class that wrote the stream was an enum type. -The receiver's corresponding class must also be an enum type. Data for -constants of the enum type will be written and read as described in [Section -1.12, "Serialization of Enum -Constants"](serial-arch.html#serialization-of-enum-constants). - -#### Example - -Consider the case of an original class and two instances in a linked list: - -``` -class List implements java.io.Serializable { - int value; - List next; - public static void main(String[] args) { - try { - List list1 = new List(); - List list2 = new List(); - list1.value = 17; - list1.next = list2; - list2.value = 19; - list2.next = null; - - ByteArrayOutputStream o = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(o); - out.writeObject(list1); - out.writeObject(list2); - out.flush(); - ... - } catch (Exception ex) { - ex.printStackTrace(); - } - } -} -``` - -The resulting stream contains: - -``` - 00: ac ed 00 05 73 72 00 04 4c 69 73 74 69 c8 8a 15 >....sr..Listi...< - 10: 40 16 ae 68 02 00 02 49 00 05 76 61 6c 75 65 4c >Z......I..valueL< - 20: 00 04 6e 65 78 74 74 00 06 4c 4c 69 73 74 3b 78 >..nextt..LList;x< - 30: 70 00 00 00 11 73 71 00 7e 00 00 00 00 00 13 70 >p....sq.~......p< - 40: 71 00 7e 00 03 >q.~..< -``` - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/security.md b/jdk/src/java.base/share/specs/serialization/security.md deleted file mode 100644 index 9f26748daa9..00000000000 --- a/jdk/src/java.base/share/specs/serialization/security.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](protocol.html) | [NEXT](exceptions.html)' -include-after: '[CONTENTS](index.html) | [PREV](protocol.html) | [NEXT](exceptions.html)' - -title: 'Java Object Serialization Specification: A - Security in Object Serialization' ---- - -------------------------------------------------------------------------------- - -Refer to the [Secure Coding Guidelines for the Java Programming -Language](http://www.oracle.com/pls/topic/lookup?ctx=javase9&id=secure_coding_guidelines_javase) -for information about security in object serialization. - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/serial-arch.md b/jdk/src/java.base/share/specs/serialization/serial-arch.md deleted file mode 100644 index 4ff54731688..00000000000 --- a/jdk/src/java.base/share/specs/serialization/serial-arch.md +++ /dev/null @@ -1,575 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](index.html) | [NEXT](output.html)' -include-after: '[CONTENTS](index.html) | [PREV](index.html) | [NEXT](output.html)' - -title: 'Java Object Serialization Specification: 1 - System Architecture' ---- - -- [Overview](#overview) -- [Writing to an Object Stream](#writing-to-an-object-stream) -- [Reading from an Object Stream](#reading-from-an-object-stream) -- [Object Streams as Containers](#object-streams-as-containers) -- [Defining Serializable Fields for a - Class](#defining-serializable-fields-for-a-class) -- [Documenting Serializable Fields and Data for a - Class](#documenting-serializable-fields-and-data-for-a-class) -- [Accessing Serializable Fields of a - Class](#accessing-serializable-fields-of-a-class) -- [The ObjectOutput Interface](#the-objectoutput-interface) -- [The ObjectInput Interface](#the-objectinput-interface) -- [The Serializable Interface](#the-serializable-interface) -- [The Externalizable Interface](#the-externalizable-interface) -- [Serialization of Enum Constants](#serialization-of-enum-constants) -- [Protecting Sensitive Information](#protecting-sensitive-information) - -------------------------------------------------------------------------------- - -## 1.1 Overview - -The ability to store and retrieve Java^TM^ objects is essential to building all -but the most transient applications. The key to storing and retrieving objects -in a serialized form is representing the state of objects sufficient to -reconstruct the object(s). Objects to be saved in the stream may support either -the `Serializable` or the `Externalizable` interface. For Java^TM^ objects, the -serialized form must be able to identify and verify the Java^TM^ class from -which the contents of the object were saved and to restore the contents to a -new instance. For serializable objects, the stream includes sufficient -information to restore the fields in the stream to a compatible version of the -class. For Externalizable objects, the class is solely responsible for the -external format of its contents. - -Objects to be stored and retrieved frequently refer to other objects. Those -other objects must be stored and retrieved at the same time to maintain the -relationships between the objects. When an object is stored, all of the objects -that are reachable from that object are stored as well. - -The goals for serializing Java^TM^ objects are to: - -- Have a simple yet extensible mechanism. -- Maintain the Java^TM^ object type and safety properties in the serialized - form. -- Be extensible to support marshaling and unmarshaling as needed for remote - objects. -- Be extensible to support simple persistence of Java^TM^ objects. -- Require per class implementation only for customization. -- Allow the object to define its external format. - -## 1.2 Writing to an Object Stream - -Writing objects and primitives to a stream is a straightforward process. For -example: - -``` -// Serialize today's date to a file. - FileOutputStream f = new FileOutputStream("tmp"); - ObjectOutput s = new ObjectOutputStream(f); - s.writeObject("Today"); - s.writeObject(new Date()); - s.flush(); -``` - -First an `OutputStream`, in this case a `FileOutputStream`, is needed to -receive the bytes. Then an `ObjectOutputStream` is created that writes to the -`FileOutputStream`. Next, the string "Today" and a Date object are written to -the stream. More generally, objects are written with the `writeObject` method -and primitives are written to the stream with the methods of `DataOutput`. - -The `writeObject` method (see [Section 2.3, "The writeObject -Method"](output.html#the-writeobject-method)) serializes the specified object -and traverses its references to other objects in the object graph recursively -to create a complete serialized representation of the graph. Within a stream, -the first reference to any object results in the object being serialized or -externalized and the assignment of a handle for that object. Subsequent -references to that object are encoded as the handle. Using object handles -preserves sharing and circular references that occur naturally in object -graphs. Subsequent references to an object use only the handle allowing a very -compact representation. - -Special handling is required for arrays, enum constants, and objects of type -`Class`, `ObjectStreamClass`, and `String`. Other objects must implement either -the `Serializable` or the `Externalizable` interface to be saved in or restored -from a stream. - -Primitive data types are written to the stream with the methods in the -`DataOutput` interface, such as `writeInt`, `writeFloat`, or `writeUTF`. -Individual bytes and arrays of bytes are written with the methods of -`OutputStream`. Except for serializable fields, primitive data is written to -the stream in block-data records, with each record prefixed by a marker and an -indication of the number of bytes in the record. - -`ObjectOutputStream` can be extended to customize the information about classes -in the stream or to replace objects to be serialized. Refer to the -`annotateClass` and `replaceObject` method descriptions for details. - -## 1.3 Reading from an Object Stream - -Reading an object from a stream, like writing, is straightforward: - -``` -// Deserialize a string and date from a file. - FileInputStream in = new FileInputStream("tmp"); - ObjectInputStream s = new ObjectInputStream(in); - String today = (String)s.readObject(); - Date date = (Date)s.readObject(); -``` - -First an `InputStream`, in this case a `FileInputStream`, is needed as the -source stream. Then an `ObjectInputStream` is created that reads from the -`InputStream`. Next, the string "Today" and a Date object are read from the -stream. Generally, objects are read with the `readObject` method and primitives -are read from the stream with the methods of `DataInput`. - -The `readObject` method deserializes the next object in the stream and -traverses its references to other objects recursively to create the complete -graph of objects serialized. - -Primitive data types are read from the stream with the methods in the -`DataInput` interface, such as `readInt`, `readFloat`, or `readUTF`. Individual -bytes and arrays of bytes are read with the methods of `InputStream`. Except -for serializable fields, primitive data is read from block-data records. - -`ObjectInputStream` can be extended to utilize customized information in the -stream about classes or to replace objects that have been deserialized. Refer -to the `resolveClass` and `resolveObject` method descriptions for details. - -## 1.4 Object Streams as Containers - -Object Serialization produces and consumes a stream of bytes that contain one -or more primitives and objects. The objects written to the stream, in turn, -refer to other objects, which are also represented in the stream. Object -Serialization produces just one stream format that encodes and stores the -contained objects. - -Each object that acts as a container implements an interface which allows -primitives and objects to be stored in or retrieved from it. These interfaces -are the `ObjectOutput` and `ObjectInput` interfaces which: - -- Provide a stream to write to and to read from -- Handle requests to write primitive types and objects to the stream -- Handle requests to read primitive types and objects from the stream - -Each object which is to be stored in a stream must explicitly allow itself to -be stored and must implement the protocols needed to save and restore its -state. Object Serialization defines two such protocols. The protocols allow the -container to ask the object to write and read its state. - -To be stored in an Object Stream, each object must implement either the -`Serializable` or the `Externalizable` interface: - -- For a `Serializable` class, Object Serialization can automatically save and - restore fields of each class of an object and automatically handle classes - that evolve by adding fields or supertypes. A serializable class can - declare which of its fields are saved or restored, and write and read - optional values and objects. - -- For an `Externalizable` class, Object Serialization delegates to the class - complete control over its external format and how the state of the - supertype(s) is saved and restored. - -## 1.5 Defining Serializable Fields for a Class - -The serializable fields of a class can be defined two different ways. Default -serializable fields of a class are defined to be the non-transient and -non-static fields. This default computation can be overridden by declaring a -special field in the `Serializable` class, `serialPersistentFields`. This field -must be initialized with an array of `ObjectStreamField` objects that list the -names and types of the serializable fields. The modifiers for the field are -required to be private, static, and final. If the field's value is null or is -otherwise not an instance of `ObjectStreamField[]`, or if the field does not -have the required modifiers, then the behavior is as if the field were not -declared at all. - -For example, the following declaration duplicates the default behavior. - -``` -class List implements Serializable { - List next; - - private static final ObjectStreamField[] serialPersistentFields - = {new ObjectStreamField("next", List.class)}; - -} -``` - -By using `serialPersistentFields` to define the Serializable fields for a -class, there no longer is a limitation that a serializable field must be a -field within the current definition of the `Serializable` class. The -`writeObject` and `readObject` methods of the `Serializable` class can map the -current implementation of the class to the serializable fields of the class -using the interface that is described in [Section 1.7, "Accessing Serializable -Fields of a Class"](#accessing-serializable-fields-of-a-class). Therefore, the -fields for a `Serializable` class can change in a later release, as long as it -maintains the mapping back to its Serializable fields that must remain -compatible across release boundaries. - -**Note:** There is, however, a limitation to the use of this mechanism to -specify serializable fields for inner classes. Inner classes can only contain -final static fields that are initialized to constants or expressions built up -from constants. Consequently, it is not possible to set -`serialPersistentFields` for an inner class (though it is possible to set it -for static member classes). For other restrictions pertaining to serialization -of inner class instances, see section [Section 1.10, "The Serializable -Interface"](#the-serializable-interface). - -## 1.6 Documenting Serializable Fields and Data for a Class - -It is important to document the serializable state of a class to enable -interoperability with alternative implementations of a Serializable class and -to document class evolution. Documenting a serializable field gives one a final -opportunity to review whether or not the field should be serializable. The -serialization javadoc tags, `@serial`, `@serialField`, and `@serialData`, -provide a way to document the serialized form for a Serializable class within -the source code. - -- The `@serial` tag should be placed in the javadoc comment for a default - serializable field. The syntax is as follows: `@serial` *field-description* - The optional *field-description* describes the meaning of the field and its - acceptable values. The *field-description* can span multiple lines. When a - field is added after the initial release, a *@since* tag indicates the - version the field was added. The *field-description* for `@serial` provides - serialization-specific documentation and is appended to the javadoc comment - for the field within the serialized form documentation. - -- The `@serialField` tag is used to document an `ObjectStreamField` component - of a `serialPersistentFields` array. One of these tags should be used for - each `ObjectStreamField` component. The syntax is as follows: - `@serialField` *field-name field-type field-description* - -- The `@serialData` tag describes the sequences and types of data written or - read. The tag describes the sequence and type of optional data written by - `writeObject` or all data written by the `Externalizable.writeExternal` - method. The syntax is as follows: `@serialData` *data-description* - -The javadoc application recognizes the serialization javadoc tags and generates -a specification for each Serializable and Externalizable class. See [Section -C.1, "Example Alternate Implementation of -java.io.File"](examples.html#c.1-example-alternate-implementation-of-java.io.file) -for an example that uses these tags. - -When a class is declared Serializable, the serializable state of the object is -defined by serializable fields (by name and type) plus optional data. Optional -data can only be written explicitly by the `writeObject` method of a -`Serializable` class. Optional data can be read by the `Serializable` class' -`readObject` method or serialization will skip unread optional data. - -When a class is declared Externalizable, the data that is written to the stream -by the class itself defines the serialized state. The class must specify the -order, types, and meaning of each datum that is written to the stream. The -class must handle its own evolution, so that it can continue to read data -written by and write data that can be read by previous versions. The class must -coordinate with the superclass when saving and restoring data. The location of -the superclasses data in the stream must be specified. - -The designer of a Serializable class must ensure that the information saved for -the class is appropriate for persistence and follows the -serialization-specified rules for interoperability and evolution. Class -evolution is explained in greater detail in [Chapter -5](version.html#versioning-of-serializable-objects), "Versioning of -Serializable Objects". - -## 1.7 Accessing Serializable Fields of a Class - -Serialization provides two mechanisms for accessing the serializable fields in -a stream: - -- The default mechanism requires no customization -- The Serializable Fields API allows a class to explicitly access/set the - serializable fields by name and type - -The default mechanism is used automatically when reading or writing objects -that implement the `Serializable` interface and do no further customization. -The serializable fields are mapped to the corresponding fields of the class and -values are either written to the stream from those fields or are read in and -assigned respectively. If the class provides `writeObject` and `readObject` -methods, the default mechanism can be invoked by calling `defaultWriteObject` -and `defaultReadObject`. When the `writeObject` and `readObject` methods are -implemented, the class has an opportunity to modify the serializable field -values before they are written or after they are read. - -When the default mechanism cannot be used, the serializable class can use the -`putFields` method of `ObjectOutputStream` to put the values for the -serializable fields into the stream. The `writeFields` method of -`ObjectOutputStream` puts the values in the correct order, then writes them to -the stream using the existing protocol for serialization. Correspondingly, the -`readFields` method of `ObjectInputStream` reads the values from the stream and -makes them available to the class by name in any order. See [Section 2.2, "The -ObjectOutputStream.PutField -Class"](output.html#the-objectoutputstream.putfield-class) and [Section 3.2, -"The ObjectInputStream.GetField -Class"](input.html#the-objectinputstream.getfield-class) for a detailed -description of the Serializable Fields API. - -## 1.8 The ObjectOutput Interface - -The `ObjectOutput` interface provides an abstract, stream-based interface to -object storage. It extends the DataOutput interface so those methods can be -used for writing primitive data types. Objects that implement this interface -can be used to store primitives and objects. - -``` -package java.io; - -public interface ObjectOutput extends DataOutput -{ - public void writeObject(Object obj) throws IOException; - public void write(int b) throws IOException; - public void write(byte b[]) throws IOException; - public void write(byte b[], int off, int len) throws IOException; - public void flush() throws IOException; - public void close() throws IOException; -} -``` - -`The` `writeObject` method is used to write an object. The exceptions thrown -reflect errors while accessing the object or its fields, or exceptions that -occur in writing to storage. If any exception is thrown, the underlying storage -may be corrupted. If this occurs, refer to the object that is implementing this -interface for more information. - -## 1.9 The ObjectInput Interface - -The `ObjectInput` interface provides an abstract stream based interface to -object retrieval. It extends the `DataInput` interface so those methods for -reading primitive data types are accessible in this interface. - -``` -package java.io; - -public interface ObjectInput extends DataInput -{ - public Object readObject() - throws ClassNotFoundException, IOException; - public int read() throws IOException; - public int read(byte b[]) throws IOException; - public int read(byte b[], int off, int len) throws IOException; - public long skip(long n) throws IOException; - public int available() throws IOException; - public void close() throws IOException; -} -``` - -The `readObject` method is used to read and return an object. The exceptions -thrown reflect errors while accessing the objects or its fields or exceptions -that occur in reading from the storage. If any exception is thrown, the -underlying storage may be corrupted. If this occurs, refer to the object -implementing this interface for additional information. - -## 1.10 The Serializable Interface - -Object Serialization produces a stream with information about the Java^TM^ -classes for the objects which are being saved. For serializable objects, -sufficient information is kept to restore those objects even if a different -(but compatible) version of the implementation of the class is present. The -`Serializable` interface is defined to identify classes which implement the -serializable protocol: - -``` -package java.io; - -public interface Serializable {}; -``` - -A Serializable class must do the following: - -- Implement the `java.io.Serializable` interface - -- Identify the fields that should be serializable - - (Use the `serialPersistentFields` member to explicitly declare them - serializable or use the transient keyword to denote nonserializable - fields.) - -- Have access to the no-arg constructor of its first nonserializable - superclass - -The class can optionally define the following methods: - -- A `writeObject` method to control what information is saved or to append - additional information to the stream - -- A `readObject` method either to read the information written by the - corresponding `writeObject` method or to update the state of the object - after it has been restored - -- A `writeReplace` method to allow a class to nominate a replacement object - to be written to the stream - - (See [Section 2.5, "The writeReplace - Method"](output.html#the-writereplace-method) for additional information.) - -- A `readResolve` method to allow a class to designate a replacement object - for the object just read from the stream - - (See [Section 3.7, "The readResolve - Method](input.html#the-readresolve-method) for additional information.) - -`ObjectOutputStream` and `ObjectInputStream` allow the serializable classes on -which they operate to evolve (allow changes to the classes that are compatible -with the earlier versions of the classes). See [Section 5.5, "Compatible Java -Type Evolution"](version.html#compatible-java-type-evolution) for information -about the mechanism which is used to allow compatible changes. - -**Note:** Serialization of inner classes (i.e., nested classes that are not -static member classes), including local and anonymous classes, is strongly -discouraged for several reasons. Because inner classes declared in non-static -contexts contain implicit non-transient references to enclosing class -instances, serializing such an inner class instance will result in -serialization of its associated outer class instance as well. Synthetic fields -generated by `javac` (or other Java^TM^ compilers) to implement inner classes -are implementation dependent and may vary between compilers; differences in -such fields can disrupt compatibility as well as result in conflicting default -`serialVersionUID` values. The names assigned to local and anonymous inner -classes are also implementation dependent and may differ between compilers. -Since inner classes cannot declare static members other than compile-time -constant fields, they cannot use the `serialPersistentFields` mechanism to -designate serializable fields. Finally, because inner classes associated with -outer instances do not have zero-argument constructors (constructors of such -inner classes implicitly accept the enclosing instance as a prepended -parameter), they cannot implement `Externalizable`. None of the issues listed -above, however, apply to static member classes. - -## 1.11 The Externalizable Interface - -For Externalizable objects, only the identity of the class of the object is -saved by the container; the class must save and restore the contents. The -`Externalizable` interface is defined as follows: - -``` -package java.io; - -public interface Externalizable extends Serializable -{ - public void writeExternal(ObjectOutput out) - throws IOException; - - public void readExternal(ObjectInput in) - throws IOException, java.lang.ClassNotFoundException; -} -``` - -The class of an Externalizable object must do the following: - -- Implement the `java.io.Externalizable` interface - -- Implement a `writeExternal` method to save the state of the object - - (It must explicitly coordinate with its supertype to save its state.) - -- Implement a `readExternal` method to read the data written by the - `writeExternal` method from the stream and restore the state of the object - - (It must explicitly coordinate with the supertype to save its state.) - -- Have the `writeExternal` and `readExternal` methods be solely responsible - for the format, if an externally defined format is written - - **Note:** The `writeExternal` and `readExternal` methods are public and - raise the risk that a client may be able to write or read information in - the object other than by using its methods and fields. These methods must - be used only when the information held by the object is not sensitive or - when exposing it does not present a security risk. - -- Have a public no-arg constructor - - **Note:** Inner classes associated with enclosing instances cannot have - no-arg constructors, since constructors of such classes implicitly accept - the enclosing instance as a prepended parameter. Consequently the - `Externalizable` interface mechanism cannot be used for inner classes and - they should implement the `Serializable` interface, if they must be - serialized. Several limitations exist for serializable inner classes as - well, however; see [Section 1.10, "The Serializable - Interface"](#the-serializable-interface), for a full enumeration. - -An Externalizable class can optionally define the following methods: - -- A `writeReplace` method to allow a class to nominate a replacement object - to be written to the stream - - (See [Section 2.5, "The writeReplace - Method"](output.html#the-writereplace-method) for additional information.) - -- A `readResolve` method to allow a class to designate a replacement object - for the object just read from the stream - - (See [Section 3.7, "The readResolve - Method"](input.html#the-readresolve-method) for additional information.) - -## 1.12 Serialization of Enum Constants - -Enum constants are serialized differently than ordinary serializable or -externalizable objects. The serialized form of an enum constant consists solely -of its name; field values of the constant are not present in the form. To -serialize an enum constant, `ObjectOutputStream` writes the value returned by -the enum constant's `name` method. To deserialize an enum constant, -`ObjectInputStream` reads the constant name from the stream; the deserialized -constant is then obtained by calling the `java.lang.Enum.valueOf` method, -passing the constant's enum type along with the received constant name as -arguments. Like other serializable or externalizable objects, enum constants -can function as the targets of back references appearing subsequently in the -serialization stream. - -The process by which enum constants are serialized cannot be customized: any -class-specific `writeObject`, `readObject`, `readObjectNoData`, `writeReplace`, -and `readResolve` methods defined by enum types are ignored during -serialization and deserialization. Similarly, any `serialPersistentFields` or -`serialVersionUID` field declarations are also ignored--all enum types have a -fixed `serialVersionUID` of `0L`. Documenting serializable fields and data for -enum types is unnecessary, since there is no variation in the type of data -sent. - -## 1.13 Protecting Sensitive Information - -When developing a class that provides controlled access to resources, care must -be taken to protect sensitive information and functions. During -deserialization, the private state of the object is restored. For example, a -file descriptor contains a handle that provides access to an operating system -resource. Being able to forge a file descriptor would allow some forms of -illegal access, since restoring state is done from a stream. Therefore, the -serializing runtime must take the conservative approach and not trust the -stream to contain only valid representations of objects. To avoid compromising -a class, the sensitive state of an object must not be restored from the stream, -or it must be reverified by the class. Several techniques are available to -protect sensitive data in classes. - -The easiest technique is to mark fields that contain sensitive data as *private -transient*. Transient fields are not persistent and will not be saved by any -persistence mechanism. Marking the field will prevent the state from appearing -in the stream and from being restored during deserialization. Since writing and -reading (of private fields) cannot be superseded outside of the class, the -transient fields of the class are safe. - -Particularly sensitive classes should not be serialized at all. To accomplish -this, the object should not implement either the `Serializable` or the -`Externalizable` interface. - -Some classes may find it beneficial to allow writing and reading but -specifically handle and revalidate the state as it is deserialized. The class -should implement `writeObject` and `readObject` methods to save and restore -only the appropriate state. If access should be denied, throwing a -`NotSerializableException` will prevent further access. - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.base/share/specs/serialization/version.md b/jdk/src/java.base/share/specs/serialization/version.md deleted file mode 100644 index 5f4d0e7d4a9..00000000000 --- a/jdk/src/java.base/share/specs/serialization/version.md +++ /dev/null @@ -1,304 +0,0 @@ ---- -# Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -include-before: '[CONTENTS](index.html) | [PREV](class.html) | [NEXT](protocol.html)' -include-after: '[CONTENTS](index.html) | [PREV](class.html) | [NEXT](protocol.html)' - -title: 'Java Object Serialization Specification: 5 - Versioning of Serializable Objects' ---- - -- [Overview](#overview) -- [Goals](#goals) -- [Assumptions](#assumptions) -- [Who's Responsible for Versioning of - Streams](#whos-responsible-for-versioning-of-streams) -- [Compatible Java Type Evolution](#compatible-java-type-evolution) -- [Type Changes Affecting - Serialization](#type-changes-affecting-serialization) - -------------------------------------------------------------------------------- - -## 5.1 Overview - -When Java objects use serialization to save state in files, or as blobs in -databases, the potential arises that the version of a class reading the data is -different than the version that wrote the data. - -Versioning raises some fundamental questions about the identity of a class, -including what constitutes a compatible change. A ***compatible change*** is a -change that does not affect the contract between the class and its callers. - -This section describes the goals, assumptions, and a solution that attempts to -address this problem by restricting the kinds of changes allowed and by -carefully choosing the mechanisms. - -The proposed solution provides a mechanism for "automatic" handling of classes -that evolve by adding fields and adding classes. Serialization will handle -versioning without class-specific methods to be implemented for each version. -The stream format can be traversed without invoking class-specific methods. - -## 5.2 Goals - -The goals are to: - -- Support bidirectional communication between different versions of a class - operating in different virtual machines by: - - - Defining a mechanism that allows Java classes to read streams written - by older versions of the same class. - - - Defining a mechanism that allows Java classes to write streams intended - to be read by older versions of the same class. - -- Provide default serialization for persistence and for RMI. - -- Perform well and produce compact streams in simple cases, so that RMI can - use serialization. - -- Be able to identify and load classes that match the exact class used to - write the stream. - -- Keep the overhead low for nonversioned classes. - -- Use a stream format that allows the traversal of the stream without having - to invoke methods specific to the objects saved in the stream. - -## 5.3 Assumptions - -The assumptions are that: - -- Versioning will only apply to serializable classes since it must control - the stream format to achieve it goals. Externalizable classes will be - responsible for their own versioning which is tied to the external format. - -- All data and objects must be read from, or skipped in, the stream in the - same order as they were written. - -- Classes evolve individually as well as in concert with supertypes and - subtypes. - -- Classes are identified by name. Two classes with the same name may be - different versions or completely different classes that can be - distinguished only by comparing their interfaces or by comparing hashes of - the interfaces. - -- Default serialization will not perform any type conversions. - -- The stream format only needs to support a linear sequence of type changes, - not arbitrary branching of a type. - -## 5.4 Who's Responsible for Versioning of Streams - -In the evolution of classes, it is the responsibility of the evolved (later -version) class to maintain the contract established by the nonevolved class. -This takes two forms. First, the evolved class must not break the existing -assumptions about the interface provided by the original version, so that the -evolved class can be used in place of the original. Secondly, when -communicating with the original (or previous) versions, the evolved class must -provide sufficient and equivalent information to allow the earlier version to -continue to satisfy the nonevolved contract. - -> ![*Private serialization protocol and contract with supertype relationships - between evolved and nonevolved classes and their - instances*](images/version.gif) - -For the purposes of the discussion here, each class implements and extends the -interface or contract defined by its supertype. New versions of a class, for -example `foo'`, must continue to satisfy the contract for `foo` and may extend -the interface or modify its implementation. - -Communication between objects via serialization is not part of the contract -defined by these interfaces. Serialization is a private protocol between the -implementations. It is the responsibility of the implementations to communicate -sufficiently to allow each implementation to continue to satisfy the contract -expected by its clients. - -## 5.5 Compatible Java Type Evolution - -The Java Language Specification discusses binary compatibility of Java classes -as those classes evolve. Most of the flexibility of binary compatibility comes -from the use of late binding of symbolic references for the names of classes, -interfaces, fields, methods, and so on. - -The following are the principle aspects of the design for versioning of -serialized object streams. - -- The default serialization mechanism will use a symbolic model for binding - the fields in the stream to the fields in the corresponding class in the - virtual machine. - -- Each class referenced in the stream will uniquely identify itself, its - supertype, and the types and names of each serializable field written to - the stream. The fields are ordered with the primitive types first sorted by - field name, followed by the object fields sorted by field name. - -- Two types of data may occur in the stream for each class: required data - (corresponding directly to the serializable fields of the object); and - optional data (consisting of an arbitrary sequence of primitives and - objects). The stream format defines how the required and optional data - occur in the stream so that the whole class, the required, or the optional - parts can be skipped if necessary. - - - The required data consists of the fields of the object in the order - defined by the class descriptor. - - - The optional data is written to the stream and does not correspond - directly to fields of the class. The class itself is responsible for - the length, types, and versioning of this optional information. - -- If defined for a class, the `writeObject`/`readObject` methods supersede - the default mechanism to write/read the state of the class. These methods - write and read the optional data for a class. The required data is written - by calling `defaultWriteObject` and read by calling `defaultReadObject`. - -- The stream format of each class is identified by the use of a Stream Unique - Identifier (SUID). By default, this is the hash of the class. All later - versions of the class must declare the Stream Unique Identifier (SUID) that - they are compatible with. This guards against classes with the same name - that might inadvertently be identified as being versions of a single class. - -- Subtypes of `ObjectOutputStream` and `ObjectInputStream` may include their - own information identifying the class using the `annotateClass` method; for - example, `MarshalOutputStream` embeds the URL of the class. - -## 5.6 Type Changes Affecting Serialization - -With these concepts, we can now describe how the design will cope with the -different cases of an evolving class. The cases are described in terms of a -stream written by some version of a class. When the stream is read back by the -same version of the class, there is no loss of information or functionality. -The stream is the only source of information about the original class. Its -class descriptions, while a subset of the original class description, are -sufficient to match up the data in the stream with the version of the class -being reconstituted. - -The descriptions are from the perspective of the stream being read in order to -reconstitute either an earlier or later version of the class. In the parlance -of RPC systems, this is a "receiver makes right" system. The writer writes its -data in the most suitable form and the receiver must interpret that information -to extract the parts it needs and to fill in the parts that are not available. - -### 5.6.1 Incompatible Changes - -Incompatible changes to classes are those changes for which the guarantee of -interoperability cannot be maintained. The incompatible changes that may occur -while evolving a class are: - -- Deleting fields - If a field is deleted in a class, the stream written will - not contain its value. When the stream is read by an earlier class, the - value of the field will be set to the default value because no value is - available in the stream. However, this default value may adversely impair - the ability of the earlier version to fulfill its contract. - -- Moving classes up or down the hierarchy - This cannot be allowed since the - data in the stream appears in the wrong sequence. - -- Changing a nonstatic field to static or a nontransient field to transient - - When relying on default serialization, this change is equivalent to - deleting a field from the class. This version of the class will not write - that data to the stream, so it will not be available to be read by earlier - versions of the class. As when deleting a field, the field of the earlier - version will be initialized to the default value, which can cause the class - to fail in unexpected ways. - -- Changing the declared type of a primitive field - Each version of the class - writes the data with its declared type. Earlier versions of the class - attempting to read the field will fail because the type of the data in the - stream does not match the type of the field. - -- Changing the `writeObject` or `readObject` method so that it no longer - writes or reads the default field data or changing it so that it attempts - to write it or read it when the previous version did not. The default field - data must consistently either appear or not appear in the stream. - -- Changing a class from `Serializable` to `Externalizable` or vice versa is - an incompatible change since the stream will contain data that is - incompatible with the implementation of the available class. - -- Changing a class from a non-enum type to an enum type or vice versa since - the stream will contain data that is incompatible with the implementation - of the available class. - -- Removing either `Serializable` or `Externalizable` is an incompatible - change since when written it will no longer supply the fields needed by - older versions of the class. - -- Adding the `writeReplace` or `readResolve` method to a class is - incompatible if the behavior would produce an object that is incompatible - with any older version of the class. - -### 5.6.2 Compatible Changes - -The compatible changes to a class are handled as follows: - -- Adding fields - When the class being reconstituted has a field that does - not occur in the stream, that field in the object will be initialized to - the default value for its type. If class-specific initialization is needed, - the class may provide a readObject method that can initialize the field to - nondefault values. - -- Adding classes - The stream will contain the type hierarchy of each object - in the stream. Comparing this hierarchy in the stream with the current - class can detect additional classes. Since there is no information in the - stream from which to initialize the object, the class's fields will be - initialized to the default values. - -- Removing classes - Comparing the class hierarchy in the stream with that of - the current class can detect that a class has been deleted. In this case, - the fields and objects corresponding to that class are read from the - stream. Primitive fields are discarded, but the objects referenced by the - deleted class are created, since they may be referred to later in the - stream. They will be garbage-collected when the stream is garbage-collected - or reset. - -- Adding `writeObject`/`readObject` methods - If the version reading the - stream has these methods then `readObject` is expected, as usual, to read - the required data written to the stream by the default serialization. It - should call `defaultReadObject` first before reading any optional data. The - `writeObject` method is expected as usual to call `defaultWriteObject` to - write the required data and then may write optional data. - -- Removing `writeObject`/`readObject` methods - If the class reading the - stream does not have these methods, the required data will be read by - default serialization, and the optional data will be discarded. - -- Adding `java.io.Serializable` - This is equivalent to adding types. There - will be no values in the stream for this class so its fields will be - initialized to default values. The support for subclassing nonserializable - classes requires that the class's supertype have a no-arg constructor and - the class itself will be initialized to default values. If the no-arg - constructor is not available, the `InvalidClassException` is thrown. - -- Changing the access to a field - The access modifiers public, package, - protected, and private have no effect on the ability of serialization to - assign values to the fields. - -- Changing a field from static to nonstatic or transient to nontransient - - When relying on default serialization to compute the serializable fields, - this change is equivalent to adding a field to the class. The new field - will be written to the stream but earlier classes will ignore the value - since serialization will not assign values to static or transient fields. - -------------------------------------------------------------------------------- - -*[Copyright](../../../legal/SMICopyright.html) © 2005, 2017, Oracle -and/or its affiliates. All rights reserved.* diff --git a/jdk/src/java.desktop/share/specs/AWT_Native_Interface.html b/jdk/src/java.desktop/share/specs/AWT_Native_Interface.html deleted file mode 100644 index 782376099a8..00000000000 --- a/jdk/src/java.desktop/share/specs/AWT_Native_Interface.html +++ /dev/null @@ -1,776 +0,0 @@ - - - - - -Java AWT Native Interface Specification and Guide - - -

The Java AWT Native Interface Specification and Guide

-

Introduction

-

The Java AWT Native Interface (JAWT) comprises a small set of native -(eg C language-based) APIs that provide a standard supported way -for interaction between Java API windows and surfaces, and -platform native API windows and surfaces. -Non-Java libraries may then render to a Java owned window. -

-Note: in this document the terms "Java AWT Native Interface", -"AWT Native Interface" and "JAWT" are interchangeable and -refer to this same specification. -

-The fundamental obstacle to native rendering without JAWT is that -is that the rendering code cannot identify where to draw. -The native code needs access to information about a Java -drawing surface (such as a handle to the underlying native ID of a -Canvas), but cannot get it.

-Without that information (ie without JAWT) an application could -use native rendering only by creating its own top-level window -not shared at all with Java. This is unacceptable for most uses. -Except for usage via JAWT, this is considered to be entirely -internal to the Java platform implementation: private, unsupported -and undocumented. -

-JAWT should be supported in all headful implementations -where technically possible although this is not enforced by the JCK. -There is a platform-specific and a platform -independent portion to the API, to account for the differing -data structures and requirements of each platform. -This document specifies the platform independent portions and -also documents the platform dependent portions for the Oracle JDK -supported desktop operating environments. -For AWT the term platform is less tied to the underlying operating -system than it is to the desktop windowing environment. -

-Reasons for using the AWT Native Interface include -

    -
  • Use of a 3rd party native library not available in Java -
  • A temporary porting aid before converting legacy code to Java -
  • Rendering performance available only to native hardware accelerated APIs -
  • Interoperation with another toolkit -
-

-Drawbacks include -

    -
  • A more complex application implementation, eg for painting -
  • Potential for application instability if the native library does -not interoperate properly with AWT. -
  • Increased application delivery complexity - per platform binaries -
-The header file "jawt.h" -in the Appendix fully specifies the APIs provided by JAWT. -

-An example illustrating how easy it is to use the AWT Native Interface -is presented and discussed later in this document.

- -

JAWT usage depends on JNI

-

The definition of Java Standard Edition includes JNI, the Java -Native Interface. Many Java developers will never need to use it, -but the interface is the only standard supported way for a Java -language program to interact directly with -application code that has been compiled to the native machine -instructions for the host processor architecture. -JNI is used where ever there is a need for mixed languages. -These are by no means limited to cases like AWT. For example, you -could use JNI to integrate with native code that communicates with -a peripheral device, such as a scanner, connected to a system via a -USB port.

-

So JNI is general enough to be used to access almost any -sort of native library. -The rest of this document assumes a familiarity with how -to use JNI. - -

How to use JAWT

-

In this section we describe the most common usage of the AWT -Native Interface — overriding the paint method to -direct drawing operations to a native rendering library which then -queries the Java VM to determine the information it needs in order -to render. Note, however, that any native code may use the AWT -Native Interface to learn about a target drawing surface, not just -code in a paint method.

-

The first step in hooking up a native rendering library to a -Java Canvas is to define a new class that extends -Canvas and overrides the paint method. The Java -system routes all drawing operations for a Canvas object -through the paint method, as it does for all other GUI -objects. Canvas is a good candidate for the rendering surface as -it does not have any content as a Button would.

-

The new paint method, to be implemented in the native -rendering library, must be declared as public native void -, and the native library itself is loaded at runtime by including a -call to System.loadLibrary( "myRenderingLib")in -the static block of the class. The myRenderingLib -name is used for the native shared library; for Linux or the Solaris -operating environment, the actual name for the library file on disk -is libmyRenderingLib.so .

-

Here is a simple example of such a class:

-
-import java.awt.*;
-import java.awt.event.*;
-
-public class MyCanvas extends Canvas {
-    static {
-        System.loadLibrary("myRenderingLib");
-    }
-    public native void paint(Graphics g);
-
-    public static void main(String[] args) {
-        Frame f = new Frame();
-        f.setBounds(0, 0, 500, 110);
-        f.add(new MyCanvas());
-        f.addWindowListener( new WindowAdapter() {
-            public void windowClosing(WindowEvent ev) {
-                System.exit(0);
-            }
-        } );
-        f.show();
-    }
-}
-
-
-

Note that this class has a main method that can be used -to run this code as an application for testing purposes.

-

The next step is to run the javah tool on the -MyCanvas class file above to generate a C/C++ header file -that describes the interface to the native paint method -that Java expects to be used. javah is a standard tool -included with the JDK. NB: javac -h outputdir may also be used.

- -

The final step ­ and the most interesting one ­ is to -write the native rendering method, with an interface that conforms -to the header file that javah generated, and build it as a -standard shared library (called myRenderingLib in the -above example) by linking it, against the appropriate JDK provided -$JDK_HOME/lib/$JAWT_LIB library for the target platform. -Where JAWT_LIB has the base name "jawt" and follows platform -shared object naming rules. i.e.: -

    -
  • Windows: jawt.dll -
  • MacOS: libjawt.dylib -
  • Linux: libjawt.so -
  • Solaris: libjawt.so -
- -This code will call back to the Java virtual machine to -get the drawing surface information it needs to access the -MyCanvas peer. Once this information is available, the -code can draw directly to MyCanvas using standard drawing -routines supplied by the underlying operating system.

-

Here is sample source code for a native paint method -designed for use in a X11-based drawing environment (Linux -or Solaris) and a Java VM where the AWT Native Interface is present:

-
-#include "MyCanvas.h"
-#include "jawt_md.h"
-
-/*
- * Class:     MyCanvas
- * Method:    paint
- * Signature: (Ljava/awt/Graphics;)V
- */
-JNIEXPORT void JNICALL Java_MyCanvas_paint
-(JNIEnv* env, jobject canvas, jobject graphics)
-{
-    JAWT awt;
-    JAWT_DrawingSurface* ds;
-    JAWT_DrawingSurfaceInfo* dsi;
-    JAWT_X11DrawingSurfaceInfo* dsi_x11;
-    jboolean result;
-    jint lock;
-    GC gc;
-
-    short       i;
-    char        *testString = "^^^ rendered from native code ^^^";
-
-    /* Get the AWT */
-    awt.version = JAWT_VERSION_9;
-    if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
-        printf("AWT Not found\n");
-        return;
-    }
-
-    /* Get the drawing surface */
-    ds = awt.GetDrawingSurface(env, canvas);
-    if (ds == NULL) {
-        printf("NULL drawing surface\n");
-        return;
-    }
-
-    /* Lock the drawing surface */
-    lock = ds->Lock(ds);
-    if((lock & JAWT_LOCK_ERROR) != 0) {
-        printf("Error locking surface\n");
-        awt.FreeDrawingSurface(ds);
-        return;
-    }
-
-    /* Get the drawing surface info */
-    dsi = ds->GetDrawingSurfaceInfo(ds);
-    if (dsi == NULL) {
-        printf("Error getting surface info\n");
-        ds->Unlock(ds);
-        awt.FreeDrawingSurface(ds);
-        return;
-    }
-
-    /* Get the platform-specific drawing info */
-    dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
-
-
-    /* Now paint */
-    gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
-    XSetBackground(dsi_x11->display, gc, 0);
-    for (i=0; i<36;i++)
-    {
-        XSetForeground(dsi_x11->display, gc, 10*i);
-        XFillRectangle(dsi_x11->display, dsi_x11->drawable, gc,
-                        10*i, 5, 90, 90);
-    }
-    XSetForeground(dsi_x11->display, gc, 155);
-    XDrawImageString(dsi_x11->display, dsi_x11->drawable, gc,
-                        100, 110, testString, strlen(testString));
-    XFreeGC(dsi_x11->display, gc);
-
-
-    /* Free the drawing surface info */
-    ds->FreeDrawingSurfaceInfo(dsi);
-
-    /* Unlock the drawing surface */
-    ds->Unlock(ds);
-
-    /* Free the drawing surface */
-    awt.FreeDrawingSurface(ds);
-}
-
-

The key data structure here is JAWT , which is defined -in jawt.h (included by jawt_md.h) ; it provides -access to all the information the native code needs to get the job -done. The first part of the native method is boilerplate: it -populates the JAWT structure, gets a -JAWT_DrawingSurface structure, locks the surface (only one -drawing engine at a time, please!), then gets a -JAWT_DrawingSurfaceInfo structure that contains a pointer -(in the platformInfo field) to the necessary -platform-specific drawing information. It also includes the -bounding rectangle of the drawing surface and the current clipping -region.

-

The structure of the information pointed to by -platformInfo is defined in a machine-dependent header file -called jawt_md.h. For X11 drawing, it includes -information about the X11 display and X11 drawable associated with -MyCanvas. After the drawing operations are completed, -there is more boilerplate code as JAWT_DrawingSurfaceInfo -is freed and JAWT_DrawingSurface is unlocked and -freed.

-

The corresponding code for the GDI API on the Microsoft Windows platform would -be structured similarly, but would include the version of -jawt_md.h for Microsoft Windows and the structure located -in the platformInfo field of drawing surface info would be -cast as a JAWT_Win32DrawingSurfaceInfo* . And, of course, -the actual drawing operations would need to be changed to those -appropriate for the Microsoft Windows platform. -The same also for MacOS. -

-

Summary

-

The ability to draw directly into a Java Canvas from a -native code library is extremely useful for developers planning to -migrate a legacy software system to Java, especially one that -includes a high-performance rendering engine. It makes it much -easier to migrate in stages, leaving performance-sensitive -rendering code alone, while other less-sensitive portions of code -are converted to Java. The result can be a modern Java-centric -application, providing the benefit of portability and development -efficiency, but one that does not sacrifice an investment in -performance of a key piece of native code.

-

References

-

The definitive reference to the Java Native Interface is The -Java Native Interface: Programmer's Guide and Specification by -Sheng Liang. This book was published in June -1999 by Addison-Wesley. The ISBN is 0-201-32577-2.

-

Appendix

-

Header Files for jawt.h and jawt_md.h

- -

jawt.h

-
-#ifndef _JAVASOFT_JAWT_H_
-#define _JAVASOFT_JAWT_H_
-
-#include "jni.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * AWT native interface.
- *
- * The AWT native interface allows a native C or C++ application a means
- * by which to access native structures in AWT.  This is to facilitate moving
- * legacy C and C++ applications to Java and to target the needs of the
- * developers who need to do their own native rendering to canvases
- * for performance or other reasons.
- *
- * Conversely it also provides mechanisms for an application which already
- * has a native window to provide that to AWT for AWT rendering.
- *
- * Since every platform may be different in its native data structures
- * and APIs for windowing systems the application must necessarily
- * provided per-platform source and compile and deliver per-platform
- * native code  to use this API.
- *
- * These interfaces are not part of the Java SE specification and
- * a VM is not required to implement this API. However it is strongly
- * recommended that all implementations which support headful AWT
- * also support these interfaces.
- *
- */
-
-/*
- * AWT Native Drawing Surface (JAWT_DrawingSurface).
- *
- * For each platform, there is a native drawing surface structure.  This
- * platform-specific structure can be found in jawt_md.h.  It is recommended
- * that additional platforms follow the same model.  It is also recommended
- * that VMs on all platforms support the existing structures in jawt_md.h.
- *
- *******************
- * EXAMPLE OF USAGE:
- *******************
- *
- * On Microsoft Windows, a programmer wishes to access the HWND of a canvas
- * to perform native rendering into it.  The programmer has declared the
- * paint() method for their canvas subclass to be native:
- *
- *
- * MyCanvas.java:
- *
- * import java.awt.*;
- *
- * public class MyCanvas extends Canvas {
- *
- *     static {
- *         System.loadLibrary("mylib");
- *     }
- *
- *     public native void paint(Graphics g);
- * }
- *
- *
- * myfile.c:
- *
- * #include "jawt_md.h"
- * #include <assert.h>
- *
- * JNIEXPORT void JNICALL
- * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
- * {
- *     JAWT awt;
- *     JAWT_DrawingSurface* ds;
- *     JAWT_DrawingSurfaceInfo* dsi;
- *     JAWT_Win32DrawingSurfaceInfo* dsi_win;
- *     jboolean result;
- *     jint lock;
- *
- *     // Get the AWT. Request version 9 to access features in that release.
- *     awt.version = JAWT_VERSION_9;
- *     result = JAWT_GetAWT(env, &awt);
- *     assert(result != JNI_FALSE);
- *
- *     // Get the drawing surface
- *     ds = awt.GetDrawingSurface(env, canvas);
- *     assert(ds != NULL);
- *
- *     // Lock the drawing surface
- *     lock = ds->Lock(ds);
- *     assert((lock & JAWT_LOCK_ERROR) == 0);
- *
- *     // Get the drawing surface info
- *     dsi = ds->GetDrawingSurfaceInfo(ds);
- *
- *     // Get the platform-specific drawing info
- *     dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
- *
- *     //////////////////////////////
- *     // !!! DO PAINTING HERE !!! //
- *     //////////////////////////////
- *
- *     // Free the drawing surface info
- *     ds->FreeDrawingSurfaceInfo(dsi);
- *
- *     // Unlock the drawing surface
- *     ds->Unlock(ds);
- *
- *     // Free the drawing surface
- *     awt.FreeDrawingSurface(ds);
- * }
- *
- */
-
-/*
- * JAWT_Rectangle
- * Structure for a native rectangle.
- */
-typedef struct jawt_Rectangle {
-    jint x;
-    jint y;
-    jint width;
-    jint height;
-} JAWT_Rectangle;
-
-struct jawt_DrawingSurface;
-
-/*
- * JAWT_DrawingSurfaceInfo
- * Structure for containing the underlying drawing information of a component.
- */
-typedef struct jawt_DrawingSurfaceInfo {
-    /*
-     * Pointer to the platform-specific information.  This can be safely
-     * cast to a JAWT_Win32DrawingSurfaceInfo on Microsoft Windows or a
-     * JAWT_X11DrawingSurfaceInfo on Linux and Solaris. On MacOS this is a
-     * pointer to a NSObject that conforms to the JAWT_SurfaceLayers protocol.
-     * See jawt_md.h for details.
-     */
-    void* platformInfo;
-    /* Cached pointer to the underlying drawing surface */
-    struct jawt_DrawingSurface* ds;
-    /* Bounding rectangle of the drawing surface */
-    JAWT_Rectangle bounds;
-    /* Number of rectangles in the clip */
-    jint clipSize;
-    /* Clip rectangle array */
-    JAWT_Rectangle* clip;
-} JAWT_DrawingSurfaceInfo;
-
-#define JAWT_LOCK_ERROR                 0x00000001
-#define JAWT_LOCK_CLIP_CHANGED          0x00000002
-#define JAWT_LOCK_BOUNDS_CHANGED        0x00000004
-#define JAWT_LOCK_SURFACE_CHANGED       0x00000008
-
-/*
- * JAWT_DrawingSurface
- * Structure for containing the underlying drawing information of a component.
- * All operations on a JAWT_DrawingSurface MUST be performed from the same
- * thread as the call to GetDrawingSurface.
- */
-typedef struct jawt_DrawingSurface {
-    /* Cached reference to the Java environment of the calling thread.
-     * If Lock(), Unlock(), GetDrawingSurfaceInfo() or
-     * FreeDrawingSurfaceInfo() are called from a different thread,
-     * this data member should be set before calling those functions.
-     */
-    JNIEnv* env;
-    /* Cached reference to the target object */
-    jobject target;
-    /*
-     * Lock the surface of the target component for native rendering.
-     * When finished drawing, the surface must be unlocked with
-     * Unlock().  This function returns a bitmask with one or more of the
-     * following values:
-     *
-     * JAWT_LOCK_ERROR - When an error has occurred and the surface could not
-     * be locked.
-     *
-     * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
-     *
-     * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
-     *
-     * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
-     */
-    jint (JNICALL *Lock)
-        (struct jawt_DrawingSurface* ds);
-    /*
-     * Get the drawing surface info.
-     * The value returned may be cached, but the values may change if
-     * additional calls to Lock() or Unlock() are made.
-     * Lock() must be called before this can return a valid value.
-     * Returns NULL if an error has occurred.
-     * When finished with the returned value, FreeDrawingSurfaceInfo must be
-     * called.
-     */
-    JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
-        (struct jawt_DrawingSurface* ds);
-    /*
-     * Free the drawing surface info.
-     */
-    void (JNICALL *FreeDrawingSurfaceInfo)
-        (JAWT_DrawingSurfaceInfo* dsi);
-    /*
-     * Unlock the drawing surface of the target component for native rendering.
-     */
-    void (JNICALL *Unlock)
-        (struct jawt_DrawingSurface* ds);
-} JAWT_DrawingSurface;
-
-/*
- * JAWT
- * Structure for containing native AWT functions.
- */
-typedef struct jawt {
-    /*
-     * Version of this structure.  This must always be set before
-     * calling JAWT_GetAWT(). It affects the functions returned.
-     * Must be one of the known pre-defined versions.
-     */
-    jint version;
-    /*
-     * Return a drawing surface from a target jobject.  This value
-     * may be cached.
-     * Returns NULL if an error has occurred.
-     * Target must be a java.awt.Component (should be a Canvas
-     * or Window for native rendering).
-     * FreeDrawingSurface() must be called when finished with the
-     * returned JAWT_DrawingSurface.
-     */
-    JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
-        (JNIEnv* env, jobject target);
-    /*
-     * Free the drawing surface allocated in GetDrawingSurface.
-     */
-    void (JNICALL *FreeDrawingSurface)
-        (JAWT_DrawingSurface* ds);
-    /*
-     * Since 1.4
-     * Locks the entire AWT for synchronization purposes
-     */
-    void (JNICALL *Lock)(JNIEnv* env);
-    /*
-     * Since 1.4
-     * Unlocks the entire AWT for synchronization purposes
-     */
-    void (JNICALL *Unlock)(JNIEnv* env);
-    /*
-     * Since 1.4
-     * Returns a reference to a java.awt.Component from a native
-     * platform handle.  On Windows, this corresponds to an HWND;
-     * on Solaris and Linux, this is a Drawable.  For other platforms,
-     * see the appropriate machine-dependent header file for a description.
-     * The reference returned by this function is a local
-     * reference that is only valid in this environment.
-     * This function returns a NULL reference if no component could be
-     * found with matching platform information.
-     */
-    jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
-
-    /**
-     * Since 9
-     * Creates a java.awt.Frame placed in a native container. Container is
-     * referenced by the native platform handle. For example on Windows this
-     * corresponds to an HWND. For other platforms, see the appropriate
-     * machine-dependent header file for a description. The reference returned
-     * by this function is a local reference that is only valid in this
-     * environment. This function returns a NULL reference if no frame could be
-     * created with matching platform information.
-     */
-    jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo);
-
-    /**
-     * Since 9
-     * Moves and resizes the embedded frame. The new location of the top-left
-     * corner is specified by x and y parameters relative to the native parent
-     * component. The new size is specified by width and height.
-     *
-     * The embedded frame should be created by CreateEmbeddedFrame() method, or
-     * this function will not have any effect.
-     *
-     * java.awt.Component.setLocation() and java.awt.Component.setBounds() for
-     * EmbeddedFrame really don't move it within the native parent. These
-     * methods always locate the embedded frame at (0, 0) for backward
-     * compatibility. To allow moving embedded frames this method was
-     * introduced, and it works just the same way as setLocation() and
-     * setBounds() for usual, non-embedded components.
-     *
-     * Using usual get/setLocation() and get/setBounds() together with this new
-     * method is not recommended.
-     */
-    void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame,
-            jint x, jint y, jint w, jint h);
-    /**
-     * Since 9
-     * Synthesize a native message to activate or deactivate an EmbeddedFrame
-     * window depending on the value of parameter doActivate, if "true"
-     * activates the window; otherwise, deactivates the window.
-     *
-     * The embedded frame should be created by CreateEmbeddedFrame() method, or
-     * this function will not have any effect.
-     */
-    void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env,
-            jobject embeddedFrame, jboolean doActivate);
-} JAWT;
-
-/*
- * Get the AWT native structure.  This function returns JNI_FALSE if
- * an error occurs.
- */
-_JNI_IMPORT_OR_EXPORT_
-jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
-
-/*
- * Specify one of these constants as the JAWT.version
- * Specifying an earlier version will limit the available functions to
- * those provided in that earlier version of JAWT.
- * See the "Since" note on each API. Methods with no "Since"
- * may be presumed to be present in JAWT_VERSION_1_3.
- */
-#define JAWT_VERSION_1_3 0x00010003
-#define JAWT_VERSION_1_4 0x00010004
-#define JAWT_VERSION_1_7 0x00010007
-#define JAWT_VERSION_9 0x00090000
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* !_JAVASOFT_JAWT_H_ */
-
-
-

jawt_md.h (Linux/Solaris/X11 operating environment version)

-
-#ifndef _JAVASOFT_JAWT_MD_H_
-#define _JAVASOFT_JAWT_MD_H_
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Intrinsic.h>
-#include "jawt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * X11-specific declarations for AWT native interface.
- * See notes in jawt.h for an example of use.
- */
-typedef struct jawt_X11DrawingSurfaceInfo {
-    Drawable drawable;
-    Display* display;
-    VisualID visualID;
-    Colormap colormapID;
-    int depth;
-} JAWT_X11DrawingSurfaceInfo;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_JAVASOFT_JAWT_MD_H_ */
-
-

jawt_md.h (Microsoft Windows version)

-
-#ifndef _JAVASOFT_JAWT_MD_H_
-#define _JAVASOFT_JAWT_MD_H_
-
-#include <windows.h>
-#include "jawt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Microsoft Windows specific declarations for AWT native interface.
- * See notes in jawt.h for an example of use.
- */
-typedef struct jawt_Win32DrawingSurfaceInfo {
-    /* Native window, DDB, or DIB handle */
-    union {
-        HWND hwnd;
-        HBITMAP hbitmap;
-        void* pbits;
-    };
-    /*
-     * This HDC should always be used instead of the HDC returned from
-     * BeginPaint() or any calls to GetDC().
-     */
-    HDC hdc;
-    HPALETTE hpalette;
-} JAWT_Win32DrawingSurfaceInfo;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_JAVASOFT_JAWT_MD_H_ */
-
-

jawt_md.h (MacOS version)

-
-#ifndef _JAVASOFT_JAWT_MD_H_
-#define _JAVASOFT_JAWT_MD_H_
-
-#include "jawt.h"
-
-#ifdef __OBJC__
-#import 
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * MacOS specific declarations for AWT native interface.
- * See notes in jawt.h for an example of use.
- */
-
-/*
- * When calling JAWT_GetAWT with a JAWT version less than 1.7, you must pass this
- * flag or you will not be able to get a valid drawing surface and JAWT_GetAWT will
- * return false. This is to maintain compatibility with applications that used the
- * interface with Java 6 which had multiple rendering models. This flag is not necessary
- * when JAWT version 1.7 or greater is used as this is the only supported rendering mode.
- *
- * Example:
- *   JAWT awt;
- *   awt.version = JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER;
- *   jboolean success = JAWT_GetAWT(env, &awt);
- */
-#define JAWT_MACOSX_USE_CALAYER 0x80000000
-
-/*
- * When the native Cocoa toolkit is in use, the pointer stored in
- * JAWT_DrawingSurfaceInfo->platformInfo points to a NSObject that conforms to the
- * JAWT_SurfaceLayers protocol. Setting the layer property of this object will cause the
- * specified layer to be overlaid on the Components rectangle. If the window the
- * Component belongs to has a CALayer attached to it, this layer will be accessible via
- * the windowLayer property.
- */
-#ifdef __OBJC__
-@protocol JAWT_SurfaceLayers
-@property (readwrite, retain) CALayer *layer;
-@property (readonly) CALayer *windowLayer;
-@end
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_JAVASOFT_JAWT_MD_H_ */
-
- - - diff --git a/jdk/src/java.management/share/specs/JVM-MANAGEMENT-MIB.mib b/jdk/src/java.management/share/specs/JVM-MANAGEMENT-MIB.mib deleted file mode 100644 index b1d9eab3d85..00000000000 --- a/jdk/src/java.management/share/specs/JVM-MANAGEMENT-MIB.mib +++ /dev/null @@ -1,3266 +0,0 @@ --- --- --- --- Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. --- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. --- --- This code is free software; you can redistribute it and/or modify it --- under the terms of the GNU General Public License version 2 only, as --- published by the Free Software Foundation. Oracle designates this --- particular file as subject to the "Classpath" exception as provided --- by Oracle in the LICENSE file that accompanied this code. --- --- This code is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or --- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --- version 2 for more details (a copy is included in the LICENSE file that --- accompanied this code). --- --- You should have received a copy of the GNU General Public License version --- 2 along with this work; if not, write to the Free Software Foundation, --- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. --- --- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA --- or visit www.oracle.com if you need additional information or have any --- questions. --- --- --- The JVM-MANAGEMENT-MIB Module --- --- See jvmManagementMIB MODULE-IDENTITY for a description overview. --- See conformance statements for mandatory objects --- - -JVM-MANAGEMENT-MIB DEFINITIONS ::= BEGIN - -IMPORTS - MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE, Counter32, Gauge32, - Integer32, Counter64, enterprises - FROM SNMPv2-SMI - DisplayString, TEXTUAL-CONVENTION, RowPointer - FROM SNMPv2-TC - MODULE-COMPLIANCE, OBJECT-GROUP, NOTIFICATION-GROUP - FROM SNMPv2-CONF; - --- Module Identity ------------------- - -jvmMgtMIB MODULE-IDENTITY - LAST-UPDATED "200403041800Z" - -- Format is "YYYYMMDDhhmmZ" - ORGANIZATION "Sun Microsystems, Inc." - CONTACT-INFO "Sun Microsystems, Inc. - 4150 Network Circle - Santa Clara, CA 95054 - 1-800-555-9SUN or - 1-650-960-1300 - http://www.sun.com - or contact your local support representative" - DESCRIPTION - "Copyright 2004 Sun Microsystems, Inc. All rights reserved. - - This module defines the MIB that provides access to the - Java[tm] Virtual Machine monitoring data. - This module is derived from the Java[tm] programming language APIs - described in the java.lang.management package of - Java[tm] 2, Standard Edition, 5.0. - - See the Java programming language APIs of JSR 163 for - 'Monitoring and Management of the Java[TM] Virtual Machine' - for more details. - - Where the Java programming language API uses long, or int, - the MIB often uses the corresponding unsigned quantity - - which is closer to the object semantics. - - In those cases, it often happens that the -1 value that might - be used by the API to indicate an unknown/unimplemented - value cannot be used. Instead the MIB uses the value 0, which - stricly speaking cannot be distinguished from a valid value. - In many cases however, a running system will have non-zero - values, so using 0 instead of -1 to indicate an unknown - quantity does not lose any functionality. - " - REVISION "200403041800Z" - -- Format is "YYYYMMDDhhmmZ" - DESCRIPTION - " - JVM-MANAGEMENT-MIB - JSR 163 Final Release 1.0 - " - - ::= { standard jsr163(163) 1 } - - --- Enterprise OIDs ------------------- - --- internet OBJECT IDENTIFIER ::= { iso(1) org(3) dod(6) 1 } --- private OBJECT IDENTIFIER ::= { internet 4 } --- enterprises OBJECT IDENTIFIER ::= { private 1 } - sun OBJECT IDENTIFIER ::= { enterprises 42 } - jmgt OBJECT IDENTIFIER ::= { sun products(2) 145 } - -- experimental OBJECT IDENTIFIER ::= { jmgt 1 } - standard OBJECT IDENTIFIER ::= { jmgt 3 } - ----------------------------------------------------------------------------- --- Textual Conventions ----------------------- --- --- Note: Some of the TEXTUAL-CONVENTIONs defined in this module are --- OCTET STRING with a 1023 size limitation (SIZE(0..1023)). --- --- As per RFC2578, section 7.1.2. OCTET STRING: --- --- "The OCTET STRING type represents arbitrary binary or textual data. --- Although the SMI-specified size limitation for this type is 65535 --- octets, MIB designers should realize that there may be --- implementation and interoperability limitations for sizes in --- excess of 255 octets." --- --- As a consequence an agent implementing this MIB may decide to --- restrict this maximum size to a lesser value than 1023, provided that --- it makes it clear in an AGENT-CAPABILITY statement. --- ----------------------------------------------------------------------------- - -JvmUnsigned64TC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "A non-negative 64-bit bit integer, without counter - semantics." - -- We have cloned the Unsigned64TC defined in RFC 2564 rather - -- than importing it because the JVM-MANAGEMENT-MIB and the - -- APPLICATION-MIB are not related. - -- - REFERENCE "RFC 2564 - APPLICATION-MIB, Unsigned64TC." - SYNTAX Counter64 - - -JvmJavaObjectNameTC ::= TEXTUAL-CONVENTION - DISPLAY-HINT "255a" - STATUS current - DESCRIPTION - "An Object Name, as implemented by the java.lang.management API, - which identify a runtime Object (e.g. a Class Loader, a - Memory Manager, etc...). - The name is assumed to be unique in the scope of the object's - class. - - This object syntax is equivalent to a DisplayString, but with a - a 1023 bytes size limits (instead of 255 for a DisplayString). - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in this type. - (1023 bytes max). - " - SYNTAX OCTET STRING (SIZE (0..1023)) - -JvmPathElementTC ::= TEXTUAL-CONVENTION - DISPLAY-HINT "255a" - STATUS current - DESCRIPTION - "A file or directory element in a PATH/CLASSPATH/LIBRARY_PATH - structure. - - This object syntax is equivalent to a DisplayString, but with a - a 1023 bytes size limits (instead of 255 for a DisplayString). - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in this type. - (1023 bytes max). - " - SYNTAX OCTET STRING (SIZE (0..1023)) - -JvmArgValueTC ::= TEXTUAL-CONVENTION - DISPLAY-HINT "255a" - STATUS current - DESCRIPTION - "A string representing an input argument. - - This object syntax is equivalent to a DisplayString, but with a - a 1023 bytes size limits (instead of 255 for a DisplayString). - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in this type. - (1023 bytes max). - " - SYNTAX OCTET STRING (SIZE (0..1023)) - -JvmVerboseLevelTC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "Defines whether the verbose flag for a feature is active. - verbose: the flag is on. - silent: the flag is off. - " - SYNTAX INTEGER { silent(1), verbose(2) } - - -JvmImplSupportStateTC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "Defines whether a feature is supported or not. - " - SYNTAX INTEGER { unsupported(1), supported(2) } - -JvmImplOptFeatureStateTC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "Defines whether an optional feature is supported, enabled, - or disabled. - - An optional feature can be: - - unsupported: The JVM does not support this feature. - enabled : The JVM supports this feature, and it - is enabled. - disabled : The JVM supports this feature, and it - is disabled. - - Only enabled(3) and disabled(4) may be supplied as values to a - SET request. unsupported(1) can only be set internally by the - agent. - " - SYNTAX INTEGER { unsupported(1), enabled(3), disabled(4) } - -JvmTimeMillis64TC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "An elapsed time, expressed in milli-seconds. - This type is based on Counter64, but without its specific - semantics. - " - SYNTAX Counter64 - -JvmTimeNanos64TC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "An elapsed time, expressed in nano-seconds. - This type is based on Counter64, but without its specific - semantics. - " - SYNTAX Counter64 - -JvmPositive32TC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "A positive Integer32. In Java that would be a number - in [0..Integer.MAX_VALUE]. - " - -- We use Integer32 (0..2147483647) rather than Unsigned32 because - -- Unsigned32 (0..2147483647) because Unsigned32 is based on - -- Gauge32 - which has a specific ASN.1 tag and a specific semantics. - -- In principle you cannot use a Gauge32 as base type for an index - -- in a table. - -- Note also that Unsigned32 is (0..2^32-1) - -- while Positive32 is (0..2^31-1) - -- - SYNTAX Integer32 (0..2147483647) - -JvmManagedMemoryTypeTC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - " - Defines the type of memory contained in a memory pool. - The pool may contain, heap memory or non-heap memory. - " - SYNTAX INTEGER { nonheap(1), heap(2) } - - -JvmValidityStateTC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - " - Defines whether an object is still valid. - " - SYNTAX INTEGER { invalid(1), valid(2) } - - -JvmThreadStateTC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "Defines the possible states of a thread running in the - Java virtual machine. They are virtual machine thread states - and do not reflect any operating system thread states. - - The first two bits: inNative(1) and suspended(2) can be - combined together and with any other bits. The remaining - bits 3-9, are mutually exclusive. Bits 10-16 are reserved - for future evolution of this MIB. - - An agent MUST always return a thread state with one of the - bits in the range 3-9 set to 1. The other(9) bit should only - be set to 1 if new thread states which are mutally exclusive - with bits 3-8 are defined. An implementation can define - additional implementation dependant states and uses bits - from bit 17. - - See java.lang.Thread.State, - java.lang.management.ThreadInfo. - " - -- - -- Take care that in SNMP bits are numbered starting at 1, from - -- left to right (1 is the highest bit). A bitmap defined by the - -- BITS construct is thus a byte array where bit 1 is the highest bit - -- of the first byte. - -- - SYNTAX BITS { -- Bits 1-2 may be specified in any combination - inNative(1), - suspended(2), - - -- Bits 3-9 are mutually exclusive. Attempting to - -- set more than a single bit to 1 will result in - -- a returned error-status of inconsistentValue. - newThread(3), - runnable(4), - blocked(5), - terminated(6), - waiting(7), - timedWaiting(8), - other(9) - -- Bits 10-16 are reserved for future use by - -- this MIB - } - - -JvmIndex64TC ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "A 64 bits string mapping an unsigned 64 bits integer value - in big-endian ordering (i.e: 1 is encoded as 0x0000000000000001). - - This type can be used when an unsigned 64 bits integer needs - to be used inside a table index. - " - SYNTAX OCTET STRING (SIZE(8)) - - --- OBJECT-TYPE OID tree ------------------------ - -jvmMgtMIBObjects - OBJECT IDENTIFIER ::= { jvmMgtMIB 1 } -jvmMgtMIBNotifications - OBJECT IDENTIFIER ::= { jvmMgtMIB 2 } -jvmMgtMIBConformance - OBJECT IDENTIFIER ::= { jvmMgtMIB 3 } - ------------------------------------------------------------------------ --- --- The JVM Class Loading group --- --- A collection of objects used to monitor Class Loading in the --- Java Virtual Machine. These objects define the SNMP management --- interface for the class loading system of the Java virtual machine. --- --- This group only contains a few scalar object and no tables. The objects --- from this group are mapped from the java.lang.management.ClassLoadingMXBean --- interface. --- --- See J2SE 5.0 API Specification, --- java.lang.management.ClassLoadingMXBean ------------------------------------------------------------------------ - --- Root OBJECT IDENTIFIER for ClassLoading group. --- -jvmClassLoading OBJECT IDENTIFIER ::= { jvmMgtMIBObjects 1 } - --- The following objects are mapped from the ClassLoadingMXBean interface. ------------------------------------------------------------------------ - -jvmClassesLoadedCount OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The number of classes currently loaded in the JVM. - - See java.lang.management.ClassLoadingMXBean.getLoadedClassCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ClassLoadingMXBean" - ::= { jvmClassLoading 1 } - -jvmClassesTotalLoadedCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The total number of classes that have been loaded since - the JVM has started execution. - - See java.lang.management.ClassLoadingMXBean. - getTotalLoadedClassCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ClassLoadingMXBean" - ::= { jvmClassLoading 2 } - -jvmClassesUnloadedCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The total number of classes that have been unloaded since - the JVM has started execution. - - See java.lang.management.ClassLoadingMXBean.getUnloadedClassCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ClassLoadingMXBean" - ::= { jvmClassLoading 3 } - -jvmClassesVerboseLevel OBJECT-TYPE - SYNTAX JvmVerboseLevelTC - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "Enables or disables the verbose output for the class loading - system. The verbose output information and the output stream - to which the verbose information is emitted are implementation - dependent. Typically, a Java virtual machine implementation - prints a message each time a class file is loaded. - - verbose: if the verbose output is enabled. - silent: otherwise. - - See java.lang.management.ClassLoadingMXBean.isVerbose(), - java.lang.management.ClassLoadingMXBean.setVerbose() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ClassLoadingMXBean" - DEFVAL { silent } - ::= { jvmClassLoading 4 } - - ------------------------------------------------------------------------ --- --- The JVM Memory group --- --- A collection of objects used to monitor memory management in the --- Java Virtual Machine. These objects define management interface for --- the memory system of the Java virtual machine. --- --- Memory: --- --- The memory system of the Java virtual machine manages the following --- kinds of memory: heap, and non-heap. More information on these types --- of memory can be obtained from the J2SE 5.0 API Specification, --- java.lang.management.MemoryMXBean. --- --- Memory Pools and Memory Managers: --- --- Memory pools and memory managers are the abstract entities that monitor --- and manage the memory system of the Java virtual machine. --- --- Memory managers are represented by the jvmMemManagerTable, which contains --- one row per Memory manager. --- The garbage collector is one type of memory manager responsible for --- reclaiming memory occupied by unreachable objects. --- The jvmMemGCTable is an extension of the jvmMemManagerTable, which contains --- the attribute specific to garbage collectors. A garbage collector entity --- is thus represented by one row in the jvmMemManagerTable, and one --- extension row in the jvmMemGCTable. --- --- Memory Pools are represented by the jvmMemPoolTable, which contains one --- row per memory pool. A Java virtual machine may create or remove --- memory pools during execution. A memory pool can belong to either the --- heap or the non-heap memory. --- --- A memory manager is responsible for managing one or more memory pools. --- A memory pool can be managed by more than one memory manager. --- The jvmMemMgrRelPoolTable represents this managing/managed relationship. --- --- A Java virtual machine may add or remove memory managers during execution. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryMXBean for --- more information on memory types, memory managers, memory pools, --- and the memory subsystem. --- ------------------------------------------------------------------------ - --- Root OBJECT IDENTIFIER for the JVM Memory group. --- -jvmMemory OBJECT IDENTIFIER ::= { jvmMgtMIBObjects 2 } - --- The following objects are mapped from the MemoryMXBean interface. ------------------------------------------------------------------------ - -jvmMemoryPendingFinalCount OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The approximate number objects that are pending for finalization. - - See java.lang.management.MemoryMXBean. - getObjectPendingFinalizationCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean" - ::= { jvmMemory 1 } - -jvmMemoryGCVerboseLevel OBJECT-TYPE - SYNTAX JvmVerboseLevelTC - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "Enables or disables verbose output for the memory system. - The verbose output information and the output stream to which - the verbose information is emitted are implementation dependent. - Typically, a Java virtual machine implementation prints a - message whenever it frees memory at garbage collection. - - verbose: if the verbose output is enabled, - silent: otherwise. - - See java.lang.management.MemoryMXBean.isVerbose(), - java.lang.management.MemoryMXBean.setVerbose() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean" - ::= { jvmMemory 2 } - -jvmMemoryGCCall OBJECT-TYPE - SYNTAX INTEGER { unsupported(1), supported(2), start(3), - started(4), failed(5) } - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "This object makes it possible to remotelly trigger the - Garbage Collector in the JVM. - - This object's syntax is an enumeration which defines: - - * Two state values, that can be returned from a GET request: - - unsupported(1): means that remote invocation of gc() is not - supported by the SNMP agent. - supported(2) : means that remote invocation of gc() is supported - by the SNMP agent. - - * One action value, that can be provided in a SET request to - trigger the garbage collector: - - start(3) : means that a manager wishes to trigger - garbage collection. - - * Two result value, that will be returned in the response to a - SET request when remote invocation of gc is supported - by the SNMP agent: - - started(4) : means that garbage collection was - successfully triggered. It does not mean - however that the action was successfullly - completed: gc might still be running when - this value is returned. - failed(5) : means that garbage collection couldn't be - triggered. - - * If remote invocation is not supported by the SNMP agent, then - unsupported(1) will always be returned as a result of either - a GET request, or a SET request with start(3) as input value. - - * If a SET request with anything but start(3) is received, then - the agent will return a wrongValue error. - - See java.lang.management.MemoryMXBean.gc() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean" - ::= { jvmMemory 3 } - --- The object identifiers in the range jvmMemory.[4-9] are reserved for future --- evolution of this MIB. --- --- We use the range jvmMemory.[10..19] for objects related to global JVM --- heap memory usage, as returned by --- java.lang.management.MemoryMXBean.getHeapMemoryUsage(). --- Object identifiers in the range jvmMemory.[14..19] are not used but --- reserved for future evolution of this MIB. --- -jvmMemoryHeapInitSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total amount of memory (in bytes) that the Java virtual machine - initially requests from the operating system for memory management - for heap memory pools. - - See java.lang.management.MemoryMXBean.getHeapMemoryUsage().getInit() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 10 } - - -jvmMemoryHeapUsed OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total amount of used memory (in bytes) from heap memory pools. - - See java.lang.management.MemoryMXBean.getHeapMemoryUsage().getUsed() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 11 } - -jvmMemoryHeapCommitted OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total amount of memory (in bytes) committed by heap memory pools. - - See java.lang.management.MemoryMXBean.getHeapMemoryUsage(). - getCommitted() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 12 } - -jvmMemoryHeapMaxSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total maximum size of memory (in bytes) for all heap memory pools. - - See java.lang.management.MemoryMXBean.getHeapMemoryUsage().getMax() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 13 } - --- We use the range jvmMemory.[20..29] for objects related to global JVM --- heap memory usage, as returned by --- lang.management.MemoryMXBean.getNonHeapMemoryUsage(). --- Object identifiers in the range jvmMemory.[24..29] are not used but are --- reserved for future evolution of this MIB. --- -jvmMemoryNonHeapInitSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total amount of memory (in bytes) that the Java virtual machine - initially requests from the operating system for memory management - for non heap memory pools. - - See java.lang.management.MemoryMXBean.getNonHeapMemoryUsage().getInit() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 20 } - - -jvmMemoryNonHeapUsed OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total amount of used memory (in bytes) from non heap memory pools. - - See java.lang.management.MemoryMXBean.getNonHeapMemoryUsage().getUsed() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 21 } - -jvmMemoryNonHeapCommitted OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total amount of memory (in bytes) committed by non heap memory pools. - - See java.lang.management.MemoryMXBean. - getNonHeapMemoryUsage().getCommitted() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 22 } - -jvmMemoryNonHeapMaxSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Total maximum size of memory (in bytes) for all non heap memory pools. - - See java.lang.management.MemoryMXBean.getNonHeapMemoryUsage().getMax() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemory 23 } - --- The object identifiers in the range jvmMemory.[30-99] are not used but are --- reserved for future evolution of this MIB. --- --- The JVM Memory Manager Table --- --- The jvmMemManagerTable represent memory manager abstract entities. --- The jvmMemManagerTable contains one row per memory manager. In --- addition, those memory managers which are also garbage collectors have --- an extension row in the jvmMemGCTable. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryMXBean for --- a detailed description of the memory subsystem. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryManagerMXBean --- for more information on memory managers. --- ------------------------------------------------------------------------ --- --- We use the range jvmMemory.[100..109] for objects related to memory --- managers. --- Object identifiers in the range jvmMemory.[102-109] are not used --- but are reserved for future evolution of this MIB. --- -jvmMemManagerTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmMemManagerEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Memory Manager Table contains the whole list of Memory - Managers as returned by ManagementFactory.getMemoryManagerMXBeans(). - - When a MemoryManagerMXBean object is an instance of - GarbageCollectorMXBean, then additional information specific to - the GarbageCollectorMXBean class will be found in the - jvmGCTable, at the same index. - - Relationships between MemoryManagers and MemoryPools are shown - by the Memory Manager-Pool Relation table (jvmMemMgrPoolRelTable). - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryManagerMXBean" - ::= { jvmMemory 100 } - -jvmMemManagerEntry OBJECT-TYPE - SYNTAX JvmMemManagerEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "A jvmMemManagerEntry conceptual row represent an instance of the - java.lang.management.MemoryManagerMXBean interface. If that instance - is also an instance of java.lang.management.GarbageCollectorMXBean, - then additional information will be found in the jvmGCTable, at the - same index. - - Columnar objects in this table are mapped from attributes of - the MemoryManagerMXBean interface. - - See java.lang.management.MemoryManagerMXBean - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryManagerMXBean" - INDEX { jvmMemManagerIndex } - ::= { jvmMemManagerTable 1 } - -JvmMemManagerEntry ::= SEQUENCE { - jvmMemManagerIndex JvmPositive32TC, - jvmMemManagerName JvmJavaObjectNameTC, - jvmMemManagerState JvmValidityStateTC -} - -jvmMemManagerIndex OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "An index opaquely computed by the agent and which uniquely - identifies a Memory Manager. - - The jvmMemManagerIndex index is opaquely computed by the agent, - from e.g the hash code of the MemoryManager (or MemoryManager name). - The agent is responsible for allocating a free index when it needs - one (e.g. if two objects have the same hash, then it may increment - one of the values until the conflict is resolved). As a result a - manager must not depend on the value of that index across, - e.g. reboot of the agent, as this value is not guaranteed to - stay identical after the agent restarts. - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryManagerMXBean" - ::= { jvmMemManagerEntry 1 } - -jvmMemManagerName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The name of this memory manager, as returned by - MemoryManagerMXBean.getName(). - - See java.mangement.MemoryManagerMXBean.getName(). - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryManagerMXBean" - ::= { jvmMemManagerEntry 2 } - -jvmMemManagerState OBJECT-TYPE - SYNTAX JvmValidityStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Indicates whether this memory manager is valid in the Java - virtual machine. A memory manager becomes invalid once the - Java virtual machine removes it from the memory system. - - See java.lang.management.MemoryManagerMXBean.isValid() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryManagerMXBean" - ::= { jvmMemManagerEntry 3 } - - --- The JVM Garbage Collector Table --- --- The jvmMemGCTable is an extension of the jvmMemManagerTable. --- It represents garbage collector abstract entities. A garbage collector --- is a memory manager responsible for reclaiming memory occupied by --- unreachable objects. --- --- A garbage collector is thus represented by one row in the --- jvmMemManagerTable, plus an extension row in the jvmMemGCTable. --- The extension row in the jvmMemGCTable contains those attributes which --- are specific to garbage collectors. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryMXBean for --- a detailed description of the memory subsystem. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryManagerMXBean --- for more information on memory managers, and --- java.lang.management.GarbageCollectorMXBean for more information on --- garbage collectors. --- ------------------------------------------------------------------------ - -jvmMemGCTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmMemGCEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Garbage Collector table provides additional information - on those MemoryManagers which are also GarbageCollectors. - This table extends the jvmMemManagerTable table. The index - used in the jvmMemGCTable table is imported from the - jvmMemManagerTable table. If a row from the jvmMemManagerTable - table is deleted, and if it has an extension in the jvmMemGCTable - table, then the extension row will also be deleted. - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.GarbageCollectorMXBean" - ::= { jvmMemory 101 } - -jvmMemGCEntry OBJECT-TYPE - SYNTAX JvmMemGCEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Provide additional information on Garbage Collectors. - - Columnar objects in this table are mapped from the - GarbageCollectorMXBean interface. - - See java.lang.management.GarbageCollectorMXBean - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.GarbageCollectorMXBean" - INDEX { jvmMemManagerIndex } - ::= {jvmMemGCTable 1 } - -JvmMemGCEntry ::= SEQUENCE { - jvmMemGCCount Counter64, - jvmMemGCTimeMs JvmTimeMillis64TC -} - -jvmMemGCCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The total number of collections that have occurred, - as returned by GarbageCollectorMXBean.getCollectionCount(). - - If garbage collection statistics are not available, this - object is set to 0. - - See java.lang.management.GarbageCollectorMXBean.getCollectionCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.GarbageCollectorMXBean" - ::= { jvmMemGCEntry 2 } - -jvmMemGCTimeMs OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The approximate accumulated collection elapsed time in - milliseconds, since the Java virtual machine has started. - This object is set to 0 if the collection elapsed time is - undefined for this collector. - - See java.lang.management.GarbageCollectorMXBean.getCollectionTime() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.GarbageCollectorMXBean" - DEFVAL { 0 } - ::= { jvmMemGCEntry 3 } - --- The JVM Memory Pool Table --- --- The jvmMemPoolTable represent memory pool abstract entities. --- The jvmMemPoolTable contains one row per memory pool. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryMXBean for --- a detailed description of the memory subsystem. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryPoolMXBean --- for more information on memory pool. --- ------------------------------------------------------------------------ --- --- We use the range jvmMemory.[110..119] for objects related to memory pools. --- Object identifiers in the range jvmMemory.[111-119] are not used but --- are reserved for future evolution of this MIB. --- -jvmMemPoolTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmMemPoolEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Memory Pool Table contains the whole list of MemoryPools - as returned by ManagementFactory.getMemoryPoolMXBeans(). - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemory 110 } - -jvmMemPoolEntry OBJECT-TYPE - SYNTAX JvmMemPoolEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - " - Represents a memory pool. The pool may contain heap memory or - non-heap memory. A row in this table represents - an instance of MemoryPoolMXBean. - - See java.lang.management.MemoryPoolMXBean - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - INDEX { jvmMemPoolIndex } - ::= { jvmMemPoolTable 1 } - -JvmMemPoolEntry ::= SEQUENCE { - jvmMemPoolIndex JvmPositive32TC, - jvmMemPoolName JvmJavaObjectNameTC, - jvmMemPoolType JvmManagedMemoryTypeTC, - jvmMemPoolState JvmValidityStateTC, - jvmMemPoolPeakReset JvmTimeMillis64TC, - - jvmMemPoolInitSize JvmUnsigned64TC, - jvmMemPoolUsed JvmUnsigned64TC, - jvmMemPoolCommitted JvmUnsigned64TC, - jvmMemPoolMaxSize JvmUnsigned64TC, - - jvmMemPoolPeakUsed JvmUnsigned64TC, - jvmMemPoolPeakCommitted JvmUnsigned64TC, - jvmMemPoolPeakMaxSize JvmUnsigned64TC, - - jvmMemPoolCollectUsed JvmUnsigned64TC, - jvmMemPoolCollectCommitted JvmUnsigned64TC, - jvmMemPoolCollectMaxSize JvmUnsigned64TC, - - jvmMemPoolThreshold JvmUnsigned64TC, - jvmMemPoolThreshdCount Counter64, - jvmMemPoolThreshdSupport JvmImplSupportStateTC, - jvmMemPoolCollectThreshold JvmUnsigned64TC, - jvmMemPoolCollectThreshdCount Counter64, - jvmMemPoolCollectThreshdSupport JvmImplSupportStateTC - -} - -jvmMemPoolIndex OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "An index value opaquely computed by the agent which uniquely - identifies a row in the jvmMemPoolTable. - - The jvmMemPoolIndex index is opaquely computed by the agent, - from e.g the hash code of the MemoryPool (or MemoryPool name). - The agent is responsible for allocating a free index when it - needs one (e.g. if two objects have the same hash, then it may - increment one of the values until the conflict is resolved). - As a result a manager must not depend on the value of that - index across, e.g. reboot of the agent, as this value is not - guaranteed to stay identical after the agent restarts. - " - ::= { jvmMemPoolEntry 1 } - -jvmMemPoolName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The name of this memory pool, as returned by - MemoryPoolMXBean.getName(). - - See java.lang.management.MemoryPoolMXBean.getName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 2 } - -jvmMemPoolType OBJECT-TYPE - SYNTAX JvmManagedMemoryTypeTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The type of memory managed in this pool. This pool may be used for - heap memory or non-heap memory. - - See java.lang.management.MemoryPoolMXBean.getMemoryType() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 3 } - -jvmMemPoolState OBJECT-TYPE - SYNTAX JvmValidityStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Indicates whether this memory pool is valid in the Java - virtual machine. A memory pool becomes invalid once the - Java virtual machine removes it from the memory system. - - See java.lang.management.MemoryPoolMXBean.isValid() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 4 } - -jvmMemPoolPeakReset OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-write - STATUS current - DESCRIPTION - " - This object indicates the last time - in milliseconds - at which - the peak memory usage statistic of this memory pool was reset - to the current memory usage. This corresponds to a time stamp - as returned by java.lang.System.currentTimeMillis(); - - Setting this object to a time earlier than its current time value - has no effect. Setting this object to a time later than its current - time value causes the peak memory usage statistic of this memory - pool to be reset to the current memory usage. The new value of this - object will be the time at which the reset operation is triggered. - - There could be a delay between the time at which the reset operation - is triggered and the time at which the actual resetting happens, so - this value is only indicative. - - See java.lang.management.MemoryPoolMXBean.resetPeakUsage() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 5 } - - --- The object identifier arcs in the range jvmMemPoolEntry.[6-9] are --- reserved for future evolution of this MIB. --- --- We use the range jvmMemPoolEntry.[10..19] for objects related to this --- pool memory usage, as returned by --- java.lang.management.MemoryPoolMXBean.getUsage(). --- Object identifiers in the range jvmMemPoolEntry.[14..19] are not --- used but are reserved for future evolution of this MIB. --- -jvmMemPoolInitSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Initial size of this memory pool. - - See java.lang.management.MemoryPoolMXBean.getUsage().getInit() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 10 } - - -jvmMemPoolUsed OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Amount of used memory in this memory pool. - - See java.lang.management.MemoryPoolMXBean.getUsage().getUsed() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 11 } - -jvmMemPoolCommitted OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Amount of committed memory in this memory pool. - - See java.lang.management.MemoryPoolMXBean.getUsage().getCommitted() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 12 } - -jvmMemPoolMaxSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Maximal size of this memory pool. - - See java.lang.management.MemoryPoolMXBean.getUsage().getMax() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 13 } - --- We use the range jvmMemPoolEntry.[20..29] for objects related to --- this pool peak memory usage, as returned by --- java.lang.management.MemoryPoolMXBean.getPeakUsage(). --- The object identifier arc jvmMemPoolEntry.20 which would have been --- used for the initial size is not used because the notion of initial --- size in the context of peak usage is meaningless. --- Therefore, we start numbering objects at 21. --- Object identifiers in the range jvmMemPoolEntry.[24..29] are not --- used but are reserved for future evolution of this MIB. --- -jvmMemPoolPeakUsed OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Amount of used memory in this memory pool when the peak usage - was reached. - - See java.lang.management.MemoryPoolMXBean.getPeakUsage().getUsed() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 21 } - -jvmMemPoolPeakCommitted OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Amount of committed memory in this memory pool when the peak usage - was reached. - - See java.lang.management.MemoryPoolMXBean.getPeakUsage().getCommitted() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 22 } - -jvmMemPoolPeakMaxSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - Maximal size of this memory pool when the peak usage - was reached. - - See java.lang.management.MemoryPoolMXBean.getPeakUsage().getMax() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 23 } - --- We use the range jvmMemPoolEntry.[30..39] for objects related to this --- pool collection memory usage, as returned by --- java.lang.management.MemoryPoolMXBean.getCollectionUsage(). --- The object identifier arc jvmMemPoolEntry.30 which would have been used --- for the initial size is not used because the notion of initial size in the --- context of collection usage is meaningless. --- Therefore, we start numbering objects at 31. --- Object identifiers in the range jvmMemPoolEntry.[34..39] are not used --- but are reserved for future evolution of this MIB. --- -jvmMemPoolCollectUsed OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - The amount of used memory at the most recent time that the - Java virtual machine has expended effort in recycling unused objects - in this memory pool. - - See java.lang.management.MemoryPoolMXBean.getCollectionUsage().getUsed() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 31 } - -jvmMemPoolCollectCommitted OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - The amount of committed memory at the most recent time that the - Java virtual machine has expended effort in recycling unused objects - in this memory pool. - - See java.lang.management.MemoryPoolMXBean.getCollectionUsage(). - getCommitted() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 32 } - -jvmMemPoolCollectMaxSize OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - " - The value of the maximum amount of memory at the most recent time - that the Java virtual machine has expended effort in recycling - unused objects in this memory pool. - - See java.lang.management.MemoryPoolMXBean.getCollectionUsage().getMax() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryUsage" - ::= { jvmMemPoolEntry 33 } - --- Object identifiers in the range jvmMemPoolEntry.[40-109] are reserved --- for future evolution of this MIB. --- --- We use the range jvmMemPoolEntry.[110..119] for objects related to this --- pool memory usage thresholds (range jvmMemPoolEntry.[10..19] was used for --- this pool memory usage). --- Object identifier arcs in the range jvmMemPoolEntry.[113..119] are not --- used but are reserved for future evolution of this MIB. --- -jvmMemPoolThreshold OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "The threshold value for the memory usage of this memory pool, - in bytes. A zero value (0) indicates that no threshold value is - configured. - When the amount of used memory crosses over this threshold - value the JVM will trigger a usage memory threshold exceeded - notification, and the jvmMemPoolThreshdCount increases. - - If memory usage threshold is not supported, then this object, if - implemented, will always be equals to 0. In that case, attempting - to set this object will trigger an inconsistentValue error. - - See also jvmMemPoolThreshdSupport. - - See java.lang.management.MemoryPoolMXBean.getUsageThreshold(), - java.lang.management.MemoryPoolMXBean.setUsageThreshold(long), - java.lang.management.MemoryPoolMXBean.getUsageThresholdCount(), - java.lang.management.MemoryPoolMXBean.isUsageThresholdSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - DEFVAL { 0 } - ::= { jvmMemPoolEntry 110 } - -jvmMemPoolThreshdCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The number of times that the memory usage has crossed - the usage threshold, as detected by the Java virtual machine. - - If memory usage threshold is not supported, then this object, if - implemented, will always be equals to 0. - - See also jvmMemPoolThresholdSupport. - - See java.lang.management.MemoryPoolMXBean.getUsageThresholdCount(), - java.lang.management.MemoryPoolMXBean.isUsageThresholdSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 111 } - -jvmMemPoolThreshdSupport OBJECT-TYPE - SYNTAX JvmImplSupportStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Tells whether this memory pool supports usage threshold. - - See java.lang.management.MemoryPoolMXBean.isUsageThresholdSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 112 } - --- Object identifiers in the range jvmMemPoolEntry.[120-129] are reserved --- for future evolution of this MIB. --- --- We use the range jvmMemPoolEntry.[130..139] for objects related to --- this pool memory collection usage thresholds (range --- jvmMemPoolEntry.[30..39] was used for this pool collection memory usage). --- Object identifiers in the range jvmMemPoolEntry.[133..139] are not used --- but are reserved for future evolution of this MIB. --- -jvmMemPoolCollectThreshold OBJECT-TYPE - SYNTAX JvmUnsigned64TC - UNITS "bytes" - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "The threshold value for the collection usage of this memory pool, - in bytes. A zero value (0) indicates that no threshold value is - configured. - When the amount of used memory crosses over this threshold - value the JVM will trigger a collection memory threshold exceeded - notification, and the jvmMemPoolCollectThreshdCount increases. - - If collection usage threshold is not supported, then this object, if - implemented, will always be equals to 0. In that case, attempting - to set this object will trigger an inconsistentValue error. - - See also jvmMemPoolCollectThreshdSupport. - - See java.lang.management.MemoryPoolMXBean. - getCollectionUsageThreshold(), - java.lang.management.MemoryPoolMXBean. - setCollectionUsageThreshold(long), - java.lang.management.MemoryPoolMXBean. - isCollectionUsageThresholdSupported(), - java.lang.management.MemoryPoolMXBean. - getCollectionUsageThresholdCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - DEFVAL { 0 } - ::= { jvmMemPoolEntry 131 } - -jvmMemPoolCollectThreshdCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The number of times that the memory usage has crossed - the collection usage threshold, as detected by the Java virtual - machine. - - If memory usage threshold is not supported, then this object, if - implemented, will always be equals to 0. - - See also jvmMemPoolCollectThreshdSupport. - - See java.lang.management.MemoryPoolMXBean. - getCollectionUsageThresholdCount(), - java.lang.management.MemoryPoolMXBean. - isCollectionUsageThresholdSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 132 } - -jvmMemPoolCollectThreshdSupport OBJECT-TYPE - SYNTAX JvmImplSupportStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Tells whether this memory pool supports collection usage threshold. - - See java.lang.management.MemoryPoolMXBean. - isCollectionUsageThresholdSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemPoolEntry 133 } - --- The JVM Memory Manager-Pool Relation Table ------------------------------------------------------------------------ --- The JVM Memory Pool Table --- --- The jvmMemPoolTable represent memory pool abstract entities. --- The jvmMemPoolTable contains one row per memory pool. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryMXBean for --- a detailed description of the memory subsystem. --- --- See J2SE 5.0 API Specification, java.lang.management.MemoryPoolMXBean --- for more information on memory pool. --- ------------------------------------------------------------------------ --- --- We use the range jvmMemory.[110..119] for objects related to memory pools. --- Object identifier arcs in the range jvmMemory.[111-119] are not used --- but are reserved for future evolution of this MIB. --- - -jvmMemMgrPoolRelTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmMemMgrPoolRelEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Memory Manager-Pool Relation Table shows the - Memory Manager / Memory Pool relations, as returned by - MemoryPoolMXBean.getMemoryManagerNames() and - MemoryManagerMXBean.getMemoryPoolNames(). - This table imports the indexes from the jvmMemManagerTable table - and jvmMemPoolTable table. The jvmMemMgrRelManagerName and - jvmMemMgrRelPoolName objects are not actually necessary since - the indexes are self-sufficient to express the relationship - - but the names will make the table more understandable when displayed - in a management console. - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryManagerMXBean" - ::= { jvmMemory 120 } - -jvmMemMgrPoolRelEntry OBJECT-TYPE - SYNTAX JvmMemMgrPoolRelEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "A row in this table indicates that the Memory Manager identified - by jvmMemManagerIndex manages the Memory Pool identified by - jvmMemPoolIndex. Note that a pool may be managed by several - memory managers, and a memory manager can manage several - memory pool. - - See java.lang.management.MemoryManagerMXBean.getMemoryPoolNames(), - java.lang.management.MemoryPoolMXBean.getMemoryManagerNames() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean, - java.lang.management.MemoryManagerMXBean" - INDEX { jvmMemManagerIndex, jvmMemPoolIndex } - ::= { jvmMemMgrPoolRelTable 1 } - -JvmMemMgrPoolRelEntry ::= SEQUENCE { - jvmMemMgrRelManagerName JvmJavaObjectNameTC, - jvmMemMgrRelPoolName JvmJavaObjectNameTC -} - -jvmMemMgrRelManagerName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The name of the memory manager. - - See java.manangement.MemoryManagerMXBean.getName(); - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryManagerMXBean" - ::= { jvmMemMgrPoolRelEntry 2 } - -jvmMemMgrRelPoolName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The name of the memory pool. - - See java.manangement.MemoryPoolMXBean.getName(); - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmMemMgrPoolRelEntry 3 } - - ------------------------------------------------------------------------ --- --- The JVM Thread group --- --- A collection of objects used to monitor threads in the --- Java Virtual Machine. These objects define the SNMP management --- interface for the thread system of the Java virtual machine. --- --- The jvmThreadInstanceTable represents the threads which are currently --- alive in the system. The representation of a thread is derived from the --- set of methods in the ThreadMXBean that return information about a --- given thread. --- --- See J2SE 5.0 API Specification, java.lang.management.ThreadMXBean for --- a detailed description of the threading subsystem. --- ------------------------------------------------------------------------ - --- ------------------------------------------------------------------------ - -jvmThreading OBJECT IDENTIFIER ::= { jvmMgtMIBObjects 3 } - --- The following objects are mapped from the ThreadMXBean interface. ------------------------------------------------------------------------ - -jvmThreadCount OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The current number of live threads. - - See java.lang.management.ThreadMXBean.getThreadCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 1 } - -jvmThreadDaemonCount OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The current number of daemon threads. - - See java.lang.management.ThreadMXBean.getDaemonThreadCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 2 } - -jvmThreadPeakCount OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The peak thread count since the execution of the application. - - See java.lang.management.ThreadMXBean.getPeakThreadCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 3 } - -jvmThreadTotalStartedCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The total number of threads created and started since the Java - Virtual Machine started. - - See java.lang.management.ThreadMXBean.getTotalStartedThreadCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 4 } - -jvmThreadContentionMonitoring OBJECT-TYPE - SYNTAX JvmImplOptFeatureStateTC - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "The state of the Thread Contention Monitoring feature. - This feature can be: - - unsupported: The JVM does not support Thread Contention Monitoring. - enabled : The JVM supports Thread Contention Monitoring, and it - is enabled. - disabled : The JVM supports Thread Contention Monitoring, and it - is disabled. - - Only enabled(3) and disabled(4) may be supplied as values to a - SET request. unsupported(1) can only be set internally by the - agent. - - When the feature is unsupported(1), any attempt to change - that value will fail: trying to set this object to - enabled(3) or disabled(4) will result in an `inconsistentValue' - error. Trying to set it to any other value will result in an - `wrongValue' error. - - See java.lang.management.ThreadMXBean. - isThreadContentionMonitoringSupported(), - java.lang.management.ThreadMXBean. - isThreadContentionMonitoringEnabled(), - java.lang.management.ThreadMXBean. - setThreadContentionMonitoringEnabled() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 5 } - -jvmThreadCpuTimeMonitoring OBJECT-TYPE - SYNTAX JvmImplOptFeatureStateTC - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "The state of the Thread CPU Time Monitoring feature. - This feature can be: - - unsupported: The JVM does not support Thread CPU Time Monitoring. - enabled : The JVM supports Thread CPU Time Monitoring, and it - is enabled. - disabled : The JVM supports Thread CPU Time Monitoring, and it - is disabled. - - Only enabled(3) and disabled(4) may be supplied as values to a - SET request. unsupported(1) can only be set internally by the - agent. - - When the feature is unsupported(1), any attempt to change - that value will fail: trying to set this object to - enabled(3) or disabled(4) will result in an `inconsistentValue' - error. Trying to set it to any other value will result in an - `wrongValue' error. - - See java.lang.management.ThreadMXBean. - isThreadCpuTimeSupported(), - java.lang.management.ThreadMXBean. - isThreadCpuTimeEnabled(), - java.lang.management.ThreadMXBean. - setThreadCpuTimeEnabled() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 6 } - -jvmThreadPeakCountReset OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-write - STATUS current - DESCRIPTION - " - This object indicates the last time - in milliseconds - at which - the peak thread count was reset to the current thread count. - This corresponds to a time stamp as returned by - java.lang.System.currentTimeMillis(). - - Setting this object to a time earlier than its current time value - has no effect. Setting this object to a time later than its current - time value causes the peak thread count statistic to be reset to - the current thread count. The new value of this object will be - the time at which the reset operation is triggered. - - There could be a delay between the time at which the reset operation - is triggered and the time at which the actual resetting happens, so - this value is only indicative. - - See java.lang.management.ThreadMXBean.resetPeakThreadCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 7 } - - --- Object identifiers in the range jvmThreading.[8-10] are reserved --- for future evolution of this MIB. --- ------------------------------------------------------------------------ --- The JVM Thread Instance Table --- --- The jvmThreadInstanceTable represents the threads which are currently --- alive in the system. The representation of a thread is derived from the --- set of methods in the ThreadMXBean that return information about a --- given thread. --- --- See J2SE 5.0 API Specification, java.lang.management.ThreadMXBean for --- a detailed description of the threading subsystem. --- See also J2SE 5.0 API Specification, java.lang.management.ThreadInfo, --- and java.lang.Thread --- ------------------------------------------------------------------------ - -jvmThreadInstanceTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmThreadInstanceEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Thread Instance Table is built from all the methods of - ThreadMXBean that take a ThreadID as parameter. - - See java.lang.management.ThreadMXBean.getAllThreadIds() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreading 10 } - -jvmThreadInstanceEntry OBJECT-TYPE - SYNTAX JvmThreadInstanceEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "A row in this table represents a live thread. - Attributes in this row are built from all the methods of - ThreadMXBean that take a ThreadID as parameter. - - See java.lang.management.ThreadMXBean - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - INDEX { jvmThreadInstIndex } - ::= { jvmThreadInstanceTable 1 } - -JvmThreadInstanceEntry ::= SEQUENCE { - jvmThreadInstIndex JvmIndex64TC, - jvmThreadInstId JvmUnsigned64TC, - jvmThreadInstState JvmThreadStateTC, - jvmThreadInstBlockCount Counter64, - jvmThreadInstBlockTimeMs JvmTimeMillis64TC, - jvmThreadInstWaitCount Counter64, - jvmThreadInstWaitTimeMs JvmTimeMillis64TC, - jvmThreadInstCpuTimeNs JvmTimeNanos64TC, - jvmThreadInstLockName JvmJavaObjectNameTC, - jvmThreadInstLockOwnerPtr RowPointer, - jvmThreadInstName JvmJavaObjectNameTC -} - -jvmThreadInstIndex OBJECT-TYPE - SYNTAX JvmIndex64TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "An index uniquely identifying a live thread, and directly - derived from the value of jvmThreadInstId. The jvmThreadInstId - cannot be used directly as index in the table, because integer - indexes cannot exceed an unsigned 32 int. - - The jvmThreadInstIndex index is an 8 byte octet string as - defined by the JvmIndex64TC TEXTUAL-CONVENTION. Its value is - directly derived from the value of the corresponding ThreadID - returned by jvmThreadInstId. - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean, java.lang.Thread" - ::= { jvmThreadInstanceEntry 1 } - -jvmThreadInstId OBJECT-TYPE - SYNTAX JvmUnsigned64TC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The thread ID, as returned by Thread.getId(). - - See java.lang.management.ThreadMXBean.getThreadInfo(long,boolean). - getThreadId() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean, java.lang.Thread" - ::= { jvmThreadInstanceEntry 2 } - -jvmThreadInstState OBJECT-TYPE - SYNTAX JvmThreadStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The state of this thread instance. - - See java.lang.management.ThreadMXBean.getThreadInfo(long,boolean). - getThreadState() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreadInstanceEntry 3 } - -jvmThreadInstBlockCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The total number of times that this thread has blocked to enter - or re-enter a monitor.. - - See java.lang.management.ThreadMXBean.getThreadInfo(long,boolean). - getBlockedCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreadInstanceEntry 4 } - -jvmThreadInstBlockTimeMs OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The approximate accumulated elapsed time (in millisecond) - that a thread has blocked to enter or re-enter a monitor since - it has started - or since thread contention monitoring was - enabled. - - This object is always set to 0 if thread contention monitoring - is disabled or not supported. - - See java.lang.management.ThreadMXBean.getThreadInfo(long,boolean). - getBlockedTime() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreadInstanceEntry 5 } - -jvmThreadInstWaitCount OBJECT-TYPE - SYNTAX Counter64 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The total number of times that this thread has waited for - notification. - - See java.lang.management.ThreadMXBean.getThreadInfo(long,boolean). - getWaitedCount() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreadInstanceEntry 6 } - -jvmThreadInstWaitTimeMs OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The approximate accumulated elapsed time (in millisecond) - that a thread has waited on a monitor through a - java.lang.Object.wait method since it has started - or since - thread contention monitoring wasenabled. - - This object is always set to 0 if thread contention monitoring - is disabled or not supported. - - See java.lang.management.ThreadMXBean.getThreadInfo(long,boolean). - getWaitedTime() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreadInstanceEntry 7 } - -jvmThreadInstCpuTimeNs OBJECT-TYPE - SYNTAX JvmTimeNanos64TC - UNITS "nanoseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The approximate accumulated CPU time (in nanosecond) for a thread - since it has started - or since thread CPU time monitoring was - enabled. - - If the thread of the specified ID is not alive or does not exist, - or the CPU time measurement is disabled or not supported, - this object is set to 0. - - See java.lang.management.ThreadMXBean.getThreadCpuTime(long), - java.lang.management.ThreadMXBean.isThreadCpuTimeSupported(), - java.lang.management.ThreadMXBean.isThreadCpuTimeEnabled() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean" - ::= { jvmThreadInstanceEntry 8 } - -jvmThreadInstName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "This thread name - as returned by Thread.getThreadName(). - - See java.lang.management.ThreadInfo.getThreadName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean, - java.lang.management.ThreadInfo" - ::= { jvmThreadInstanceEntry 9 } - -jvmThreadInstLockName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The string representation of the monitor lock that this thread - is blocked to enter or waiting to be notified through the - Object.wait method. - - See J2SE 5.0 API Specification, - java.lang.management.ThreadInfo.getLockName() - for more information on the format of this string. - - If this thread is not blocked then a zero-length string is returned. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the JvmJavaObjectNameTC - (1023 bytes max). - - See java.lang.management.ThreadInfo.getLockName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean, - java.lang.management.ThreadInfo" - ::= { jvmThreadInstanceEntry 10 } - -jvmThreadInstLockOwnerPtr OBJECT-TYPE - SYNTAX RowPointer - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "A pointer to the thread which owns the monitor of the - object on which this thread instance is blocked. - This object will point to jvmThreadInstId of the - lock owner thread. - - If this thread is not blocked then 0.0 is returned. - - See java.lang.management.ThreadInfo.getLockOwnerId() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.ThreadMXBean, - java.lang.management.ThreadInfo" - ::= { jvmThreadInstanceEntry 11 } - ------------------------------------------------------------------------ --- --- The JVM Runtime group --- --- A collection of objects used to monitor the Java Virtual Machine --- Runtime. These objects define the SNMP management interface for the --- runtime system of the Java virtual machine. --- --- The JVM Runtime group defines object mapped from the --- java.lang.management.RuntimeMXBean interface. --- --- See J2SE 5.0 API Specification, java.lang.management.RuntimeMXBean for --- a detailed description of the runtime system. --- ------------------------------------------------------------------------ - -jvmRuntime OBJECT IDENTIFIER ::= { jvmMgtMIBObjects 4 } - --- The following objects are mapped from the RuntimeMXBean interface. ------------------------------------------------------------------------ - -jvmRTName OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The name representing the running Java virtual machine. - - Note that the SNMP agent may have to truncate the name returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 1 } - -jvmRTVMName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Java virtual machine implementation name. - - See java.lang.management.RuntimeMXBean.getVmName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 2 } - -jvmRTVMVendor OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Java virtual machine implementation vendor. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getVmVendor() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 3 } - -jvmRTVMVersion OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Java virtual machine implementation version. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getVmVersion() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 4 } - -jvmRTSpecName OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Java virtual machine specification name. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getSpecName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 5 } - -jvmRTSpecVendor OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Java virtual machine specification vendor. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getSpecVendor() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 6 } - -jvmRTSpecVersion OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Java virtual machine specification version. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getSpecVersion() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 7 } - -jvmRTManagementSpecVersion OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The version of the management specification for the Java virtual - machine implementation. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.RuntimeMXBean.getManagementSpecVersion() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 8 } - -jvmRTBootClassPathSupport OBJECT-TYPE - SYNTAX JvmImplSupportStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Indicates whether the Java virtual machine supports the - boot class path mechanism used by the bootstrap class loader - to search for class files. - - See java.lang.management.RuntimeMXBean.isBootClassPathSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 9 } - -jvmRTInputArgsCount OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The number of input arguments passed to the Java Virtual Machine. - - See java.lang.management.RuntimeMXBean.getInputArguments() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 10 } - -jvmRTUptimeMs OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Uptime of the Java virtual machine, in milliseconds. This is - equivalent to ( System.currentTimeMillis() - jvmStartTimeMs ). - - See also jvmRTStartTimeMs. - - See java.lang.management.RuntimeMXBean.getUptime() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 11 } - -jvmRTStartTimeMs OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The approximate time when the Java virtual machine started, in - milliseconds. This is a time stamp as returned by - System.currentTimeMillis(). This time will not change unless - the Java Virtual Machine is restarted. - - See also jvmRTUptimeMs. - - See java.lang.management.RuntimeMXBean.getStartTime() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 12 } - - --- Object identifiers in the range jvmRuntime.[13-19] are reserved --- for future evolution of this MIB. --- ------------------------------------------------------------------------ --- --- The JVM Input Argument Table --- --- The jvmRTInputArgsTable contains one row per input argument given on --- the Java command line. --- --- See J2SE 5.0 API Specification, --- java.lang.management.RuntimeMXBean.getInputArguments() --- for more information. ------------------------------------------------------------------------ - -jvmRTInputArgsTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmRTInputArgsEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Input Argument Table lists the input arguments passed - to the Java Virtual Machine. - - The jvmRTInputArgsIndex is the index of the argument in - the array returned by RuntimeMXBean.getInputArguments(). - - See java.lang.management.RuntimeMXBean.getInputArguments() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 20 } - -jvmRTInputArgsEntry OBJECT-TYPE - SYNTAX JvmRTInputArgsEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represent an input argument passed to the Java Virtual Machine. - - See java.lang.management.RuntimeMXBean.getInputArguments() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - INDEX { jvmRTInputArgsIndex } - ::= { jvmRTInputArgsTable 1 } - -JvmRTInputArgsEntry ::= SEQUENCE { - jvmRTInputArgsIndex JvmPositive32TC, - jvmRTInputArgsItem JvmArgValueTC -} - -jvmRTInputArgsIndex OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The index of the input argument, as in the array returned - by RuntimeMXBean.getInputArguments(). - - See java.lang.management.RuntimeMXBean.getInputArguments() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTInputArgsEntry 1 } - -jvmRTInputArgsItem OBJECT-TYPE - SYNTAX JvmArgValueTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An input argument at index jvmRTInputArgsIndex, as in the array - returned by RuntimeMXBean.getInputArguments(). - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the JvmArgValueTC - (1023 bytes max). - - See java.lang.management.RuntimeMXBean.getInputArguments() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTInputArgsEntry 2 } - - ------------------------------------------------------------------------ --- --- The JVM Boot Class Path Table --- --- The jvmRTBootClassPathTable contains one row per path element in the --- bootclasspath. This table may not be implemented (or may be empty) if --- the bootclasspath feature is not supported by the underlying --- implementation. --- --- See J2SE 5.0 API Specification, --- java.lang.management.RuntimeMXBean.getBootClassPath() --- java.lang.management.RuntimeMXBean.isBootClassPathSupported() --- for more information. ------------------------------------------------------------------------ - -jvmRTBootClassPathTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmRTBootClassPathEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The boot class path that is used by the bootstrap class loader - to search for a class file for loading. - - Note that the SNMP agent may have to truncate the bootclasspath - elements contained in the string returned by the underlying API - if it does not fit in the JvmPathElementTC (1023 bytes max). - - This table is not implemented (or empty) if jvmRTBootClassPathSupport - is unsupported(1). - - See java.lang.management.RuntimeMXBean.getBootClassPath() - java.lang.management.RuntimeMXBean.isBootClassPathSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 21 } - -jvmRTBootClassPathEntry OBJECT-TYPE - SYNTAX JvmRTBootClassPathEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represent a path element in the Java Virtual Machine bootclasspath. - - See java.lang.management.RuntimeMXBean.getBootClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - INDEX { jvmRTBootClassPathIndex } - ::= { jvmRTBootClassPathTable 1 } - -JvmRTBootClassPathEntry ::= SEQUENCE { - jvmRTBootClassPathIndex JvmPositive32TC, - jvmRTBootClassPathItem JvmPathElementTC -} - -jvmRTBootClassPathIndex OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The index of the path element, as in the array obtained - by splitting RuntimeMXBean.getBootClassPath() in its elementary path - constituents. - - See java.lang.management.RuntimeMXBean.getBootClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTBootClassPathEntry 1 } - -jvmRTBootClassPathItem OBJECT-TYPE - SYNTAX JvmPathElementTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An path element at index jvmRTBootClassPathIndex, as in the - array obtained by splitting RuntimeMXBean.getBootClassPath() in - its elementary path constituents. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the JvmPathElementTC - (1023 bytes max). - - See java.lang.management.RuntimeMXBean.getBootClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTBootClassPathEntry 2 } - ------------------------------------------------------------------------ --- --- The JVM Class Path Table --- --- The jvmRTClassPathTable contains one row per path element in the --- classpath. --- --- See J2SE 5.0 API Specification, --- java.lang.management.RuntimeMXBean.getClassPath() --- for more information. ------------------------------------------------------------------------ - -jvmRTClassPathTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmRTClassPathEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The class path that is used by the system class loader - to search for a class file. - - Note that the SNMP agent may have to truncate the classpath - elements contained in the string returned by the underlying API - if it does not fit in the JvmPathElementTC (1023 bytes max). - - See java.lang.management.RuntimeMXBean.getClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 22 } - -jvmRTClassPathEntry OBJECT-TYPE - SYNTAX JvmRTClassPathEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represent a path element in the Java Virtual Machine classpath. - - See java.lang.management.RuntimeMXBean.getClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - INDEX { jvmRTClassPathIndex } - ::= { jvmRTClassPathTable 1 } - -JvmRTClassPathEntry ::= SEQUENCE { - jvmRTClassPathIndex JvmPositive32TC, - jvmRTClassPathItem JvmPathElementTC -} - -jvmRTClassPathIndex OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The index of the path element, as in the array obtained - by splitting RuntimeMXBean.getClassPath() in its elementary - path constituents. - - See java.lang.management.RuntimeMXBean.getClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTClassPathEntry 1 } - -jvmRTClassPathItem OBJECT-TYPE - SYNTAX JvmPathElementTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An path element at index jvmRTClassPathIndex, as in the array - obtained by splitting RuntimeMXBean.getClassPath() in its elementary - path constituents. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the JvmPathElementTC - (1023 bytes max). - - See java.lang.management.RuntimeMXBean.getClassPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTClassPathEntry 2 } - ------------------------------------------------------------------------ --- --- The JVM Library Path Table --- --- The jvmRTLibraryPathTable contains one row per path element in the --- librarypath. --- --- See J2SE 5.0 API Specification, --- java.lang.management.RuntimeMXBean.getLibraryPath() --- for more information. ------------------------------------------------------------------------ - -jvmRTLibraryPathTable OBJECT-TYPE - SYNTAX SEQUENCE OF JvmRTLibraryPathEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The library path. - - Note that the SNMP agent may have to truncate the librarypath - elements contained in the string returned by the underlying API - if it does not fit in the JvmPathElementTC (1023 bytes max). - - See java.lang.management.RuntimeMXBean.getLibraryPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRuntime 23 } - -jvmRTLibraryPathEntry OBJECT-TYPE - SYNTAX JvmRTLibraryPathEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represent a path element in the Java Virtual Machine librarypath. - - See java.lang.management.RuntimeMXBean.getLibraryPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - INDEX { jvmRTLibraryPathIndex } - ::= { jvmRTLibraryPathTable 1 } - -JvmRTLibraryPathEntry ::= SEQUENCE { - jvmRTLibraryPathIndex JvmPositive32TC, - jvmRTLibraryPathItem JvmPathElementTC -} - -jvmRTLibraryPathIndex OBJECT-TYPE - SYNTAX JvmPositive32TC - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The index of the path element, as in the array obtained - by splitting RuntimeMXBean.getLibraryPath() in its elementary - constituents. - - See java.lang.management.RuntimeMXBean.getLibraryPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTLibraryPathEntry 1 } - -jvmRTLibraryPathItem OBJECT-TYPE - SYNTAX JvmPathElementTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An path element at index jvmRTLibraryPathIndex, as in the array - obtained by splitting RuntimeMXBean.getLibraryPath() in its elementary - path constituents. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the JvmPathElementTC - (1023 bytes max). - - See java.lang.management.RuntimeMXBean.getLibraryPath() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.RuntimeMXBean" - ::= { jvmRTLibraryPathEntry 2 } - ------------------------------------------------------------------------ --- --- The JVM Compilation group --- --- A collection of objects used to monitor the Java Virtual Machine --- Runtime Compiler (JIT). These objects define the SNMP management --- interface for the compilation system of the Java virtual machine. --- --- The JVM Compilation group defines object mapped from the --- java.lang.management.CompilationMXBean interface. --- --- See J2SE 5.0 API Specification, java.lang.management.CompilationMXBean for --- a detailed description of the runtime system. --- ------------------------------------------------------------------------ - -jvmCompilation OBJECT IDENTIFIER ::= { jvmMgtMIBObjects 5 } - --- The following objects are mapped from the CompilationMXBean interface. ------------------------------------------------------------------------ - -jvmJITCompilerName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The name of the Just-in-time (JIT) compiler. - - See java.lang.management.CompilationMXBean.getName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.CompilationMXBean" - ::= { jvmCompilation 1 } - -jvmJITCompilerTimeMs OBJECT-TYPE - SYNTAX JvmTimeMillis64TC - UNITS "milliseconds" - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Gets the approximate accumulated elapsed time (in milliseconds) - spent in compilation since the Java virtual machine has started. - If multiple threads are used for compilation, this value is - the summation of the approximate time that each thread - spent in compilation. - - If compiler time monitoring is not supported, then this object - remains set to 0. - - See java.lang.management.CompilationMXBean.getTotalCompilationTime() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.CompilationMXBean" - ::= { jvmCompilation 2 } - - -jvmJITCompilerTimeMonitoring OBJECT-TYPE - SYNTAX JvmImplSupportStateTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Indicates whether the Java virtual machine supports - compilation time monitoring. - - See java.lang.management.CompilationMXBean. - isCompilationTimeMonitoringSupported() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.CompilationMXBean" - ::= { jvmCompilation 3 } - ------------------------------------------------------------------------ --- --- The JVM Operating System group --- --- A collection of objects used to monitor some resource of the --- Operating System the Java Virtual Machine is running on. These objects --- define the SNMP management interface offered by the Java virtual machine --- for the operating system on which it is running. --- --- The JVM Operating System group defines object mapped from the --- java.lang.management.OperatingSystemMXBean interface. --- --- See J2SE 5.0 API Specification, java.lang.management.OperatingSystemMXBean --- for a detailed description of the operating system. --- ------------------------------------------------------------------------ - -jvmOS OBJECT IDENTIFIER ::= { jvmMgtMIBObjects 6 } - --- The following objects are mapped from the OperatingSystemMXBean interface. ------------------------------------------------------------------------ - -jvmOSName OBJECT-TYPE - SYNTAX JvmJavaObjectNameTC - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The operating system name. - - See java.lang.management.OperatingSystemMXBean.getName() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.OperatingSystemMXBean" - ::= { jvmOS 1 } - -jvmOSArch OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The operating system architecture. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.OperatingSystemMXBean.getArch() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.OperatingSystemMXBean" - ::= { jvmOS 2 } - -jvmOSVersion OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The operating system version. - - Note that the SNMP agent may have to truncate the string returned - by the underlying API if it does not fit in the DisplayString - (255 bytes max). - - See java.lang.management.OperatingSystemMXBean.getVersion() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.OperatingSystemMXBean" - ::= { jvmOS 3 } - -jvmOSProcessorCount OBJECT-TYPE - - SYNTAX Integer32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The number of processors available to the Java virtual machine. - - See java.lang.management.OperatingSystemMXBean.getAvailableProcessors() - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.OperatingSystemMXBean" - ::= { jvmOS 4 } - --- --- NOTIFICATIONS --- ------------------------------------------------------------------------ - --- --- Low Memory Notifications --- - -jvmMgtMIBMemoryNotifs OBJECT IDENTIFIER ::= { jvmMgtMIBNotifications 2 } -jvmMgtMIBLowMemoryNotifs OBJECT IDENTIFIER ::= { jvmMgtMIBMemoryNotifs 1 } - -jvmLowMemoryPrefix OBJECT IDENTIFIER - ::= { jvmMgtMIBLowMemoryNotifs 0 } - --- Not used at this time, but reserved for future evolution of this MIB: --- --- jvmLowMemoryData OBJECT IDENTIFIER --- ::= { jvmMgtMIBLowMemoryNotifs 1 } --- - -jvmLowMemoryPoolUsageNotif NOTIFICATION-TYPE - OBJECTS { jvmMemPoolName, jvmMemPoolUsed, jvmMemPoolThreshdCount } - STATUS current - DESCRIPTION - "This notification is sent when the memory usage threshold of - a memory pool is exceeded. - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryNotification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmLowMemoryPrefix 1 } - -jvmLowMemoryPoolCollectNotif NOTIFICATION-TYPE - OBJECTS { jvmMemPoolName, jvmMemPoolCollectUsed, - jvmMemPoolCollectThreshdCount } - STATUS current - DESCRIPTION - "This notification is sent when the collection memory usage - threshold of a memory pool is exceeded. - " - REFERENCE "J2SE 5.0 API Specification, - java.lang.management.MemoryNotification, - java.lang.management.MemoryPoolMXBean" - ::= { jvmLowMemoryPrefix 2 } - --- --- Conformance Section --- ------------------------------------------------------------------------ - --- conformance information - -jvmMgtMIBCompliances - OBJECT IDENTIFIER ::= { jvmMgtMIBConformance 1 } -jvmMgtMIBGroups - OBJECT IDENTIFIER ::= { jvmMgtMIBConformance 2 } - - --- compliance statements - -jvmManagementCompliance MODULE-COMPLIANCE - STATUS current - DESCRIPTION - "The compliance statement for SNMP entities which - implement this MIB." - MODULE -- this module - MANDATORY-GROUPS { - jvmClassLoadingBasicGroup, - jvmClassLoadingSetGroup, - jvmMemoryBasicGroup, - jvmMemoryHeapUsageGroup, - jvmMemoryNonHeapUsageGroup, - jvmMemorySetGroup, - jvmMemManagerGroup, - jvmMemGCGroup, - jvmMemPoolBasicGroup, - jvmMemPoolUsageGroup, - jvmMemPoolPeakUsageGroup, - jvmMemPoolCollectUsageGroup, - jvmMemMgrPoolRelationGroup, - jvmThreadBasicGroup, - jvmThreadInstanceBasicGroup, - jvmRuntimeBasicGroup, - jvmOSGroup - } - - -- optional/conditional groups - GROUP jvmMemPoolMonitoringGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine does not support low memory detection in memory usage. - " - GROUP jvmMemPoolCollectMonitoringGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine does not support low memory detection in collection - memory usage. - " - GROUP jvmLowMemoryUsageNotifGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine does not support low memory usage detection. - " - GROUP jvmLowMemoryCollectNotifGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine does not support low collection memory usage detection. - " - GROUP jvmThreadInstanceCpuGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine does not support CPU time measurement for other threads. - " - GROUP jvmThreadInstanceBlockGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine does not support thread contention monitoring. - " - GROUP jvmRuntimeBootCPGroup - DESCRIPTION - "This group may not be implemented if the underlying - implementation does not support the bootclasspath feature. - " - GROUP jvmJITCompilerBasicGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine has no compilation system. - " - GROUP jvmJITCompilerTimeStatGroup - DESCRIPTION - "This group may not be implemented if the Java virtual - machine has no compilation system, or does not support - JIT Compiler time statistics. - " - ::= { jvmMgtMIBCompliances 1 } - - --- units of conformance - -jvmClassLoadingGroups OBJECT IDENTIFIER ::= { jvmMgtMIBGroups 1 } - -jvmClassLoadingBasicGroup OBJECT-GROUP - OBJECTS { - jvmClassesLoadedCount, - jvmClassesTotalLoadedCount, - jvmClassesUnloadedCount - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.ClassLoadingMXBean interface. - " - ::= { jvmClassLoadingGroups 1 } - -jvmClassLoadingSetGroup OBJECT-GROUP - OBJECTS { - jvmClassesVerboseLevel - } - STATUS current - DESCRIPTION - "A collection of writable scalar objects that are mapped from JSR 163 - java.lang.management.ClassLoadingMXBean interface, and make it possible - to act on class loading. Accessing these objects may - require special permissions - the agent implementation is - responsible for puting in place the appropriate access control - if needed. - " - ::= { jvmClassLoadingGroups 2 } - -jvmMemoryGroups OBJECT IDENTIFIER ::= { jvmMgtMIBGroups 2 } - -jvmMemoryBasicGroup OBJECT-GROUP - OBJECTS { - jvmMemoryPendingFinalCount - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.MemoryManagerMXBean interface. - " - ::= { jvmMemoryGroups 1 } - -jvmMemoryHeapUsageGroup OBJECT-GROUP - OBJECTS { - jvmMemoryHeapInitSize, - jvmMemoryHeapUsed, - jvmMemoryHeapCommitted, - jvmMemoryHeapMaxSize - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.MemoryMXBean.getHeapMemoryUsage(). - When several of these objects are requested within a single - SNMP request, the agent must ensure that - java.lang.management.MemoryPoolMXBean.getHeapMemoryUsage() is - called only once, in order to guarantee that the set of - values returned for these objects remain coherent and give - a consistent snapshot of the heap memory usage made by - Heap Memory Pools. - " - ::= { jvmMemoryGroups 2 } - -jvmMemoryNonHeapUsageGroup OBJECT-GROUP - OBJECTS { - jvmMemoryNonHeapInitSize, - jvmMemoryNonHeapUsed, - jvmMemoryNonHeapCommitted, - jvmMemoryNonHeapMaxSize - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.MemoryMXBean.getNonHeapMemoryUsage(). - When several of these objects are requested within a single - SNMP request, the agent must ensure that - java.lang.management.MemoryPoolMXBean.getNonHeapMemoryUsage() is - called only once, in order to guarantee that the set of - values returned for these objects remain coherent and give - a consistent snapshot of the non heap memory usage made by - Non Heap Memory Pools. - " - ::= { jvmMemoryGroups 3 } - -jvmMemorySetGroup OBJECT-GROUP - OBJECTS { - jvmMemoryGCVerboseLevel, - jvmMemoryGCCall - } - STATUS current - DESCRIPTION - "A collection of writable scalar objects that are mapped from JSR 163 - java.lang.management.MemoryMXBean interface, and make it possible - to act on the Garbage Collector. Accessing these objects may - require special permissions - the agent implementation is - responsible for puting in place the appropriate access control - if needed. - " - ::= { jvmMemoryGroups 4 } - -jvmMemManagerGroup OBJECT-GROUP - OBJECTS { - jvmMemManagerName, - jvmMemManagerState - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.MemoryManagerMXBean interface. - " - ::= { jvmMemoryGroups 5 } - -jvmMemGCGroup OBJECT-GROUP - OBJECTS { - jvmMemGCCount, - jvmMemGCTimeMs - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.GarbageCollectorMXBean interface, and are - specific to GarbageCollector MXBeans. - These objects are used to model the inheritence link between - GarbageCollectorMXBean and its super interface - MemoryManagerMXBean. - " - ::= { jvmMemoryGroups 6 } - -jvmMemPoolGroups OBJECT IDENTIFIER ::= { jvmMemoryGroups 7 } - -jvmMemPoolBasicGroup OBJECT-GROUP - OBJECTS { - jvmMemPoolName, - jvmMemPoolType, - jvmMemPoolState, - jvmMemPoolPeakReset, - jvmMemPoolThreshdSupport, - jvmMemPoolCollectThreshdSupport - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.MemoryPoolMXBean interface. - " - ::= { jvmMemPoolGroups 1 } - -jvmMemPoolMonitoringGroup OBJECT-GROUP - OBJECTS { - jvmMemPoolThreshold, - jvmMemPoolThreshdCount - } - STATUS current - DESCRIPTION - "Memory usage threshold objects mapped from - JSR 163 java.lang.management.MemoryPoolMXBean interface, which makes - it possible to configure low memory detection. - Accessing this object may require special permissions - the agent - implementation is responsible for puting in place the appropriate - access control if needed. - " - ::= { jvmMemPoolGroups 2 } - -jvmMemPoolUsageGroup OBJECT-GROUP - OBJECTS { - jvmMemPoolInitSize, - jvmMemPoolUsed, - jvmMemPoolCommitted, - jvmMemPoolMaxSize - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.MemoryPoolMXBean.getUsage(). - When several of these objects are requested within a single - SNMP request, the agent must ensure that - java.lang.management.MemoryPoolMXBean.getUsage() is - called only once, in order to guarantee that the set of - values returned for these objects remain coherent and give - a consistent snapshot of the memory used by this Memory - Pool. - " - ::= { jvmMemPoolGroups 3 } - -jvmMemPoolPeakUsageGroup OBJECT-GROUP - OBJECTS { - jvmMemPoolPeakUsed, - jvmMemPoolPeakCommitted, - jvmMemPoolPeakMaxSize - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.MemoryPoolMXBean.getPeakUsage(). - When several of these objects are requested within a single - SNMP request, the agent must ensure that - java.lang.management.MemoryPoolMXBean.getPeakUsage() is - called only once, in order to guarantee that the set of - values returned for these objects remain coherent and give - a consistent snapshot of the peak memory usage made by - this Memory Pool. - " - ::= { jvmMemPoolGroups 4 } - -jvmMemPoolCollectUsageGroup OBJECT-GROUP - OBJECTS { - jvmMemPoolCollectUsed, - jvmMemPoolCollectCommitted, - jvmMemPoolCollectMaxSize - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.MemoryPoolMXBean.getCollectionUsage(). - When several of these objects are requested within a single - SNMP request, the agent must ensure that - java.lang.management.MemoryPoolMXBean.getCollectionUsage() is - called only once, in order to guarantee that the set of - values returned for these objects remain coherent and give - a consistent snapshot of the collection memory usage made by - this Memory Pool. - " - ::= { jvmMemPoolGroups 5 } - -jvmMemPoolCollectMonitoringGroup OBJECT-GROUP - OBJECTS { - jvmMemPoolCollectThreshold, - jvmMemPoolCollectThreshdCount - } - STATUS current - DESCRIPTION - "Memory collection usage threshold objects mapped from JSR 163 - java.lang.management.MemoryPoolMXBean interface, which makes - it possible to configure low memory detection. - Accessing this object may require special permissions - the agent - implementation is responsible for putting in place the appropriate - access control if needed. - " - ::= { jvmMemPoolGroups 6 } - - -jvmMemMgrPoolRelationGroup OBJECT-GROUP - OBJECTS { - jvmMemMgrRelManagerName, - jvmMemMgrRelPoolName - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.MemoryPoolMXBean and - java.lang.management.MemoryManagerMXBean interface, and show the - relationship between Memory Managers and Memory Pools. - " - ::= { jvmMemoryGroups 8 } - -jvmThreadGroups OBJECT IDENTIFIER ::= { jvmMgtMIBGroups 3 } - -jvmThreadBasicGroup OBJECT-GROUP - OBJECTS { - jvmThreadCount, - jvmThreadDaemonCount, - jvmThreadPeakCount, - jvmThreadTotalStartedCount, - jvmThreadContentionMonitoring, - jvmThreadCpuTimeMonitoring, - jvmThreadPeakCountReset - } - STATUS current - DESCRIPTION - "A collection of scalar objects that are mapped from JSR 163 - java.lang.management.ThreadMXBean interface. - " - ::= { jvmThreadGroups 1 } - -jvmThreadInstanceGroups OBJECT IDENTIFIER ::= { jvmThreadGroups 2 } - -jvmThreadInstanceBasicGroup OBJECT-GROUP - OBJECTS { - jvmThreadInstId, - jvmThreadInstState, - jvmThreadInstName, - jvmThreadInstLockName, - jvmThreadInstLockOwnerPtr - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.ThreadMXBean interface, and are - relative to an instance of java.lang.Thread. - " - ::= { jvmThreadInstanceGroups 1} - -jvmThreadInstanceCpuGroup OBJECT-GROUP - OBJECTS { - jvmThreadInstCpuTimeNs - } - STATUS current - DESCRIPTION - "A columnar object mapped from JSR 163 - java.lang.management.ThreadMXBean interface which provides CPU - time statistics about an instance of java.lang.Thread. - " - ::= { jvmThreadInstanceGroups 2 } - - -jvmThreadInstanceBlockGroup OBJECT-GROUP - OBJECTS { - jvmThreadInstBlockCount, - jvmThreadInstBlockTimeMs, - jvmThreadInstWaitCount, - jvmThreadInstWaitTimeMs - } - STATUS current - DESCRIPTION - "A collection of columnar objects that are mapped from JSR 163 - java.lang.management.ThreadMXBean interface, and which provide - synchronization statistics about an instance of java.lang.Thread. - " - ::= { jvmThreadInstanceGroups 3 } - - -jvmRuntimeGroups OBJECT IDENTIFIER ::= { jvmMgtMIBGroups 4 } - -jvmRuntimeBasicGroup OBJECT-GROUP - OBJECTS { - jvmRTName, - jvmRTVMName, - jvmRTVMVendor, - jvmRTVMVersion, - jvmRTSpecName, - jvmRTSpecVendor, - jvmRTSpecVersion, - jvmRTManagementSpecVersion, - jvmRTUptimeMs, - jvmRTStartTimeMs, - jvmRTBootClassPathSupport, - jvmRTInputArgsCount, - jvmRTInputArgsItem, - jvmRTClassPathItem, - jvmRTLibraryPathItem - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.RuntimeMXBean interface. - " - ::= { jvmRuntimeGroups 1 } - - -jvmRuntimeBootCPGroup OBJECT-GROUP - OBJECTS { - jvmRTBootClassPathItem - } - STATUS current - DESCRIPTION - "A columnar object that is mapped from JSR 163 - java.lang.management.RuntimeMXBean.getBootClassPath() interface, - and provide information about bootclasspath elements. - " - ::= { jvmRuntimeGroups 2 } - -jvmJITCompilerGroups OBJECT IDENTIFIER ::= { jvmMgtMIBGroups 5 } - -jvmJITCompilerBasicGroup OBJECT-GROUP - OBJECTS { - jvmJITCompilerName, - jvmJITCompilerTimeMonitoring - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.CompilationMXBean interface. - " - ::= { jvmJITCompilerGroups 1 } - -jvmJITCompilerTimeStatGroup OBJECT-GROUP - OBJECTS { - jvmJITCompilerTimeMs - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.CompilationMXBean interface and provide - time statistic about the JIT Compiler. - " - ::= { jvmJITCompilerGroups 2 } - -jvmOSGroup OBJECT-GROUP - OBJECTS { - jvmOSName, - jvmOSArch, - jvmOSVersion, - jvmOSProcessorCount - } - STATUS current - DESCRIPTION - "A collection of objects that are mapped from JSR 163 - java.lang.management.OperatingSystemMXBean interface. - " - ::= { jvmMgtMIBGroups 6 } - -jvmLowMemoryUsageNotifGroup NOTIFICATION-GROUP - NOTIFICATIONS { - jvmLowMemoryPoolUsageNotif - } - STATUS current - DESCRIPTION - "A collection of notifications emitted when low - memory usage conditions are detected. - " - ::= { jvmMgtMIBGroups 7 } - -jvmLowMemoryCollectNotifGroup NOTIFICATION-GROUP - NOTIFICATIONS { - jvmLowMemoryPoolCollectNotif - } - STATUS current - DESCRIPTION - "A collection of notifications emitted when low - collection memory usage conditions are detected. - " - ::= { jvmMgtMIBGroups 8 } - -END From 7a520e19a19953f1a0eedb9ffd069317036f9cfe Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Thu, 8 Jun 2017 12:24:13 +0100 Subject: [PATCH 19/59] 8181430: HTTP/2 client might deadlock when receiving data during the initial handshake CountDownLatch removed. Data produced during the handshake is instead buffered until the preface is sent. Reviewed-by: michaelm, msheppar, prappo --- .../jdk/incubator/http/Http2Connection.java | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java index 5c13878ad86..275325f8b29 100644 --- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java +++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,47 +111,56 @@ class Http2Connection { */ - // A small class that allows to control the state of - // the connection preface. This is just a thin wrapper - // over a CountDownLatch. - private final class PrefaceController { + // A small class that allows to control frames with respect to the state of + // the connection preface. Any data received before the connection + // preface is sent will be buffered. + private final class FramesController { volatile boolean prefaceSent; - private final CountDownLatch latch = new CountDownLatch(1); + volatile List pending; - // This method returns immediately if the preface is sent, - // and blocks until the preface is sent if not. - // In the common case this where the preface is already sent - // this will cost not more than a volatile read. - void waitUntilPrefaceSent() { + boolean processReceivedData(FramesDecoder decoder, ByteBufferReference buf) + throws IOException + { + // if preface is not sent, buffers data in the pending list if (!prefaceSent) { - try { - // If the preface is not sent then await on the latch - Log.logTrace("Waiting until connection preface is sent"); - latch.await(); - Log.logTrace("Preface sent: resuming reading"); - assert prefaceSent; - } catch (InterruptedException e) { - String msg = Utils.stackTrace(e); - Log.logTrace(msg); - shutdown(e); + synchronized (this) { + if (!prefaceSent) { + if (pending == null) pending = new ArrayList<>(); + pending.add(buf); + return false; + } } } + + // Preface is sent. Checks for pending data and flush it. + // We rely on this method being called from within the readlock, + // so we know that no other thread could execute this method + // concurrently while we're here. + // This ensures that later incoming buffers will not + // be processed before we have flushed the pending queue. + // No additional synchronization is therefore necessary here. + List pending = this.pending; + this.pending = null; + if (pending != null) { + // flush pending data + for (ByteBufferReference b : pending) { + decoder.decode(b); + } + } + + // push the received buffer to the frames decoder. + decoder.decode(buf); + return true; } // Mark that the connection preface is sent void markPrefaceSent() { assert !prefaceSent; - prefaceSent = true; - // Release the latch. If asyncReceive was scheduled it will - // be waiting for the release and will be woken up by this - // call. If not, then the semaphore will no longer be used after - // this. - latch.countDown(); + synchronized (this) { + prefaceSent = true; + } } - boolean isPrefaceSent() { - return prefaceSent; - } } volatile boolean closed; @@ -176,7 +185,7 @@ class Http2Connection { * Each of this connection's Streams MUST use this controller. */ private final WindowController windowController = new WindowController(); - private final PrefaceController prefaceController = new PrefaceController(); + private final FramesController framesController = new FramesController(); final WindowUpdateSender windowUpdater; static final int DEFAULT_FRAME_SIZE = 16 * 1024; @@ -409,11 +418,11 @@ class Http2Connection { // SettingsFrame sent by the server) before the connection // preface is fully sent might result in the server // sending a GOAWAY frame with 'invalid_preface'. - prefaceController.waitUntilPrefaceSent(); synchronized (readlock) { - assert prefaceController.isPrefaceSent(); try { - framesDecoder.decode(buffer); + // the readlock ensures that the order of incoming buffers + // is preserved. + framesController.processReceivedData(framesDecoder, buffer); } catch (Throwable e) { String msg = Utils.stackTrace(e); Log.logTrace(msg); @@ -646,7 +655,8 @@ class Http2Connection { Log.logFrames(sf, "OUT"); // send preface bytes and SettingsFrame together connection.write(ref.get()); - + // mark preface sent. + framesController.markPrefaceSent(); Log.logTrace("PREFACE_BYTES sent"); Log.logTrace("Settings Frame sent"); @@ -654,8 +664,10 @@ class Http2Connection { // minus the initial 64 K specified in protocol final int len = client2.client().getReceiveBufferSize() - (64 * 1024 - 1); windowUpdater.sendWindowUpdate(len); + // there will be an ACK to the windows update - which should + // cause any pending data stored before the preface was sent to be + // flushed (see PrefaceController). Log.logTrace("finished sending connection preface"); - prefaceController.markPrefaceSent(); } /** From 3d902cf92ab1590049931ccf08cfbaa98924b70b Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Thu, 8 Jun 2017 12:41:07 +0100 Subject: [PATCH 20/59] 8180044: java/net/httpclient/ManyRequests.java failed due to timeout Fixes several race conditions observed while testing. Reviewed-by: michaelm, msheppar, prappo --- .../jdk/incubator/http/HttpClientImpl.java | 8 ++- .../incubator/http/PlainHttpConnection.java | 23 +++++++- .../classes/jdk/incubator/http/Stream.java | 4 +- .../sun/net/httpserver/FileServerHandler.java | 16 +++-- .../java/net/httpclient/ManyRequests.java | 59 ++++++++++++++++--- .../java/net/httpclient/ManyRequests2.java | 48 +++++++++++++++ 6 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 jdk/test/java/net/httpclient/ManyRequests2.java diff --git a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java index a0cb429ef55..c4087b0a4ec 100644 --- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java +++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java @@ -344,7 +344,13 @@ class HttpClientImpl extends HttpClient { c.configureBlocking(false); SelectionKey key = c.keyFor(selector); SelectorAttachment sa; - if (key == null) { + if (key == null || !key.isValid()) { + if (key != null) { + // key is canceled. + // invoke selectNow() to purge it + // before registering the new event. + selector.selectNow(); + } sa = new SelectorAttachment(c, selector); } else { sa = (SelectorAttachment) key.attachment(); diff --git a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java index 7bb69850c83..6126725b3cf 100644 --- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java +++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java @@ -62,6 +62,7 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { private volatile Consumer asyncReceiver; private volatile Consumer errorReceiver; private volatile Supplier readBufferSupplier; + private boolean asyncReading; private final AsyncWriteQueue asyncOutputQ = new AsyncWriteQueue(this::asyncOutput); @@ -70,6 +71,9 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { @Override public void startReading() { try { + synchronized(reading) { + asyncReading = true; + } client.registerEvent(new ReadEvent()); } catch (IOException e) { shutdown(); @@ -78,6 +82,9 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { @Override public void stopAsyncReading() { + synchronized(reading) { + asyncReading = false; + } client.cancelRegistration(chan); } @@ -279,7 +286,7 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { void asyncRead() { synchronized (reading) { try { - while (true) { + while (asyncReading) { ByteBufferReference buf = readBufferSupplier.get(); int n = chan.read(buf.get()); if (n == -1) { @@ -325,7 +332,7 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { return -1; } Utils.flipToMark(buf, mark); - String s = "Receive (" + n + " bytes) "; + // String s = "Receive (" + n + " bytes) "; //debugPrint(s, buf); return n; } @@ -393,6 +400,10 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { shutdown(); } + @Override + public String toString() { + return super.toString() + "/" + chan; + } } // used in blocking channels only @@ -422,6 +433,11 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { public void abort() { close(); } + + @Override + public String toString() { + return super.toString() + "/" + chan; + } } @Override @@ -447,7 +463,8 @@ class PlainHttpConnection extends HttpConnection implements AsyncConnection { CompletableFuture whenReceivingResponse() { CompletableFuture cf = new MinimalFuture<>(); try { - client.registerEvent(new ReceiveResponseEvent(cf)); + ReceiveResponseEvent evt = new ReceiveResponseEvent(cf); + client.registerEvent(evt); } catch (IOException e) { cf.completeExceptionally(e); } diff --git a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java index a0eb54e0076..de0c6a8f7cd 100644 --- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java +++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java @@ -803,7 +803,9 @@ class Stream extends ExchangeImpl { completeResponseExceptionally(e); try { // will send a RST_STREAM frame - connection.resetStream(streamid, ResetFrame.CANCEL); + if (streamid != 0) { + connection.resetStream(streamid, ResetFrame.CANCEL); + } } catch (IOException ex) { Log.logError(ex); } diff --git a/jdk/test/com/sun/net/httpserver/FileServerHandler.java b/jdk/test/com/sun/net/httpserver/FileServerHandler.java index 00ccd7d1a43..298dc095906 100644 --- a/jdk/test/com/sun/net/httpserver/FileServerHandler.java +++ b/jdk/test/com/sun/net/httpserver/FileServerHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,8 +214,8 @@ class EchoHandler implements HttpHandler { t.sendResponseHeaders(200, in.length); OutputStream os = t.getResponseBody(); os.write(in); - os.close(); - is.close(); + close(os); + close(is); } else { OutputStream os = t.getResponseBody(); byte[] buf = new byte[64 * 1024]; @@ -232,9 +232,15 @@ class EchoHandler implements HttpHandler { String s = Integer.toString(count); os.write(s.getBytes()); } + close(os); + close(is); + } + } + + protected void close(OutputStream os) throws IOException { os.close(); + } + protected void close(InputStream is) throws IOException { is.close(); } } -} - diff --git a/jdk/test/java/net/httpclient/ManyRequests.java b/jdk/test/java/net/httpclient/ManyRequests.java index 47f21c60d0f..7420c7223ed 100644 --- a/jdk/test/java/net/httpclient/ManyRequests.java +++ b/jdk/test/java/net/httpclient/ManyRequests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8087112 + * @bug 8087112 8180044 * @modules jdk.incubator.httpclient * java.logging * jdk.httpserver @@ -32,13 +32,20 @@ * @compile ../../../com/sun/net/httpserver/LogFilter.java * @compile ../../../com/sun/net/httpserver/FileServerHandler.java * @run main/othervm/timeout=40 -Djdk.httpclient.HttpClient.log=ssl ManyRequests + * @run main/othervm/timeout=40 -Dtest.insertDelay=true ManyRequests + * @run main/othervm/timeout=40 -Dtest.chunkSize=64 ManyRequests + * @run main/othervm/timeout=40 -Dtest.insertDelay=true -Dtest.chunkSize=64 ManyRequests * @summary Send a large number of requests asynchronously */ + // * @run main/othervm/timeout=40 -Djdk.httpclient.HttpClient.log=ssl ManyRequests import com.sun.net.httpserver.HttpsConfigurator; import com.sun.net.httpserver.HttpsParameters; import com.sun.net.httpserver.HttpsServer; +import com.sun.net.httpserver.HttpExchange; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import jdk.incubator.http.HttpClient; import jdk.incubator.http.HttpRequest; import java.net.InetSocketAddress; @@ -65,7 +72,10 @@ public class ManyRequests { Logger logger = Logger.getLogger("com.sun.net.httpserver"); logger.setLevel(Level.ALL); logger.info("TEST"); - + System.out.println("Sending " + REQUESTS + + " requests; delay=" + INSERT_DELAY + + ", chunks=" + CHUNK_SIZE + + ", XFixed=" + XFIXED); SSLContext ctx = new SimpleSSLContext().get(); InetSocketAddress addr = new InetSocketAddress(0); @@ -86,11 +96,36 @@ public class ManyRequests { //static final int REQUESTS = 1000; static final int REQUESTS = 20; + static final boolean INSERT_DELAY = Boolean.getBoolean("test.insertDelay"); + static final int CHUNK_SIZE = Math.max(0, + Integer.parseInt(System.getProperty("test.chunkSize", "0"))); + static final boolean XFIXED = Boolean.getBoolean("test.XFixed"); + + static class TestEchoHandler extends EchoHandler { + final Random rand = new Random(); + @Override + public void handle(HttpExchange e) throws IOException { + System.out.println("Server: received " + e.getRequestURI()); + super.handle(e); + } + protected void close(OutputStream os) throws IOException { + if (INSERT_DELAY) { + try { Thread.sleep(rand.nextInt(200)); } catch (InterruptedException e) {} + } + super.close(os); + } + protected void close(InputStream is) throws IOException { + if (INSERT_DELAY) { + try { Thread.sleep(rand.nextInt(200)); } catch (InterruptedException e) {} + } + super.close(is); + } + } static void test(HttpsServer server, HttpClient client) throws Exception { int port = server.getAddress().getPort(); - URI uri = new URI("https://127.0.0.1:" + port + "/foo/x"); - server.createContext("/foo", new EchoHandler()); + URI baseURI = new URI("https://127.0.0.1:" + port + "/foo/x"); + server.createContext("/foo", new TestEchoHandler()); server.start(); RequestLimiter limiter = new RequestLimiter(40); @@ -99,24 +134,32 @@ public class ManyRequests { HashMap bodies = new HashMap<>(); for (int i=0; i client.sendAsync(r, asByteArray())) + .thenCompose((v) -> { + System.out.println("Client: sendAsync: " + r.uri()); + return client.sendAsync(r, asByteArray()); + }) .thenCompose((resp) -> { limiter.requestComplete(); if (resp.statusCode() != 200) { String s = "Expected 200, got: " + resp.statusCode(); + System.out.println(s + " from " + + resp.request().uri().getPath()); return completedWithIOException(s); } else { counter++; - System.out.println("Result from " + counter); + System.out.println("Result (" + counter + ") from " + + resp.request().uri().getPath()); } return CompletableFuture.completedStage(resp.body()) .thenApply((b) -> new Pair<>(resp, b)); diff --git a/jdk/test/java/net/httpclient/ManyRequests2.java b/jdk/test/java/net/httpclient/ManyRequests2.java new file mode 100644 index 00000000000..2ec01de9734 --- /dev/null +++ b/jdk/test/java/net/httpclient/ManyRequests2.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8087112 8180044 + * @modules jdk.incubator.httpclient + * java.logging + * jdk.httpserver + * @library /lib/testlibrary/ / + * @build jdk.testlibrary.SimpleSSLContext EchoHandler + * @compile ../../../com/sun/net/httpserver/LogFilter.java + * @compile ../../../com/sun/net/httpserver/FileServerHandler.java + * @build ManyRequests ManyRequests2 + * @run main/othervm/timeout=40 -Dtest.XFixed=true ManyRequests2 + * @run main/othervm/timeout=40 -Dtest.XFixed=true -Dtest.insertDelay=true ManyRequests2 + * @run main/othervm/timeout=40 -Dtest.XFixed=true -Dtest.chunkSize=64 ManyRequests2 + * @run main/othervm/timeout=40 -Dtest.XFixed=true -Dtest.insertDelay=true -Dtest.chunkSize=64 ManyRequests2 + * @summary Send a large number of requests asynchronously. The server echoes back using known content length. + */ + // * @run main/othervm/timeout=40 -Djdk.httpclient.HttpClient.log=ssl ManyRequests + +public class ManyRequests2 { + + public static void main(String[] args) throws Exception { + ManyRequests.main(args); + } +} From 0a843fc371c2158e985df69995b68098b3a76ed2 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 8 Jun 2017 13:49:11 +0200 Subject: [PATCH 21/59] 8180300: Move JDWP specs to specs directory Reviewed-by: sspitsyn --- .../share/classes/com/sun/jdi/connect/spi/Connection.java | 4 ++-- .../classes/com/sun/jdi/connect/spi/TransportService.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java index 2067d714c4b..1e7943fbd70 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java @@ -82,7 +82,7 @@ public abstract class Connection { * thrown. The first byte of the packet is stored in element * {@code 0} of the byte array, the second in element {@code 1}, * and so on. The bytes in the byte array are laid out as per the - * + * * JDWP specification. That is, all fields in the packet * are in big endian order as per the JDWP specification. * @@ -119,7 +119,7 @@ public abstract class Connection { * *

The byte array provided to this method should be laid out * as per the + * href="{@docRoot}/../specs/jdwp/jdwp-spec.html"> * JDWP specification. That is, all fields in the packet * are in big endian order. The first byte, that is element * {@code pkt[0]}, is the first byte of the {@code length} field. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java index 61eba8880cc..1c06bd39447 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java @@ -43,7 +43,7 @@ import com.sun.jdi.connect.TransportTimeoutException; * Debug Wire Protocol (JDWP) packets over an underlying * communication protocol. In essence a transport service * implementation binds JDWP (as specified in the - * + * * JDWP specification) to an underlying communication * protocol. A transport service implementation provides * a reliable JDWP packet transportation service. JDWP @@ -166,7 +166,7 @@ public abstract class TransportService { * is followed by a handshake to ensure that the connection is * to a target VM. The handshake involves the exchange * of a string JDWP-Handshake as specified in the + * href="{@docRoot}/../specs/jdwp/jdwp-spec.html"> * Java Debug Wire Protocol specification. * * @param address @@ -315,7 +315,7 @@ public abstract class TransportService { * connection is indeed to a target VM. The handshake involves * the exchange of a string JDWP-Handshake as specified * in the + * href="{@docRoot}/../specs/jdwp/jdwp-spec.html"> * Java Debug Wire Protocol specification. * * @param listenKey From e9fe6f3c6b7c9d70138948717a351988e1df2d18 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 8 Jun 2017 14:53:48 +0200 Subject: [PATCH 22/59] 8178064: OpenJDK RI binary should include the license file for freetype Reviewed-by: tbell, ihse --- common/autoconf/generated-configure.sh | 158 ++++++++++++++++++++++++- common/autoconf/lib-freetype.m4 | 16 +++ common/autoconf/spec.gmk.in | 1 + common/conf/jib-profiles.js | 10 ++ make/CreateJmods.gmk | 1 + 5 files changed, 185 insertions(+), 1 deletion(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index cf23d7e99b8..ab0642affe6 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -688,6 +688,7 @@ LIBFFI_LIBS LIBFFI_CFLAGS ALSA_LIBS ALSA_CFLAGS +FREETYPE_LICENSE FREETYPE_BUNDLE_LIB_PATH FREETYPE_LIBS FREETYPE_CFLAGS @@ -1199,6 +1200,7 @@ with_freetype_include with_freetype_lib with_freetype_src enable_freetype_bundling +with_freetype_license with_alsa with_alsa_include with_alsa_lib @@ -2151,6 +2153,7 @@ Optional Packages: --with-freetype-src specify directory with freetype sources to automatically build the library (experimental, Windows-only) + --with-freetype-license if bundling freetype, also bundle this license file --with-alsa specify prefix directory for the alsa package (expecting the libraries under PATH/lib and the headers under PATH/include) @@ -5183,7 +5186,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1494858828 +DATE_WHEN_GENERATED=1496926402 ############################################################################### # @@ -57706,6 +57709,12 @@ if test "${enable_freetype_bundling+set}" = set; then : fi +# Check whether --with-freetype-license was given. +if test "${with_freetype_license+set}" = set; then : + withval=$with_freetype_license; +fi + + # Need to specify explicitly since it needs to be overridden on some versions of macosx FREETYPE_BASE_NAME=freetype FREETYPE_CFLAGS= @@ -63652,6 +63661,153 @@ $as_echo "$BUNDLE_FREETYPE" >&6; } fi # end freetype needed + FREETYPE_LICENSE="" + if test "x$with_freetype_license" = "xyes"; then + as_fn_error $? "--with-freetype-license must have a value" "$LINENO" 5 + elif test "x$with_freetype_license" != "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype license" >&5 +$as_echo_n "checking for freetype license... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_freetype_license" >&5 +$as_echo "$with_freetype_license" >&6; } + FREETYPE_LICENSE="$with_freetype_license" + + # Only process if variable expands to non-empty + + if test "x$FREETYPE_LICENSE" != x; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$FREETYPE_LICENSE" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of FREETYPE_LICENSE" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-style (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + FREETYPE_LICENSE="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$FREETYPE_LICENSE" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + FREETYPE_LICENSE="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a unix platform. Hooray! :) + path="$FREETYPE_LICENSE" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of FREETYPE_LICENSE, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + if test -d "$path"; then + FREETYPE_LICENSE="`cd "$path"; $THEPWDCMD -L`" + else + dir="`$DIRNAME "$path"`" + base="`$BASENAME "$path"`" + FREETYPE_LICENSE="`cd "$dir"; $THEPWDCMD -L`/$base" + fi + fi + fi + + if test ! -f "$FREETYPE_LICENSE"; then + as_fn_error $? "$FREETYPE_LICENSE cannot be found" "$LINENO" 5 + fi + fi + + diff --git a/common/autoconf/lib-freetype.m4 b/common/autoconf/lib-freetype.m4 index e7790caa64b..17dd726e54c 100644 --- a/common/autoconf/lib-freetype.m4 +++ b/common/autoconf/lib-freetype.m4 @@ -194,6 +194,8 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], [specify directory with freetype sources to automatically build the library (experimental, Windows-only)])]) AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling], [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])]) + AC_ARG_WITH(freetype-license, [AS_HELP_STRING([--with-freetype-license], + [if bundling freetype, also bundle this license file])]) # Need to specify explicitly since it needs to be overridden on some versions of macosx FREETYPE_BASE_NAME=freetype @@ -443,7 +445,21 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], fi # end freetype needed + FREETYPE_LICENSE="" + if test "x$with_freetype_license" = "xyes"; then + AC_MSG_ERROR([--with-freetype-license must have a value]) + elif test "x$with_freetype_license" != "x"; then + AC_MSG_CHECKING([for freetype license]) + AC_MSG_RESULT([$with_freetype_license]) + FREETYPE_LICENSE="$with_freetype_license" + BASIC_FIXUP_PATH(FREETYPE_LICENSE) + if test ! -f "$FREETYPE_LICENSE"; then + AC_MSG_ERROR([$FREETYPE_LICENSE cannot be found]) + fi + fi + AC_SUBST(FREETYPE_BUNDLE_LIB_PATH) AC_SUBST(FREETYPE_CFLAGS) AC_SUBST(FREETYPE_LIBS) + AC_SUBST(FREETYPE_LICENSE) ]) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 9946fa2b679..877ede9d9b1 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -312,6 +312,7 @@ DEFAULT_MAKE_TARGET:=@DEFAULT_MAKE_TARGET@ FREETYPE_LIBS:=@FREETYPE_LIBS@ FREETYPE_CFLAGS:=@FREETYPE_CFLAGS@ FREETYPE_BUNDLE_LIB_PATH=@FREETYPE_BUNDLE_LIB_PATH@ +FREETYPE_LICENSE=@FREETYPE_LICENSE@ CUPS_CFLAGS:=@CUPS_CFLAGS@ ALSA_LIBS:=@ALSA_LIBS@ ALSA_CFLAGS:=@ALSA_CFLAGS@ diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index 1892fafab9f..54ccfcecd52 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -893,6 +893,16 @@ var getJibProfilesProfiles = function (input, common, data) { } }); + // The windows ri profile needs to add the freetype license file + profilesRiFreetype = { + "windows-x86-ri": { + configure_args: "--with-freetype-license=" + + input.get("freetype", "install_path") + + "/freetype-2.7.1-v120-x86/freetype.md" + } + }; + profiles = concatObjects(profiles, profilesRiFreetype); + // Generate the missing platform attributes profiles = generatePlatformAttributes(profiles); profiles = generateDefaultMakeTargetsConfigureArg(common, profiles); diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 7d4287e02d8..2a27e3629a6 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -81,6 +81,7 @@ endif LEGAL_NOTICES := \ $(SUPPORT_OUTPUTDIR)/modules_legal/java.base \ + $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)) \ $(call FindModuleLegalDirs, $(MODULE)) \ # From 938744edaba1102653cd10b939218820e848a0f8 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 8 Jun 2017 14:53:56 +0200 Subject: [PATCH 23/59] 8178064: OpenJDK RI binary should include the license file for freetype Reviewed-by: tbell, ihse --- jdk/make/copy/Copy-java.desktop.gmk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jdk/make/copy/Copy-java.desktop.gmk b/jdk/make/copy/Copy-java.desktop.gmk index 49d6b86aeb2..710375594e4 100644 --- a/jdk/make/copy/Copy-java.desktop.gmk +++ b/jdk/make/copy/Copy-java.desktop.gmk @@ -77,6 +77,13 @@ ifneq ($(FREETYPE_BUNDLE_LIB_PATH), ) endif TARGETS += $(FREETYPE_TARGET_LIB) + + $(eval $(call SetupCopyFiles, COPY_FREETYPE_LICENSE, \ + FILES := $(FREETYPE_LICENSE), \ + DEST := $(LEGAL_DST_DIR), \ + )) + + TARGETS += $(COPY_FREETYPE_LICENSE) endif ################################################################################ From 18b1dfcafa832f889733e32522ce735c85772e17 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 9 Jun 2017 16:52:07 +0100 Subject: [PATCH 24/59] 8181867: [tests] Reorganize EchoHandlers This fix reorganize some test files and rename some test classes. Several classes named EchoHandler in the unnamed package are renamed to make it clear what classes (and sources) tests that use these EchoHandler implementations effectively depend on. Reviewed-by: chegar --- .../com/sun/net/httpserver/EchoHandler.java | 98 +++++++ .../sun/net/httpserver/FileServerHandler.java | 266 ++++++------------ .../sun/net/httpserver/SimpleFileServer.java | 73 +++++ .../java/net/httpclient/HttpEchoHandler.java | 87 ++++++ .../net/httpclient/LightWeightHttpServer.java | 5 +- .../java/net/httpclient/ManyRequests.java | 3 +- .../java/net/httpclient/ManyRequests2.java | 3 +- .../java/net/httpclient/RequestBodyTest.java | 3 +- jdk/test/java/net/httpclient/SmokeTest.java | 5 +- .../java/net/httpclient/http2/BasicTest.java | 6 +- .../java/net/httpclient/http2/ErrorTest.java | 4 +- .../httpclient/http2/FixedThreadPoolTest.java | 6 +- .../net/httpclient/http2/RedirectTest.java | 4 +- .../http2/server/Http2EchoHandler.java | 76 +++++ 14 files changed, 442 insertions(+), 197 deletions(-) create mode 100644 jdk/test/com/sun/net/httpserver/EchoHandler.java create mode 100644 jdk/test/com/sun/net/httpserver/SimpleFileServer.java create mode 100644 jdk/test/java/net/httpclient/HttpEchoHandler.java create mode 100644 jdk/test/java/net/httpclient/http2/server/Http2EchoHandler.java diff --git a/jdk/test/com/sun/net/httpserver/EchoHandler.java b/jdk/test/com/sun/net/httpserver/EchoHandler.java new file mode 100644 index 00000000000..0b9de1f3d62 --- /dev/null +++ b/jdk/test/com/sun/net/httpserver/EchoHandler.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; +import java.util.concurrent.*; +import java.util.logging.*; +import java.io.*; +import java.net.*; +import java.security.*; +import javax.net.ssl.*; +import com.sun.net.httpserver.*; + +/** + * Implements a basic static EchoHandler for an HTTP server + */ +public class EchoHandler implements HttpHandler { + + byte[] read(InputStream is) throws IOException { + byte[] buf = new byte[1024]; + byte[] result = new byte[0]; + + while (true) { + int n = is.read(buf); + if (n > 0) { + byte[] b1 = new byte[result.length + n]; + System.arraycopy(result, 0, b1, 0, result.length); + System.arraycopy(buf, 0, b1, result.length, n); + result = b1; + } else if (n == -1) { + return result; + } + } + } + + public void handle (HttpExchange t) + throws IOException + { + InputStream is = t.getRequestBody(); + Headers map = t.getRequestHeaders(); + String fixedrequest = map.getFirst ("XFixed"); + + // return the number of bytes received (no echo) + String summary = map.getFirst ("XSummary"); + if (fixedrequest != null && summary == null) { + byte[] in = read(is); + t.sendResponseHeaders(200, in.length); + OutputStream os = t.getResponseBody(); + os.write(in); + close(os); + close(is); + } else { + OutputStream os = t.getResponseBody(); + byte[] buf = new byte[64 * 1024]; + t.sendResponseHeaders(200, 0); + int n, count=0;; + + while ((n = is.read(buf)) != -1) { + if (summary == null) { + os.write(buf, 0, n); + } + count += n; + } + if (summary != null) { + String s = Integer.toString(count); + os.write(s.getBytes()); + } + close(os); + close(is); + } + } + + protected void close(OutputStream os) throws IOException { + os.close(); + } + protected void close(InputStream is) throws IOException { + is.close(); + } +} diff --git a/jdk/test/com/sun/net/httpserver/FileServerHandler.java b/jdk/test/com/sun/net/httpserver/FileServerHandler.java index 298dc095906..bff78443839 100644 --- a/jdk/test/com/sun/net/httpserver/FileServerHandler.java +++ b/jdk/test/com/sun/net/httpserver/FileServerHandler.java @@ -31,216 +31,122 @@ import javax.net.ssl.*; import com.sun.net.httpserver.*; /** - * Implements a basic static content HTTP server + * Implements a basic static content HTTP file server handler * which understands text/html, text/plain content types * * Must be given an abs pathname to the document root. * Directory listings together with text + html files * can be served. * - * File Server created on files sub-path - * - * Echo server created on echo sub-path */ public class FileServerHandler implements HttpHandler { - public static void main (String[] args) throws Exception { - if (args.length != 3) { - System.out.println ("usage: java FileServerHandler rootDir port logfilename"); - System.exit(1); - } - Logger logger = Logger.getLogger("com.sun.net.httpserver"); - ConsoleHandler ch = new ConsoleHandler(); - logger.setLevel(Level.ALL); - ch.setLevel(Level.ALL); - logger.addHandler(ch); + String docroot; - String rootDir = args[0]; - int port = Integer.parseInt (args[1]); - String logfile = args[2]; - HttpServer server = HttpServer.create (new InetSocketAddress (port), 0); - HttpHandler h = new FileServerHandler (rootDir); - HttpHandler h1 = new EchoHandler (); + public FileServerHandler (String docroot) { + this.docroot = docroot; + } - HttpContext c = server.createContext ("/files", h); - c.getFilters().add (new LogFilter (new File (logfile))); - HttpContext c1 = server.createContext ("/echo", h1); - c.getFilters().add (new LogFilter (new File (logfile))); - c1.getFilters().add (new LogFilter (new File (logfile))); - server.setExecutor (Executors.newCachedThreadPool()); - server.start (); + int invocation = 1; + public void handle (HttpExchange t) + throws IOException + { + InputStream is = t.getRequestBody(); + Headers map = t.getRequestHeaders(); + Headers rmap = t.getResponseHeaders(); + URI uri = t.getRequestURI(); + String path = uri.getPath(); + + int x = 0; + while (is.read () != -1) x++; + is.close(); + File f = new File (docroot, path); + if (!f.exists()) { + notfound (t, path); + return; + } + String fixedrequest = map.getFirst ("XFixed"); + + String method = t.getRequestMethod(); + if (method.equals ("HEAD")) { + rmap.set ("Content-Length", Long.toString (f.length())); + t.sendResponseHeaders (200, -1); + t.close(); + } else if (!method.equals("GET")) { + t.sendResponseHeaders (405, -1); + t.close(); + return; } - String docroot; - - FileServerHandler (String docroot) { - this.docroot = docroot; + if (path.endsWith (".html") || path.endsWith (".htm")) { + rmap.set ("Content-Type", "text/html"); + } else { + rmap.set ("Content-Type", "text/plain"); } - - int invocation = 1; - public void handle (HttpExchange t) - throws IOException - { - InputStream is = t.getRequestBody(); - Headers map = t.getRequestHeaders(); - Headers rmap = t.getResponseHeaders(); - URI uri = t.getRequestURI(); - String path = uri.getPath(); - - int x = 0; - while (is.read () != -1) x++; - is.close(); - File f = new File (docroot, path); - if (!f.exists()) { - notfound (t, path); + if (f.isDirectory()) { + if (!path.endsWith ("/")) { + moved (t); return; } - String fixedrequest = map.getFirst ("XFixed"); - - String method = t.getRequestMethod(); - if (method.equals ("HEAD")) { - rmap.set ("Content-Length", Long.toString (f.length())); - t.sendResponseHeaders (200, -1); - t.close(); - } else if (!method.equals("GET")) { - t.sendResponseHeaders (405, -1); - t.close(); - return; + rmap.set ("Content-Type", "text/html"); + t.sendResponseHeaders (200, 0); + String[] list = f.list(); + OutputStream os = t.getResponseBody(); + PrintStream p = new PrintStream (os); + p.println ("

Directory listing for: " + path+ "

"); + p.println ("
    "); + for (int i=0; i"+list[i]+""); } - - if (path.endsWith (".html") || path.endsWith (".htm")) { - rmap.set ("Content-Type", "text/html"); + p.println ("


"); + p.flush(); + p.close(); + } else { + int clen; + if (fixedrequest != null) { + clen = (int) f.length(); } else { - rmap.set ("Content-Type", "text/plain"); + clen = 0; } - if (f.isDirectory()) { - if (!path.endsWith ("/")) { - moved (t); - return; - } - rmap.set ("Content-Type", "text/html"); - t.sendResponseHeaders (200, 0); - String[] list = f.list(); - OutputStream os = t.getResponseBody(); - PrintStream p = new PrintStream (os); - p.println ("

Directory listing for: " + path+ "

"); - p.println ("


"); - p.flush(); - p.close(); - } else { - int clen; - if (fixedrequest != null) { - clen = (int) f.length(); - } else { - clen = 0; - } - t.sendResponseHeaders (200, clen); - OutputStream os = t.getResponseBody(); - FileInputStream fis = new FileInputStream (f); - int count = 0; - try { + t.sendResponseHeaders (200, clen); + OutputStream os = t.getResponseBody(); + FileInputStream fis = new FileInputStream (f); + int count = 0; + try { byte[] buf = new byte [16 * 1024]; int len; while ((len=fis.read (buf)) != -1) { os.write (buf, 0, len); count += len; } - } catch (IOException e) { - e.printStackTrace(); - } - fis.close(); - os.close(); + } catch (IOException e) { + e.printStackTrace(); } - } - - void moved (HttpExchange t) throws IOException { - Headers req = t.getRequestHeaders(); - Headers map = t.getResponseHeaders(); - URI uri = t.getRequestURI(); - String host = req.getFirst ("Host"); - String location = "http://"+host+uri.getPath() + "/"; - map.set ("Content-Type", "text/html"); - map.set ("Location", location); - t.sendResponseHeaders (301, -1); - t.close(); - } - - void notfound (HttpExchange t, String p) throws IOException { - t.getResponseHeaders().set ("Content-Type", "text/html"); - t.sendResponseHeaders (404, 0); - OutputStream os = t.getResponseBody(); - String s = "

File not found

"; - s = s + p + "

"; - os.write (s.getBytes()); + fis.close(); os.close(); - t.close(); } } -class EchoHandler implements HttpHandler { - - byte[] read(InputStream is) throws IOException { - byte[] buf = new byte[1024]; - byte[] result = new byte[0]; - - while (true) { - int n = is.read(buf); - if (n > 0) { - byte[] b1 = new byte[result.length + n]; - System.arraycopy(result, 0, b1, 0, result.length); - System.arraycopy(buf, 0, b1, result.length, n); - result = b1; - } else if (n == -1) { - return result; - } - } + void moved (HttpExchange t) throws IOException { + Headers req = t.getRequestHeaders(); + Headers map = t.getResponseHeaders(); + URI uri = t.getRequestURI(); + String host = req.getFirst ("Host"); + String location = "http://"+host+uri.getPath() + "/"; + map.set ("Content-Type", "text/html"); + map.set ("Location", location); + t.sendResponseHeaders (301, -1); + t.close(); } - public void handle (HttpExchange t) - throws IOException - { - InputStream is = t.getRequestBody(); - Headers map = t.getRequestHeaders(); - String fixedrequest = map.getFirst ("XFixed"); - - // return the number of bytes received (no echo) - String summary = map.getFirst ("XSummary"); - if (fixedrequest != null && summary == null) { - byte[] in = read(is); - t.sendResponseHeaders(200, in.length); - OutputStream os = t.getResponseBody(); - os.write(in); - close(os); - close(is); - } else { - OutputStream os = t.getResponseBody(); - byte[] buf = new byte[64 * 1024]; - t.sendResponseHeaders(200, 0); - int n, count=0;; - - while ((n = is.read(buf)) != -1) { - if (summary == null) { - os.write(buf, 0, n); - } - count += n; - } - if (summary != null) { - String s = Integer.toString(count); - os.write(s.getBytes()); - } - close(os); - close(is); - } - } - - protected void close(OutputStream os) throws IOException { - os.close(); - } - protected void close(InputStream is) throws IOException { - is.close(); - } + void notfound (HttpExchange t, String p) throws IOException { + t.getResponseHeaders().set ("Content-Type", "text/html"); + t.sendResponseHeaders (404, 0); + OutputStream os = t.getResponseBody(); + String s = "

File not found

"; + s = s + p + "

"; + os.write (s.getBytes()); + os.close(); + t.close(); } +} diff --git a/jdk/test/com/sun/net/httpserver/SimpleFileServer.java b/jdk/test/com/sun/net/httpserver/SimpleFileServer.java new file mode 100644 index 00000000000..0d32f37bda3 --- /dev/null +++ b/jdk/test/com/sun/net/httpserver/SimpleFileServer.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; +import java.util.concurrent.*; +import java.util.logging.*; +import java.io.*; +import java.net.*; +import java.security.*; +import javax.net.ssl.*; +import com.sun.net.httpserver.*; + +/** + * Implements a basic static content HTTP server + * which understands text/html, text/plain content types + * + * Must be given an abs pathname to the document root. + * Directory listings together with text + html files + * can be served. + * + * File Server created on files sub-path + * + * Echo server created on echo sub-path + */ +public class SimpleFileServer { + + public static void main (String[] args) throws Exception { + if (args.length != 3) { + System.out.println ("usage: java FileServerHandler rootDir port logfilename"); + System.exit(1); + } + Logger logger = Logger.getLogger("com.sun.net.httpserver"); + ConsoleHandler ch = new ConsoleHandler(); + logger.setLevel(Level.ALL); + ch.setLevel(Level.ALL); + logger.addHandler(ch); + + String rootDir = args[0]; + int port = Integer.parseInt (args[1]); + String logfile = args[2]; + HttpServer server = HttpServer.create (new InetSocketAddress (port), 0); + HttpHandler h = new FileServerHandler (rootDir); + HttpHandler h1 = new EchoHandler (); + + HttpContext c = server.createContext ("/files", h); + c.getFilters().add (new LogFilter (new File (logfile))); + HttpContext c1 = server.createContext ("/echo", h1); + c.getFilters().add (new LogFilter (new File (logfile))); + c1.getFilters().add (new LogFilter (new File (logfile))); + server.setExecutor (Executors.newCachedThreadPool()); + server.start (); + } +} diff --git a/jdk/test/java/net/httpclient/HttpEchoHandler.java b/jdk/test/java/net/httpclient/HttpEchoHandler.java new file mode 100644 index 00000000000..914d89161ac --- /dev/null +++ b/jdk/test/java/net/httpclient/HttpEchoHandler.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 com.sun.net.httpserver.*; +import java.net.*; +import jdk.incubator.http.*; +import java.io.*; +import java.util.concurrent.*; +import javax.net.ssl.*; +import java.nio.file.*; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import jdk.testlibrary.SimpleSSLContext; +import static jdk.incubator.http.HttpRequest.*; +import static jdk.incubator.http.HttpResponse.*; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class HttpEchoHandler implements HttpHandler { + public HttpEchoHandler() {} + + @Override + public void handle(HttpExchange t) + throws IOException { + try { + System.err.println("EchoHandler received request to " + t.getRequestURI()); + InputStream is = t.getRequestBody(); + Headers map = t.getRequestHeaders(); + Headers map1 = t.getResponseHeaders(); + map1.add("X-Hello", "world"); + map1.add("X-Bye", "universe"); + String fixedrequest = map.getFirst("XFixed"); + File outfile = File.createTempFile("foo", "bar"); + FileOutputStream fos = new FileOutputStream(outfile); + int count = (int) is.transferTo(fos); + is.close(); + fos.close(); + InputStream is1 = new FileInputStream(outfile); + OutputStream os = null; + // return the number of bytes received (no echo) + String summary = map.getFirst("XSummary"); + if (fixedrequest != null && summary == null) { + t.sendResponseHeaders(200, count); + os = t.getResponseBody(); + is1.transferTo(os); + } else { + t.sendResponseHeaders(200, 0); + os = t.getResponseBody(); + is1.transferTo(os); + + if (summary != null) { + String s = Integer.toString(count); + os.write(s.getBytes()); + } + } + outfile.delete(); + os.close(); + is1.close(); + } catch (Throwable e) { + e.printStackTrace(); + throw new IOException(e); + } + } +} diff --git a/jdk/test/java/net/httpclient/LightWeightHttpServer.java b/jdk/test/java/net/httpclient/LightWeightHttpServer.java index a0d6e9ac9c7..d80a382d669 100644 --- a/jdk/test/java/net/httpclient/LightWeightHttpServer.java +++ b/jdk/test/java/net/httpclient/LightWeightHttpServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,9 @@ /** * library /lib/testlibrary/ / - * build jdk.testlibrary.SimpleSSLContext ProxyServer EchoHandler + * build jdk.testlibrary.SimpleSSLContext ProxyServer * compile ../../../com/sun/net/httpserver/LogFilter.java + * compile ../../../com/sun/net/httpserver/EchoHandler.java * compile ../../../com/sun/net/httpserver/FileServerHandler.java */ import com.sun.net.httpserver.Headers; diff --git a/jdk/test/java/net/httpclient/ManyRequests.java b/jdk/test/java/net/httpclient/ManyRequests.java index 7420c7223ed..8803b397528 100644 --- a/jdk/test/java/net/httpclient/ManyRequests.java +++ b/jdk/test/java/net/httpclient/ManyRequests.java @@ -28,8 +28,9 @@ * java.logging * jdk.httpserver * @library /lib/testlibrary/ / - * @build jdk.testlibrary.SimpleSSLContext EchoHandler + * @build jdk.testlibrary.SimpleSSLContext * @compile ../../../com/sun/net/httpserver/LogFilter.java + * @compile ../../../com/sun/net/httpserver/EchoHandler.java * @compile ../../../com/sun/net/httpserver/FileServerHandler.java * @run main/othervm/timeout=40 -Djdk.httpclient.HttpClient.log=ssl ManyRequests * @run main/othervm/timeout=40 -Dtest.insertDelay=true ManyRequests diff --git a/jdk/test/java/net/httpclient/ManyRequests2.java b/jdk/test/java/net/httpclient/ManyRequests2.java index 2ec01de9734..26c281fca61 100644 --- a/jdk/test/java/net/httpclient/ManyRequests2.java +++ b/jdk/test/java/net/httpclient/ManyRequests2.java @@ -28,8 +28,9 @@ * java.logging * jdk.httpserver * @library /lib/testlibrary/ / - * @build jdk.testlibrary.SimpleSSLContext EchoHandler + * @build jdk.testlibrary.SimpleSSLContext * @compile ../../../com/sun/net/httpserver/LogFilter.java + * @compile ../../../com/sun/net/httpserver/EchoHandler.java * @compile ../../../com/sun/net/httpserver/FileServerHandler.java * @build ManyRequests ManyRequests2 * @run main/othervm/timeout=40 -Dtest.XFixed=true ManyRequests2 diff --git a/jdk/test/java/net/httpclient/RequestBodyTest.java b/jdk/test/java/net/httpclient/RequestBodyTest.java index fd0bbcc7aaa..446eb0324f5 100644 --- a/jdk/test/java/net/httpclient/RequestBodyTest.java +++ b/jdk/test/java/net/httpclient/RequestBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ * jdk.httpserver * @library /lib/testlibrary/ * @compile ../../../com/sun/net/httpserver/LogFilter.java + * @compile ../../../com/sun/net/httpserver/EchoHandler.java * @compile ../../../com/sun/net/httpserver/FileServerHandler.java * @build LightWeightHttpServer * @build jdk.testlibrary.SimpleSSLContext diff --git a/jdk/test/java/net/httpclient/SmokeTest.java b/jdk/test/java/net/httpclient/SmokeTest.java index 8d33296c390..a0636cc1df5 100644 --- a/jdk/test/java/net/httpclient/SmokeTest.java +++ b/jdk/test/java/net/httpclient/SmokeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,9 @@ * java.logging * jdk.httpserver * @library /lib/testlibrary/ / - * @build jdk.testlibrary.SimpleSSLContext ProxyServer EchoHandler + * @build jdk.testlibrary.SimpleSSLContext ProxyServer * @compile ../../../com/sun/net/httpserver/LogFilter.java + * @compile ../../../com/sun/net/httpserver/EchoHandler.java * @compile ../../../com/sun/net/httpserver/FileServerHandler.java * @run main/othervm -Djdk.httpclient.HttpClient.log=errors,trace SmokeTest */ diff --git a/jdk/test/java/net/httpclient/http2/BasicTest.java b/jdk/test/java/net/httpclient/http2/BasicTest.java index 615843df973..9744eda9034 100644 --- a/jdk/test/java/net/httpclient/http2/BasicTest.java +++ b/jdk/test/java/net/httpclient/http2/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,11 +62,11 @@ public class BasicTest { sslContext = sslct.get(); client = getClient(); httpServer = new Http2TestServer(false, 0, exec, sslContext); - httpServer.addHandler(new EchoHandler(), "/"); + httpServer.addHandler(new Http2EchoHandler(), "/"); httpPort = httpServer.getAddress().getPort(); httpsServer = new Http2TestServer(true, 0, exec, sslContext); - httpsServer.addHandler(new EchoHandler(), "/"); + httpsServer.addHandler(new Http2EchoHandler(), "/"); httpsPort = httpsServer.getAddress().getPort(); httpURIString = "http://127.0.0.1:" + httpPort + "/foo/"; diff --git a/jdk/test/java/net/httpclient/http2/ErrorTest.java b/jdk/test/java/net/httpclient/http2/ErrorTest.java index a2e115071e6..9a8815df14b 100644 --- a/jdk/test/java/net/httpclient/http2/ErrorTest.java +++ b/jdk/test/java/net/httpclient/http2/ErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ public class ErrorTest { 0, exec, serverContext); - httpsServer.addHandler(new EchoHandler(), "/"); + httpsServer.addHandler(new Http2EchoHandler(), "/"); int httpsPort = httpsServer.getAddress().getPort(); String httpsURIString = "https://127.0.0.1:" + httpsPort + "/bar/"; diff --git a/jdk/test/java/net/httpclient/http2/FixedThreadPoolTest.java b/jdk/test/java/net/httpclient/http2/FixedThreadPoolTest.java index 39676149e3a..d6de84aca6c 100644 --- a/jdk/test/java/net/httpclient/http2/FixedThreadPoolTest.java +++ b/jdk/test/java/net/httpclient/http2/FixedThreadPoolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,11 +62,11 @@ public class FixedThreadPoolTest { sslContext = sslct.get(); client = getClient(); httpServer = new Http2TestServer(false, 0, exec, sslContext); - httpServer.addHandler(new EchoHandler(), "/"); + httpServer.addHandler(new Http2EchoHandler(), "/"); httpPort = httpServer.getAddress().getPort(); httpsServer = new Http2TestServer(true, 0, exec, sslContext); - httpsServer.addHandler(new EchoHandler(), "/"); + httpsServer.addHandler(new Http2EchoHandler(), "/"); httpsPort = httpsServer.getAddress().getPort(); httpURIString = "http://127.0.0.1:" + httpPort + "/foo/"; diff --git a/jdk/test/java/net/httpclient/http2/RedirectTest.java b/jdk/test/java/net/httpclient/http2/RedirectTest.java index 634467e06e1..cf0278585f3 100644 --- a/jdk/test/java/net/httpclient/http2/RedirectTest.java +++ b/jdk/test/java/net/httpclient/http2/RedirectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,7 +79,7 @@ public class RedirectTest { httpServer.addHandler(new RedirectHandler(sup(altURIString1)), "/foo"); altServer.addHandler(new RedirectHandler(sup(altURIString2)), "/redir"); - altServer.addHandler(new EchoHandler(), "/redir/again"); + altServer.addHandler(new Http2EchoHandler(), "/redir/again"); httpServer.start(); altServer.start(); diff --git a/jdk/test/java/net/httpclient/http2/server/Http2EchoHandler.java b/jdk/test/java/net/httpclient/http2/server/Http2EchoHandler.java new file mode 100644 index 00000000000..c1ebebe0d2f --- /dev/null +++ b/jdk/test/java/net/httpclient/http2/server/Http2EchoHandler.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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.*; +import jdk.incubator.http.internal.common.HttpHeadersImpl; + +public class Http2EchoHandler implements Http2Handler { + public Http2EchoHandler() {} + + @Override + public void handle(Http2TestExchange t) + throws IOException { + try { + System.err.println("EchoHandler received request to " + t.getRequestURI()); + InputStream is = t.getRequestBody(); + HttpHeadersImpl map = t.getRequestHeaders(); + HttpHeadersImpl map1 = t.getResponseHeaders(); + map1.addHeader("X-Hello", "world"); + map1.addHeader("X-Bye", "universe"); + String fixedrequest = map.firstValue("XFixed").orElse(null); + File outfile = File.createTempFile("foo", "bar"); + //System.err.println ("QQQ = " + outfile.toString()); + FileOutputStream fos = new FileOutputStream(outfile); + int count = (int) is.transferTo(fos); + System.err.printf("EchoHandler read %d bytes\n", count); + is.close(); + fos.close(); + InputStream is1 = new FileInputStream(outfile); + OutputStream os = null; + // return the number of bytes received (no echo) + String summary = map.firstValue("XSummary").orElse(null); + if (fixedrequest != null && summary == null) { + t.sendResponseHeaders(200, count); + os = t.getResponseBody(); + int count1 = (int)is1.transferTo(os); + System.err.printf("EchoHandler wrote %d bytes\n", count1); + } else { + t.sendResponseHeaders(200, 0); + os = t.getResponseBody(); + int count1 = (int)is1.transferTo(os); + System.err.printf("EchoHandler wrote %d bytes\n", count1); + + if (summary != null) { + String s = Integer.toString(count); + os.write(s.getBytes()); + } + } + outfile.delete(); + os.close(); + is1.close(); + } catch (Throwable e) { + e.printStackTrace(); + throw new IOException(e); + } + } +} From 70eda1ba26e0b330547c5943a6e9e093bf9238f5 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Fri, 9 Jun 2017 11:26:42 -0700 Subject: [PATCH 25/59] 8181824: Broken javadoc link in java.util.BitSet Reviewed-by: martin --- jdk/src/java.base/share/classes/java/util/BitSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/util/BitSet.java b/jdk/src/java.base/share/classes/java/util/BitSet.java index f453965f672..c9dafaed3e8 100644 --- a/jdk/src/java.base/share/classes/java/util/BitSet.java +++ b/jdk/src/java.base/share/classes/java/util/BitSet.java @@ -1212,7 +1212,7 @@ public class BitSet implements Cloneable, java.io.Serializable { * *

The stream binds to this bit set when the terminal stream operation * commences (specifically, the spliterator for the stream is - * late-binding). If the + * late-binding). If the * bit set is modified during that operation then the result is undefined. * * @return a stream of integers representing set indices From 4464690740d4019810a28f3d14214cf37df37390 Mon Sep 17 00:00:00 2001 From: Vyom Tewari Date: Thu, 15 Jun 2017 17:50:21 +0530 Subject: [PATCH 26/59] 8176192: Incorrect usage of Iterator in Java 8 In com.sun.jndi.ldap.EventSupport.removeNamingListener Reviewed-by: psandoz --- .../com/sun/jndi/ldap/EventSupport.java | 28 +- .../jndi/ldap/RemoveNamingListenerTest.java | 241 ++++++++++++++++++ 2 files changed, 258 insertions(+), 11 deletions(-) create mode 100644 jdk/test/com/sun/jndi/ldap/RemoveNamingListenerTest.java diff --git a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java index de78c1f11ab..a13a4da637e 100644 --- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java +++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/EventSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,8 @@ package com.sun.jndi.ldap; import java.util.Hashtable; import java.util.Vector; import java.util.EventObject; +import java.util.Iterator; +import java.util.Map; import javax.naming.*; import javax.naming.event.*; @@ -204,31 +206,35 @@ final class EventSupport { * Removes {@code l} from all notifiers in this context. */ synchronized void removeNamingListener(NamingListener l) { - if (debug) System.err.println("EventSupport removing listener"); - + if (debug) { + System.err.println("EventSupport removing listener"); + } // Go through list of notifiers, remove 'l' from each. // If 'l' is notifier's only listener, remove notifier too. - for (NamingEventNotifier notifier : notifiers.values()) { + Iterator iterator = notifiers.values().iterator(); + while (iterator.hasNext()) { + NamingEventNotifier notifier = iterator.next(); if (notifier != null) { - if (debug) + if (debug) { System.err.println("EventSupport removing listener from notifier"); + } notifier.removeNamingListener(l); if (!notifier.hasNamingListeners()) { - if (debug) + if (debug) { System.err.println("EventSupport stopping notifier"); + } notifier.stop(); - notifiers.remove(notifier.info); + iterator.remove(); } } } - // Remove from list of unsolicited notifier - if (debug) System.err.println("EventSupport removing unsolicited: " + - unsolicited); + if (debug) { + System.err.println("EventSupport removing unsolicited: " + unsolicited); + } if (unsolicited != null) { unsolicited.removeElement(l); } - } synchronized boolean hasUnsolicited() { diff --git a/jdk/test/com/sun/jndi/ldap/RemoveNamingListenerTest.java b/jdk/test/com/sun/jndi/ldap/RemoveNamingListenerTest.java new file mode 100644 index 00000000000..ebdc4c60e2b --- /dev/null +++ b/jdk/test/com/sun/jndi/ldap/RemoveNamingListenerTest.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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.BufferedInputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; +import java.nio.charset.StandardCharsets; +import java.util.ConcurrentModificationException; +import java.util.Hashtable; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.event.EventContext; +import javax.naming.event.NamingEvent; +import javax.naming.event.NamingExceptionEvent; +import javax.naming.event.NamingListener; +import javax.naming.event.ObjectChangeListener; + +/** + * @test + * @bug 8176192 + * @summary Incorrect usage of Iterator in Java 8 In com.sun.jndi.ldap. + * EventSupport.removeNamingListener + * @modules java.naming + * @run main RemoveNamingListenerTest + */ +public class RemoveNamingListenerTest { + + private static volatile Exception exception; + + public static void main(String args[]) throws Exception { + // start the LDAP server + TestLDAPServer server = new TestLDAPServer(); + server.start(); + + // Set up environment for creating initial context + Hashtable env = new Hashtable<>(3); + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + env.put(Context.PROVIDER_URL, "ldap://localhost:" + server.getPort() + "/o=example"); + env.put("com.sun.jndi.ldap.connect.timeout", "2000"); + EventContext ctx = null; + + try { + ctx = (EventContext) (new InitialContext(env).lookup("")); + String target = "cn=Vyom Tewari"; + + // Create listeners + NamingListener oneListener = new SampleListener(); + NamingListener objListener = new SampleListener(); + NamingListener subListener = new SampleListener(); + + // Register listeners using different scopes + ctx.addNamingListener(target, EventContext.ONELEVEL_SCOPE, oneListener); + ctx.addNamingListener(target, EventContext.OBJECT_SCOPE, objListener); + ctx.addNamingListener(target, EventContext.SUBTREE_SCOPE, subListener); + + //remove a listener in different thread + Thread t = new Thread(new RemoveNamingListener(ctx, subListener)); + t.start(); + t.join(); + + if (exception != null) { + throw exception; + } + System.out.println("Test run OK!!!"); + } finally { + if (ctx != null) { + ctx.close(); + } + server.stopServer(); + } + } + + /** + * Helper thread that removes the naming listener. + */ + static class RemoveNamingListener implements Runnable { + + final EventContext ctx; + final NamingListener listener; + + RemoveNamingListener(EventContext ctx, NamingListener listener) { + this.ctx = ctx; + this.listener = listener; + } + + @Override + public void run() { + try { + ctx.removeNamingListener(listener); + } catch (NamingException | ConcurrentModificationException ex) { + exception = ex; + } + } + } + + static class SampleListener implements ObjectChangeListener { + + @Override + public void objectChanged(NamingEvent ne) { + //do nothing + } + + @Override + public void namingExceptionThrown(NamingExceptionEvent nee) { + //do nothing + } + } +} + +class TestLDAPServer extends Thread { + + private final int LDAP_PORT; + private final ServerSocket serverSocket; + private volatile boolean isRunning; + + TestLDAPServer() throws IOException { + serverSocket = new ServerSocket(0); + isRunning = true; + LDAP_PORT = serverSocket.getLocalPort(); + setDaemon(true); + } + + public int getPort() { + return LDAP_PORT; + } + + public void stopServer() { + isRunning = false; + if (serverSocket != null && !serverSocket.isClosed()) { + try { + // this will cause ServerSocket.accept() to throw SocketException. + serverSocket.close(); + } catch (IOException ignored) { + } + } + } + + @Override + public void run() { + try { + while (isRunning) { + Socket clientSocket = serverSocket.accept(); + Thread handler = new Thread(new LDAPServerHandler(clientSocket)); + handler.setDaemon(true); + handler.start(); + } + } catch (IOException iOException) { + //do not throw exception if server is not running. + if (isRunning) { + throw new RuntimeException(iOException); + } + } finally { + stopServer(); + } + } +} + +class LDAPServerHandler implements Runnable { + + private final Socket clientSocket; + + public LDAPServerHandler(final Socket clientSocket) { + this.clientSocket = clientSocket; + } + + @Override + public void run() { + BufferedInputStream in = null; + PrintWriter out = null; + byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00}; + byte[] searchResponse = {0x30, 0x0C, 0x02, 0x01, 0x02, 0x65, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00}; + try { + in = new BufferedInputStream(clientSocket.getInputStream()); + out = new PrintWriter(new OutputStreamWriter( + clientSocket.getOutputStream(), StandardCharsets.UTF_8), true); + while (true) { + + // Read the LDAP BindRequest + while (in.read() != -1) { + in.skip(in.available()); + break; + } + + // Write an LDAP BindResponse + out.write(new String(bindResponse)); + out.flush(); + + // Read the LDAP SearchRequest + while (in.read() != -1) { + in.skip(in.available()); + break; + } + + // Write an LDAP SearchResponse + out.write(new String(searchResponse)); + out.flush(); + } + } catch (IOException iOException) { + throw new RuntimeException(iOException); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + } + } + if (out != null) { + out.close(); + } + if (clientSocket != null) { + try { + clientSocket.close(); + } catch (IOException ignored) { + } + } + } + } +} From ec1c052367e33d3458751137c7006105c3a3458f Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:10 +0000 Subject: [PATCH 27/59] Added tag jdk-9+174 for changeset 78af1824a3ba --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index ac719147800..98bbdae3716 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -416,3 +416,4 @@ b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169 4c12464a907db4656c1033f56fa49cba643ac629 jdk-9+171 2c25fc24103251f9711a1c280c31e1e41016d90f jdk-9+172 88d7fd969e7df0e07a53b201cfd29393ca33ede9 jdk-9+173 +5466f409346e0446ee9a6daeb7f5d75c8fc76823 jdk-9+174 From 39a669e1020e4ffb4eff2929828f077601a131cd Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:10 +0000 Subject: [PATCH 28/59] Added tag jdk-9+174 for changeset f25253621ba1 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 1f76802f679..9deff2db564 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -576,3 +576,4 @@ fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168 d53171650a2cc6c6f699c966c533b914ca9c0602 jdk-9+171 1ae9e84f68b359420d2d153ecfe5ee2903e33a2e jdk-9+172 e64b1cb48d6e7703928a9d1da106fc27f8cb65fd jdk-9+173 +944791f8160185bffa13fbb821fc09b6198f1f25 jdk-9+174 From 076f1cd8e07b0e7ee15611c7266fac16f364e138 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:10 +0000 Subject: [PATCH 29/59] Added tag jdk-9+174 for changeset a1ec0a218e89 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 6db1eeda878..0cb7bc2e8c7 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -416,3 +416,4 @@ b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169 c62e5964cfcf144d8f72e9ba69757897785349a9 jdk-9+171 95ed14547ca9246baed34f90ef3ca13217538a8c jdk-9+172 534ba4f8cfcf12accc5b9adb943103f2ff79fe16 jdk-9+173 +3615768c12904e29bb2ec1b506cd4633cd8a9ced jdk-9+174 From c982899af8ff42a6ed80942135e748b3650c90bd Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:11 +0000 Subject: [PATCH 30/59] Added tag jdk-9+174 for changeset de2f9156e3ad --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 7353c4ba3b0..8b82af23438 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -419,3 +419,4 @@ e75d3abe579a7b39b762fc0a1a337c49eb072d82 jdk-9+170 139e7c786ee4885efe53eb650b72c7b5a2d3b964 jdk-9+171 8c615099f3e3ca137325be34bf566b767d9e3c64 jdk-9+172 2bd967aa452c1e0e87a6173bef6fbb96ef1c521b jdk-9+173 +c2296642010f1b215ac35da89e92c3ce44104e32 jdk-9+174 From 4bc56f38bbc974b7d8aee47b64a399cf65a04295 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:11 +0000 Subject: [PATCH 31/59] Added tag jdk-9+174 for changeset 6a12bfe13efd --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 65daf6b0720..760390f724b 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -416,3 +416,4 @@ d02b6fbcab06c59a5f5a4a6736bd4ec6d2567855 jdk-9+162 c27321c889cf4c8e465a61b84572c00ef7ee6004 jdk-9+171 eedb6e54c8bd6197ecba5fc0d8568bac8ae852dd jdk-9+172 9788347e0629d0cb3a0e55a903494ff741d4fa15 jdk-9+173 +b9c0b105002272d7414c8b34af9aded151f9cad6 jdk-9+174 From 2844bc771c0dcdf3e953678409db0f3389a6dc47 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:12 +0000 Subject: [PATCH 32/59] Added tag jdk-9+174 for changeset 7ebbcd3c853f --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index d973120b189..140c6960e0f 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -416,3 +416,4 @@ ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170 29bbedd4cce8e14742bdb22118c057b877c02f0f jdk-9+171 0ff9ad7d067cd4fa14450cf208bf019175a0aaba jdk-9+172 a5506b425f1bf91530d8417b57360e5d89328c0c jdk-9+173 +42f18c931bd4fae5c206ccf6d8e591e4c4e69d31 jdk-9+174 From 65da19e30a88532ee369cc3eb07a4bf113c59613 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 15 Jun 2017 17:24:14 +0000 Subject: [PATCH 33/59] Added tag jdk-9+174 for changeset 27ec0241c724 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 4e9aaddad61..6ce656d70c1 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -407,3 +407,4 @@ e118c818dbf84d15191414c453b77c089116fdc0 jdk-9+167 fc416270a776409b74006262dd0a9f5f5ff31555 jdk-9+171 c8d6b740f0f7ec834b4157bf0d4523e8bbddb3f0 jdk-9+172 fa8e4de50e821eed876388c84f7129a6739268be jdk-9+173 +7d4006eaa088848c4fa2ac4aef0ba9982f80752a jdk-9+174 From 7be8618771e7594be760e1e45ca4bc1a68d56952 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Thu, 15 Jun 2017 15:00:30 -0700 Subject: [PATCH 34/59] 8182143: SHA224-based signature algorithms are not enabled for TLSv12 on Windows Reviewed-by: xuelei --- .../ssl/SignatureAndHashAlgorithm.java | 18 +++++++----------- .../net/ssl/TLSv12/SignatureAlgorithms.java | 19 ++----------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java index 8445a665da3..b9f11f851bf 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -411,16 +411,12 @@ final class SignatureAndHashAlgorithm { "SHA1withRSA", --p); supports(HashAlgorithm.SHA1, SignatureAlgorithm.ECDSA, "SHA1withECDSA", --p); - - if (Security.getProvider("SunMSCAPI") == null) { - supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA, - "SHA224withDSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA, - "SHA224withRSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA, - "SHA224withECDSA", --p); - } - + supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA, + "SHA224withDSA", --p); + supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA, + "SHA224withRSA", --p); + supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA, + "SHA224withECDSA", --p); supports(HashAlgorithm.SHA256, SignatureAlgorithm.DSA, "SHA256withDSA", --p); supports(HashAlgorithm.SHA256, SignatureAlgorithm.RSA, diff --git a/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java b/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java index 8b51703df41..0533d31135e 100644 --- a/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java +++ b/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ /* * @test - * @bug 8049321 + * @bug 8049321 8182143 * @summary Support SHA256WithDSA in JSSE * @run main/othervm SignatureAlgorithms PKIX "SHA-224,SHA-256" * TLS_DHE_DSS_WITH_AES_128_CBC_SHA @@ -434,21 +434,6 @@ public class SignatureAlgorithms { */ parseArguments(args); - - /* - * Ignore testing on Windows if only SHA-224 is available. - */ - if ((Security.getProvider("SunMSCAPI") != null) && - (disabledAlgorithms.contains("SHA-1")) && - (disabledAlgorithms.contains("SHA-256"))) { - - System.out.println( - "Windows system does not support SHA-224 algorithms yet. " + - "Ignore the testing"); - - return; - } - /* * Expose the target algorithms by diabling unexpected algorithms. */ From d9286d66e8598f0a1effc68792952f4024da1443 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 16 Jun 2017 14:09:31 +0200 Subject: [PATCH 35/59] 8181417: Code cleanups in com.sun.jdi Reviewed-by: alanb, stuefe, sspitsyn --- .../sun/jdi/AbsentInformationException.java | 13 +- .../share/classes/com/sun/jdi/ArrayType.java | 4 +- .../share/classes/com/sun/jdi/Bootstrap.java | 12 +- .../com/sun/jdi/ClassNotLoadedException.java | 7 +- .../sun/jdi/ClassNotPreparedException.java | 10 +- .../share/classes/com/sun/jdi/ClassType.java | 1 + .../jdi/IncompatibleThreadStateException.java | 3 +- .../jdi/InconsistentDebugInfoException.java | 4 +- .../classes/com/sun/jdi/InterfaceType.java | 10 +- .../com/sun/jdi/InternalException.java | 24 ++-- .../sun/jdi/InvalidCodeIndexException.java | 4 +- .../sun/jdi/InvalidLineNumberException.java | 4 +- .../com/sun/jdi/InvalidModuleException.java | 3 +- .../sun/jdi/InvalidStackFrameException.java | 4 +- .../com/sun/jdi/InvalidTypeException.java | 3 +- .../com/sun/jdi/InvocationException.java | 4 +- .../classes/com/sun/jdi/JDIPermission.java | 4 +- .../share/classes/com/sun/jdi/Locatable.java | 3 +- .../share/classes/com/sun/jdi/Location.java | 18 ++- .../share/classes/com/sun/jdi/Mirror.java | 15 +-- .../classes/com/sun/jdi/ModuleReference.java | 24 ++-- .../com/sun/jdi/NativeMethodException.java | 3 +- .../com/sun/jdi/ObjectCollectedException.java | 4 +- .../classes/com/sun/jdi/ObjectReference.java | 30 ++--- .../sun/jdi/PathSearchingVirtualMachine.java | 3 +- .../classes/com/sun/jdi/ReferenceType.java | 22 ++-- .../share/classes/com/sun/jdi/StackFrame.java | 14 ++- .../classes/com/sun/jdi/StringReference.java | 3 +- .../classes/com/sun/jdi/ThreadReference.java | 11 +- .../sun/jdi/VMCannotBeModifiedException.java | 4 +- .../com/sun/jdi/VMDisconnectedException.java | 4 +- .../com/sun/jdi/VMMismatchException.java | 4 +- .../com/sun/jdi/VMOutOfMemoryException.java | 4 +- .../share/classes/com/sun/jdi/Value.java | 9 +- .../classes/com/sun/jdi/VirtualMachine.java | 76 ++++++----- .../com/sun/jdi/VirtualMachineManager.java | 119 +++++++++--------- .../sun/jdi/connect/AttachingConnector.java | 8 +- .../com/sun/jdi/connect/Connector.java | 12 +- .../IllegalConnectorArgumentsException.java | 7 +- .../sun/jdi/connect/LaunchingConnector.java | 13 +- .../sun/jdi/connect/ListeningConnector.java | 8 +- .../com/sun/jdi/connect/Transport.java | 18 +-- .../connect/TransportTimeoutException.java | 24 ++-- .../com/sun/jdi/connect/VMStartException.java | 6 +- .../spi/ClosedConnectionException.java | 5 +- .../com/sun/jdi/connect/spi/Connection.java | 18 ++- .../sun/jdi/connect/spi/TransportService.java | 12 +- .../sun/jdi/event/AccessWatchpointEvent.java | 4 +- .../com/sun/jdi/event/BreakpointEvent.java | 22 ++-- .../com/sun/jdi/event/ClassPrepareEvent.java | 12 +- .../com/sun/jdi/event/ClassUnloadEvent.java | 5 +- .../classes/com/sun/jdi/event/Event.java | 5 +- .../com/sun/jdi/event/EventIterator.java | 4 +- .../classes/com/sun/jdi/event/EventQueue.java | 39 +++--- .../classes/com/sun/jdi/event/EventSet.java | 39 +++--- .../com/sun/jdi/event/ExceptionEvent.java | 8 +- .../com/sun/jdi/event/LocatableEvent.java | 8 +- .../com/sun/jdi/event/MethodEntryEvent.java | 4 +- .../com/sun/jdi/event/MethodExitEvent.java | 8 +- .../event/ModificationWatchpointEvent.java | 8 +- .../jdi/event/MonitorContendedEnterEvent.java | 7 +- .../event/MonitorContendedEnteredEvent.java | 8 +- .../com/sun/jdi/event/MonitorWaitEvent.java | 9 +- .../com/sun/jdi/event/MonitorWaitedEvent.java | 11 +- .../classes/com/sun/jdi/event/StepEvent.java | 16 ++- .../com/sun/jdi/event/ThreadDeathEvent.java | 6 +- .../com/sun/jdi/event/ThreadStartEvent.java | 6 +- .../com/sun/jdi/event/VMDeathEvent.java | 36 +++--- .../com/sun/jdi/event/VMDisconnectEvent.java | 12 +- .../com/sun/jdi/event/VMStartEvent.java | 6 +- .../com/sun/jdi/event/WatchpointEvent.java | 8 +- .../jdi/request/AccessWatchpointRequest.java | 17 +-- .../sun/jdi/request/BreakpointRequest.java | 21 ++-- .../sun/jdi/request/ClassPrepareRequest.java | 18 +-- .../sun/jdi/request/ClassUnloadRequest.java | 16 +-- .../request/DuplicateRequestException.java | 3 +- .../com/sun/jdi/request/EventRequest.java | 32 +++-- .../sun/jdi/request/EventRequestManager.java | 43 ++++--- .../com/sun/jdi/request/ExceptionRequest.java | 24 ++-- .../request/InvalidRequestStateException.java | 10 +- .../sun/jdi/request/MethodEntryRequest.java | 21 ++-- .../sun/jdi/request/MethodExitRequest.java | 21 ++-- .../ModificationWatchpointRequest.java | 23 ++-- .../request/MonitorContendedEnterRequest.java | 21 ++-- .../MonitorContendedEnteredRequest.java | 21 ++-- .../sun/jdi/request/MonitorWaitRequest.java | 21 ++-- .../sun/jdi/request/MonitorWaitedRequest.java | 21 ++-- .../com/sun/jdi/request/StepRequest.java | 20 +-- .../sun/jdi/request/ThreadDeathRequest.java | 17 +-- .../sun/jdi/request/ThreadStartRequest.java | 17 +-- .../com/sun/jdi/request/VMDeathRequest.java | 18 +-- .../sun/jdi/request/WatchpointRequest.java | 11 +- 92 files changed, 739 insertions(+), 583 deletions(-) diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/AbsentInformationException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/AbsentInformationException.java index 6a2188ee191..4a68bbf459b 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/AbsentInformationException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/AbsentInformationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,16 +31,15 @@ package com.sun.jdi; * @author Gordon Hirsch * @since 1.3 */ -public class AbsentInformationException extends Exception -{ +public class AbsentInformationException extends Exception { + private static final long serialVersionUID = 4988939309582416373L; - public AbsentInformationException() - { + + public AbsentInformationException() { super(); } - public AbsentInformationException(String s) - { + public AbsentInformationException(String s) { super(s); } } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ArrayType.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ArrayType.java index d693c0e6195..7cdfb6f73ce 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ArrayType.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ArrayType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ package com.sun.jdi; -import java.util.List; - /** * Provides access to the class of an array and the type of * its components in the target VM. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Bootstrap.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Bootstrap.java index 2e639148d1e..7f72580c761 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Bootstrap.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Bootstrap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ package com.sun.jdi; +import com.sun.jdi.connect.Connector; +import com.sun.tools.jdi.VirtualMachineManagerImpl; + /** * Initial class that provides access to the default implementation * of JDI interfaces. A debugger application uses this class to access the @@ -40,9 +43,8 @@ public class Bootstrap extends Object { * Returns the virtual machine manager. * *

May throw an unspecified error if initialization of the - * {@link com.sun.jdi.VirtualMachineManager} fails or if - * the virtual machine manager is unable to locate or create - * any {@link com.sun.jdi.connect.Connector Connectors}. + * {@link VirtualMachineManager} fails or if the virtual machine manager + * is unable to locate or create any {@link Connector Connectors}. * * @throws java.lang.SecurityException if a security manager has been * installed and it denies {@link JDIPermission} @@ -50,6 +52,6 @@ public class Bootstrap extends Object { * permissions required by the implementation. */ static public synchronized VirtualMachineManager virtualMachineManager() { - return com.sun.tools.jdi.VirtualMachineManagerImpl.virtualMachineManager(); + return VirtualMachineManagerImpl.virtualMachineManager(); } } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotLoadedException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotLoadedException.java index 790f8d0d1b8..75bf2b6d0fe 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotLoadedException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotLoadedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,9 +67,10 @@ package com.sun.jdi; * @author Gordon Hirsch * @since 1.3 */ -public class ClassNotLoadedException extends Exception -{ +public class ClassNotLoadedException extends Exception { + private static final long serialVersionUID = -6242978768444298722L; + private String className; public ClassNotLoadedException(String className) { diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotPreparedException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotPreparedException.java index f30e87f2474..d40804d151b 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotPreparedException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassNotPreparedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,14 +33,14 @@ package com.sun.jdi; * @since 1.3 */ public class ClassNotPreparedException extends RuntimeException { + private static final long serialVersionUID = -6120698967144079642L; - public ClassNotPreparedException() - { + + public ClassNotPreparedException() { super(); } - public ClassNotPreparedException(String s) - { + public ClassNotPreparedException(String s) { super(s); } } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java index 65ef602c959..e080e235c83 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java @@ -42,6 +42,7 @@ import java.util.List; * @since 1.3 */ public interface ClassType extends ReferenceType { + /** * Gets the superclass of this class. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/IncompatibleThreadStateException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/IncompatibleThreadStateException.java index 1fd8e713d52..ef90c4834e9 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/IncompatibleThreadStateException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/IncompatibleThreadStateException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class IncompatibleThreadStateException extends Exception { + private static final long serialVersionUID = 6199174323414551389L; public IncompatibleThreadStateException() { diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InconsistentDebugInfoException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InconsistentDebugInfoException.java index 305efa06e09..45904e20a99 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InconsistentDebugInfoException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InconsistentDebugInfoException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,9 @@ package com.sun.jdi; * @since 1.3 */ public class InconsistentDebugInfoException extends RuntimeException { + private static final long serialVersionUID = 7964236415376861808L; + public InconsistentDebugInfoException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java index 8ff159f7ba1..e4d174ee25e 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java @@ -44,6 +44,7 @@ import java.util.List; * @since 1.3 */ public interface InterfaceType extends ReferenceType { + /** * Gets the interfaces directly extended by this interface. * The returned list contains only those interfaces this @@ -187,11 +188,12 @@ public interface InterfaceType extends ReferenceType { * @since 1.8 */ default Value invokeMethod(ThreadReference thread, Method method, - List arguments, int options) + List arguments, int options) throws InvalidTypeException, - ClassNotLoadedException, - IncompatibleThreadStateException, - InvocationException { + ClassNotLoadedException, + IncompatibleThreadStateException, + InvocationException + { throw new UnsupportedOperationException(); } } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InternalException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InternalException.java index a291ac196e5..ab7373b3574 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InternalException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InternalException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,18 +33,20 @@ package com.sun.jdi; * @since 1.3 */ public class InternalException extends RuntimeException { - private static final long serialVersionUID = -9171606393104480607L; - private int errorCode; - public InternalException() { - super(); - this.errorCode = 0; - } + private static final long serialVersionUID = -9171606393104480607L; - public InternalException(String s) { - super(s); - this.errorCode = 0; - } + private int errorCode; + + public InternalException() { + super(); + this.errorCode = 0; + } + + public InternalException(String s) { + super(s); + this.errorCode = 0; + } public InternalException(int errorCode) { super(); diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidCodeIndexException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidCodeIndexException.java index 3e62cf8df84..8eed0556689 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidCodeIndexException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidCodeIndexException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,9 @@ package com.sun.jdi; */ @Deprecated public class InvalidCodeIndexException extends RuntimeException { + private static final long serialVersionUID = 7416010225133747805L; + public InvalidCodeIndexException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidLineNumberException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidLineNumberException.java index bc40ea6e8b8..80e82866e15 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidLineNumberException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidLineNumberException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,9 @@ package com.sun.jdi; */ @Deprecated public class InvalidLineNumberException extends RuntimeException { + private static final long serialVersionUID = 4048709912372692875L; + public InvalidLineNumberException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidModuleException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidModuleException.java index ee49b7f623c..5351594c952 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidModuleException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidModuleException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 9 */ public class InvalidModuleException extends RuntimeException { + private static final long serialVersionUID = 7907359387320658039L; /** diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidStackFrameException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidStackFrameException.java index e57bfa53454..0d8f8010fc7 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidStackFrameException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidStackFrameException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,9 @@ package com.sun.jdi; * @since 1.3 */ public class InvalidStackFrameException extends RuntimeException { + private static final long serialVersionUID = -1919378296505827922L; + public InvalidStackFrameException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidTypeException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidTypeException.java index 904248ccb03..fa60a3a8b9d 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidTypeException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvalidTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class InvalidTypeException extends Exception { + private static final long serialVersionUID = 2256667231949650806L; public InvalidTypeException() { diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvocationException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvocationException.java index 4e66f601b96..c38f488007b 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvocationException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InvocationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,9 @@ package com.sun.jdi; * @since 1.3 */ public class InvocationException extends Exception { + private static final long serialVersionUID = 6066780907971918568L; + ObjectReference exception; public InvocationException(ObjectReference exception) { diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java index a54ba2388d4..8f9b4da9980 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java @@ -70,7 +70,7 @@ package com.sun.jdi; * @author Tim Bell * @since 1.5 * - * @see com.sun.jdi.Bootstrap + * @see Bootstrap * @see java.security.BasicPermission * @see java.security.Permission * @see java.security.Permissions @@ -80,7 +80,9 @@ package com.sun.jdi; */ public final class JDIPermission extends java.security.BasicPermission { + private static final long serialVersionUID = -6988461416938786271L; + /** * The {@code JDIPermission} class represents access rights to the * {@code VirtualMachineManager} diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Locatable.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Locatable.java index 16db7bff8ce..f8c63ad925e 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Locatable.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Locatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ package com.sun.jdi; * @since 1.3 */ public interface Locatable { + /** * Returns the {@link Location} of this mirror, if there is * executable code associated with it. Note that both Java™ diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Location.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Location.java index 42ea4ca5e23..c645db078b4 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Location.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Location.java @@ -25,7 +25,9 @@ package com.sun.jdi; -import java.util.List; +import com.sun.jdi.event.BreakpointEvent; +import com.sun.jdi.event.ExceptionEvent; +import com.sun.jdi.request.EventRequestManager; /** * A point within the executing code of the target VM. @@ -75,10 +77,10 @@ import java.util.List; * returned as the default. To determine the available strata * use {@link ReferenceType#availableStrata()}. * - * @see com.sun.jdi.request.EventRequestManager + * @see EventRequestManager * @see StackFrame - * @see com.sun.jdi.event.BreakpointEvent - * @see com.sun.jdi.event.ExceptionEvent + * @see BreakpointEvent + * @see ExceptionEvent * @see Locatable * * @author Robert Field @@ -128,7 +130,6 @@ public interface Location extends Mirror, Comparable { */ String sourceName() throws AbsentInformationException; - /** * Gets an identifing name for the source corresponding to * this location. Interpretation of this string is the @@ -154,8 +155,7 @@ public interface Location extends Mirror, Comparable { * * @since 1.4 */ - String sourceName(String stratum) - throws AbsentInformationException; + String sourceName(String stratum) throws AbsentInformationException; /** * Gets the path to the source corresponding to this @@ -173,7 +173,6 @@ public interface Location extends Mirror, Comparable { */ String sourcePath() throws AbsentInformationException; - /** * Gets the path to the source corresponding to this * location. Interpretation of this string is the @@ -206,8 +205,7 @@ public interface Location extends Mirror, Comparable { * * @since 1.4 */ - String sourcePath(String stratum) - throws AbsentInformationException; + String sourcePath(String stratum) throws AbsentInformationException; /** * Gets the line number of this Location. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Mirror.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Mirror.java index e9f88871409..af23846beb0 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Mirror.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Mirror.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.jdi; +import com.sun.jdi.request.BreakpointRequest; + /** * A proxy used by a debugger to examine or manipulate some entity * in another virtual machine. Mirror is the root of the @@ -33,10 +35,9 @@ package com.sun.jdi; * (for example, {@link IntegerValue}), types (for example, * {@link ReferenceType}), dynamic application state (for example, * {@link StackFrame}), and even debugger-specific constructs (for example, - * {@link com.sun.jdi.request.BreakpointRequest}). - * The {@link VirtualMachine} itself is also - * considered a mirror, representing the composite state of the - * target VM. + * {@link BreakpointRequest}). + * The {@link VirtualMachine} itself is also considered a mirror, + * representing the composite state of the target VM. *

* There is no guarantee that a particular entity in the target VM will map * to a single instance of Mirror. Implementors are free to decide @@ -44,9 +45,9 @@ package com.sun.jdi; * of this interface should always use equals to compare * two mirrors for equality. *

- * Any method on a {@link com.sun.jdi.Mirror} that takes a Mirror as an + * Any method on a {@link Mirror} that takes a Mirror as an * parameter directly or indirectly (e.g., as a element in a List) will - * throw {@link com.sun.jdi.VMMismatchException} if the mirrors are from different + * throw {@link VMMismatchException} if the mirrors are from different * virtual machines. * * @see VirtualMachine diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ModuleReference.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ModuleReference.java index 88c5129f4b9..843cce85b5c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ModuleReference.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ModuleReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,24 +25,24 @@ package com.sun.jdi; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.VMDisconnectEvent; /** * A module in the target VM. *

- * Any method on {@code ModuleReference} which directly or - * indirectly takes {@code ModuleReference} as a parameter may throw - * {@link com.sun.jdi.VMDisconnectedException} if the target VM is - * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is - * available to be read from the {@link com.sun.jdi.event.EventQueue}. + * Any method on {@code ModuleReference} which directly or indirectly takes + * {@code ModuleReference} as a parameter may throw {@link VMDisconnectedException} + * if the target VM is disconnected and the {@link VMDisconnectEvent} has been or is + * available to be read from the {@link EventQueue}. *

- * Any method on {@code ModuleReference} which directly or - * indirectly takes {@code ModuleReference} as a parameter may throw - * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory. + * Any method on {@code ModuleReference} which directly or indirectly takes + * {@code ModuleReference} as a parameter may throw {@link VMOutOfMemoryException} + * if the target VM has run out of memory. *

* Any method on {@code ModuleReference} or which directly or indirectly takes - * {@code ModuleReference} as a parameter may throw - * {@link com.sun.jdi.InvalidModuleException} if the mirrored module - * has been unloaded. + * {@code ModuleReference} as a parameter may throw {@link InvalidModuleException} + * if the mirrored module has been unloaded. * * Not all target virtual machines support this class. * Use {@link VirtualMachine#canGetModuleInfo()} diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/NativeMethodException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/NativeMethodException.java index 2708c20deea..eda4d5ab454 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/NativeMethodException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/NativeMethodException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ package com.sun.jdi; public class NativeMethodException extends RuntimeException { private static final long serialVersionUID = 3924951669039469992L; + public NativeMethodException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectCollectedException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectCollectedException.java index b088064e97c..db68d7a465d 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectCollectedException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectCollectedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,9 @@ package com.sun.jdi; * @since 1.3 */ public class ObjectCollectedException extends RuntimeException { + private static final long serialVersionUID = -1928428056197269588L; + public ObjectCollectedException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java index fdef1eae4d7..c37d1b1f6df 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java @@ -28,26 +28,29 @@ package com.sun.jdi; import java.util.List; import java.util.Map; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.VMDisconnectEvent; + /** * An object that currently exists in the target VM. An ObjectReference * mirrors only the object itself and is not specific to any * {@link Field} or {@link LocalVariable} to which it is currently - * assigned. An ObjectReference can - * have 0 or more references from field(s) and/or variable(s). + * assigned. An ObjectReference can have 0 or more references from + * field(s) and/or variable(s). *

- * Any method on ObjectReference which directly or - * indirectly takes ObjectReference as an parameter may throw - * {@link com.sun.jdi.VMDisconnectedException} if the target VM is - * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is - * available to be read from the {@link com.sun.jdi.event.EventQueue}. + * Any method on ObjectReference which directly or indirectly + * takes ObjectReference as a parameter may throw + * {@link VMDisconnectedException} if the target VM is disconnected and the + * {@link VMDisconnectEvent} has been or is available to be read from the + * {@link EventQueue}. *

- * Any method on ObjectReference which directly or - * indirectly takes ObjectReference as an parameter may throw - * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory. + * Any method on ObjectReference which directly or indirectly + * takes ObjectReference as a parameter may throw + * {@link VMOutOfMemoryException} if the target VM has run out of memory. *

- * Any method on ObjectReference or which directly or indirectly takes - * ObjectReference as parameter may throw - * {@link com.sun.jdi.ObjectCollectedException} if the mirrored object has been + * Any method on ObjectReference or which directly or indirectly + * takes ObjectReference as parameter may throw + * {@link ObjectCollectedException} if the mirrored object has been * garbage collected. * * @author Robert Field @@ -422,7 +425,6 @@ public interface ObjectReference extends Value { */ List referringObjects(long maxReferrers); - /** * Compares the specified Object with this ObjectReference for equality. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java index adc6b76cc05..1aa39089cde 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/PathSearchingVirtualMachine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import java.util.List; * @since 1.3 */ public interface PathSearchingVirtualMachine extends VirtualMachine { + /** * Get the class path for this virtual machine. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ReferenceType.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ReferenceType.java index 442b283f455..9ec03162295 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ReferenceType.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ReferenceType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,9 @@ package com.sun.jdi; import java.util.List; import java.util.Map; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.VMDisconnectEvent; + /** * The type of an object in a target VM. ReferenceType encompasses * classes, interfaces, and array types as defined in @@ -55,17 +58,17 @@ import java.util.Map; *

* Any method on ReferenceType which directly or * indirectly takes ReferenceType as an parameter may throw - * {@link com.sun.jdi.VMDisconnectedException} if the target VM is - * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is - * available to be read from the {@link com.sun.jdi.event.EventQueue}. + * {@link VMDisconnectedException} if the target VM is + * disconnected and the {@link VMDisconnectEvent} has been or is + * available to be read from the {@link EventQueue}. *

* Any method on ReferenceType which directly or * indirectly takes ReferenceType as an parameter may throw - * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory. + * {@link VMOutOfMemoryException} if the target VM has run out of memory. *

* Any method on ReferenceType or which directly or indirectly takes * ReferenceType as parameter may throw - * {@link com.sun.jdi.ObjectCollectedException} if the mirrored type has been unloaded. + * {@link ObjectCollectedException} if the mirrored type has been unloaded. * * @see ObjectReference * @see ObjectReference#referenceType @@ -80,7 +83,6 @@ import java.util.Map; public interface ReferenceType extends Type, Comparable, Accessible { - /** * Gets the fully qualified name of this type. The returned name * is formatted as it might appear in a Java programming langauge @@ -615,7 +617,7 @@ public interface ReferenceType * @since 1.4 */ List allLineLocations(String stratum, String sourceName) - throws AbsentInformationException; + throws AbsentInformationException; /** * Returns a List containing all {@link Location} objects @@ -685,7 +687,7 @@ public interface ReferenceType List locationsOfLine(String stratum, String sourceName, int lineNumber) - throws AbsentInformationException; + throws AbsentInformationException; /** * Return the available strata for this reference type. @@ -777,7 +779,6 @@ public interface ReferenceType */ int majorVersion(); - /** * Returns the class minor version number, as defined in the class file format * of the Java Virtual Machine Specification. @@ -850,5 +851,4 @@ public interface ReferenceType * @since 1.6 */ byte[] constantPool(); - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StackFrame.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StackFrame.java index 7b330c76622..5a2e0cf6b79 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StackFrame.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StackFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,9 @@ package com.sun.jdi; import java.util.List; import java.util.Map; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.VMDisconnectEvent; + /** * The state of one method invocation on a thread's call stack. * As a thread executes, stack frames are pushed and popped from @@ -45,13 +48,13 @@ import java.util.Map; *

* Any method on StackFrame which * takes StackFrame as an parameter may throw - * {@link com.sun.jdi.VMDisconnectedException} if the target VM is - * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is - * available to be read from the {@link com.sun.jdi.event.EventQueue}. + * {@link VMDisconnectedException} if the target VM is + * disconnected and the {@link VMDisconnectEvent} has been or is + * available to be read from the {@link EventQueue}. *

* Any method on StackFrame which * takes StackFrame as an parameter may throw - * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory. + * {@link VMOutOfMemoryException} if the target VM has run out of memory. * * @author Robert Field * @author Gordon Hirsch @@ -235,5 +238,4 @@ public interface StackFrame extends Mirror, Locatable { * @since 1.6 */ List getArgumentValues(); - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StringReference.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StringReference.java index 8a1053a27a1..1179e210a35 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StringReference.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/StringReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ package com.sun.jdi; * @since 1.3 */ public interface StringReference extends ObjectReference { + /** * Returns the StringReference as a String. The returned string * is the equivalent of the mirrored string, but is an entity in the diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ThreadReference.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ThreadReference.java index ab537ee3f38..ee5a1ef2a4c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ThreadReference.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ThreadReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,8 +24,11 @@ */ package com.sun.jdi; + import java.util.List; +import com.sun.jdi.event.EventSet; + /** * A thread object from the target VM. * A ThreadReference is an {@link ObjectReference} with additional @@ -37,6 +40,7 @@ import java.util.List; * @since 1.3 */ public interface ThreadReference extends ObjectReference { + /** Thread status is unknown */ public final int THREAD_STATUS_UNKNOWN =-1; /** Thread has completed execution */ @@ -82,6 +86,7 @@ public interface ThreadReference extends ObjectReference { * through {@link java.lang.Thread#resume}. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ + @SuppressWarnings("javadoc") void suspend(); /** @@ -92,7 +97,7 @@ public interface ThreadReference extends ObjectReference { * suspends on this thread is decremented. If it is decremented to 0, * the thread will continue to execute. * Note: the normal way to resume from an event related suspension is - * via {@link com.sun.jdi.event.EventSet#resume}. + * via {@link EventSet#resume}. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ void resume(); @@ -115,6 +120,7 @@ public interface ThreadReference extends ObjectReference { * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. * @see java.lang.Thread#stop(Throwable) */ + @SuppressWarnings("javadoc") void stop(ObjectReference throwable) throws InvalidTypeException; /** @@ -390,7 +396,6 @@ public interface ThreadReference extends ObjectReference { * @since 1.4 */ void popFrames(StackFrame frame) throws IncompatibleThreadStateException; - /** * Force a method to return before it reaches a return * statement. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMCannotBeModifiedException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMCannotBeModifiedException.java index 0366425f66e..a279439d913 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMCannotBeModifiedException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMCannotBeModifiedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,9 @@ package com.sun.jdi; * @since 1.5 */ public class VMCannotBeModifiedException extends UnsupportedOperationException { + private static final long serialVersionUID = -4063879815130164009L; + public VMCannotBeModifiedException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMDisconnectedException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMDisconnectedException.java index f6805f01c8a..e2866bde517 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMDisconnectedException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMDisconnectedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,9 +36,11 @@ package com.sun.jdi; public class VMDisconnectedException extends RuntimeException { private static final long serialVersionUID = 2892975269768351637L; + public VMDisconnectedException() { super(); } + public VMDisconnectedException(String message) { super(message); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMMismatchException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMMismatchException.java index ff0c3db5213..7d1be5f9e91 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMMismatchException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMMismatchException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,9 @@ package com.sun.jdi; * @since 1.3 */ public class VMMismatchException extends RuntimeException { + private static final long serialVersionUID = 289169358790459564L; + public VMMismatchException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMOutOfMemoryException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMOutOfMemoryException.java index 2834d3403c3..4028fc425d7 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMOutOfMemoryException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VMOutOfMemoryException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,9 @@ package com.sun.jdi; * @since 1.3 */ public class VMOutOfMemoryException extends RuntimeException { + private static final long serialVersionUID = 71504228548910686L; + public VMOutOfMemoryException() { super(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Value.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Value.java index b54c7b796c9..99568fe60bc 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Value.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Value.java @@ -25,6 +25,8 @@ package com.sun.jdi; +import com.sun.jdi.event.ModificationWatchpointEvent; + /** * The mirror for a value in the target VM. * This interface is the root of a @@ -33,11 +35,11 @@ package com.sun.jdi; * Some examples of where values may be accessed: *

* - * - * @@ -45,7 +47,7 @@ package com.sun.jdi; * VirtualMachine.mirrorOf(double)} * - *
layout
{@link ObjectReference#getValue(com.sun.jdi.Field) + * {@link ObjectReference#getValue(Field) * ObjectReference.getValue(Field)} * - value of a field *
{@link StackFrame#getValue(com.sun.jdi.LocalVariable) + * {@link StackFrame#getValue(LocalVariable) * StackFrame.getValue(LocalVariable)} * - value of a variable *
- created in the target VM by the JDI client *
{@link com.sun.jdi.event.ModificationWatchpointEvent#valueToBe() + * {@link ModificationWatchpointEvent#valueToBe() * ModificationWatchpointEvent.valueToBe()} * - returned with an event *
@@ -170,6 +172,7 @@ package com.sun.jdi; */ public interface Value extends Mirror { + /** * Returns the run-time type of this value. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachine.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachine.java index dcfd20cdb61..5e83ed7d0b8 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachine.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,26 @@ package com.sun.jdi; -import com.sun.jdi.event.EventQueue; -import com.sun.jdi.ModuleReference; -import com.sun.jdi.request.EventRequestManager; - import java.util.List; import java.util.Map; +import com.sun.jdi.connect.AttachingConnector; +import com.sun.jdi.connect.Connector; +import com.sun.jdi.connect.LaunchingConnector; +import com.sun.jdi.connect.spi.Connection; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.MethodExitEvent; +import com.sun.jdi.event.VMDisconnectEvent; +import com.sun.jdi.event.VMStartEvent; +import com.sun.jdi.request.BreakpointRequest; +import com.sun.jdi.request.ClassPrepareRequest; +import com.sun.jdi.request.EventRequestManager; +import com.sun.jdi.request.MonitorContendedEnterRequest; +import com.sun.jdi.request.MonitorContendedEnteredRequest; +import com.sun.jdi.request.MonitorWaitRequest; +import com.sun.jdi.request.MonitorWaitedRequest; +import com.sun.jdi.request.VMDeathRequest; + /** * A virtual machine targeted for debugging. * More precisely, a {@link Mirror mirror} representing the @@ -44,27 +57,27 @@ import java.util.Map; * are supported directly by this interface. *

* Instances of this interface are created by instances of - * {@link com.sun.jdi.connect.Connector}. For example, - * an {@link com.sun.jdi.connect.AttachingConnector AttachingConnector} + * {@link Connector}. For example, + * an {@link AttachingConnector AttachingConnector} * attaches to a target VM and returns its virtual machine mirror. * A Connector will typically create a VirtualMachine by invoking * the VirtualMachineManager's {@link - * com.sun.jdi.VirtualMachineManager#createVirtualMachine(Connection)} + * VirtualMachineManager#createVirtualMachine(Connection)} * createVirtualMachine(Connection) method. *

* Note that a target VM launched by a launching connector is not - * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been + * guaranteed to be stable until after the {@link VMStartEvent} has been * received. *

* Any method on VirtualMachine which * takes VirtualMachine as an parameter may throw - * {@link com.sun.jdi.VMDisconnectedException} if the target VM is - * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is - * available to be read from the {@link com.sun.jdi.event.EventQueue}. + * {@link VMDisconnectedException} if the target VM is + * disconnected and the {@link VMDisconnectEvent} has been or is + * available to be read from the {@link EventQueue}. *

* Any method on VirtualMachine which * takes VirtualMachine as an parameter may throw - * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory. + * {@link VMOutOfMemoryException} if the target VM has run out of memory. * * @author Robert Field * @author Gordon Hirsch @@ -431,12 +444,10 @@ public interface VirtualMachine extends Mirror { /** * Returns the {@link java.lang.Process} object for this - * virtual machine if launched - * by a {@link com.sun.jdi.connect.LaunchingConnector} + * virtual machine if launched by a {@link LaunchingConnector} * * @return the {@link java.lang.Process} object for this virtual - * machine, or null if it was not launched by a - * {@link com.sun.jdi.connect.LaunchingConnector}. + * machine, or null if it was not launched by a {@link LaunchingConnector}. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only * -see {@link VirtualMachine#canBeModified()}. */ @@ -552,7 +563,7 @@ public interface VirtualMachine extends Mirror { /** * Determines if the target VM supports filtering * events by specific instance object. For example, - * see {@link com.sun.jdi.request.BreakpointRequest#addInstanceFilter}. + * see {@link BreakpointRequest#addInstanceFilter}. * * @return true if the feature is supported, * false otherwise. @@ -621,8 +632,8 @@ public interface VirtualMachine extends Mirror { /** * Determines if the target VM supports the creation of - * {@link com.sun.jdi.request.VMDeathRequest}s. - * @see com.sun.jdi.request.EventRequestManager#createVMDeathRequest + * {@link VMDeathRequest}s. + * @see EventRequestManager#createVMDeathRequest * * @return true if the feature is supported, * false otherwise. @@ -634,8 +645,8 @@ public interface VirtualMachine extends Mirror { /** * Determines if the target VM supports the inclusion of return values * in - * {@link com.sun.jdi.event.MethodExitEvent}s. - * @see com.sun.jdi.request.EventRequestManager#createMethodExitRequest + * {@link MethodExitEvent}s. + * @see EventRequestManager#createMethodExitRequest * * @return true if the feature is supported, * false otherwise. @@ -659,12 +670,11 @@ public interface VirtualMachine extends Mirror { */ boolean canGetInstanceInfo(); - /** * Determines if the target VM supports the filtering of * class prepare events by source name. * - * see {@link com.sun.jdi.request.ClassPrepareRequest#addSourceNameFilter}. + * see {@link ClassPrepareRequest#addSourceNameFilter}. * @return true if the feature is supported, * false otherwise. * @@ -700,14 +710,14 @@ public interface VirtualMachine extends Mirror { /** * Determines if the target VM supports the creation of - * {@link com.sun.jdi.request.MonitorContendedEnterRequest}s. - * {@link com.sun.jdi.request.MonitorContendedEnteredRequest}s. - * {@link com.sun.jdi.request.MonitorWaitRequest}s. - * {@link com.sun.jdi.request.MonitorWaitedRequest}s. - * @see com.sun.jdi.request.EventRequestManager#createMonitorContendedEnterRequest - * @see com.sun.jdi.request.EventRequestManager#createMonitorContendedEnteredRequest - * @see com.sun.jdi.request.EventRequestManager#createMonitorWaitRequest - * @see com.sun.jdi.request.EventRequestManager#createMonitorWaitedRequest + * {@link MonitorContendedEnterRequest}s. + * {@link MonitorContendedEnteredRequest}s. + * {@link MonitorWaitRequest}s. + * {@link MonitorWaitedRequest}s. + * @see EventRequestManager#createMonitorContendedEnterRequest + * @see EventRequestManager#createMonitorContendedEnteredRequest + * @see EventRequestManager#createMonitorWaitRequest + * @see EventRequestManager#createMonitorWaitedRequest * * @return true if the feature is supported, * false otherwise. @@ -720,7 +730,7 @@ public interface VirtualMachine extends Mirror { /** * Determines if the target VM supports getting which * frame has acquired a monitor. - * @see com.sun.jdi.ThreadReference#ownedMonitorsAndFrames + * @see ThreadReference#ownedMonitorsAndFrames * * @return true if the feature is supported, * false otherwise. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java index d8f6e0bf011..ae3c5ffd016 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java @@ -25,10 +25,18 @@ package com.sun.jdi; -import com.sun.jdi.connect.*; -import com.sun.jdi.connect.spi.Connection; -import java.util.List; import java.io.IOException; +import java.util.List; + +import com.sun.jdi.connect.AttachingConnector; +import com.sun.jdi.connect.Connector; +import com.sun.jdi.connect.LaunchingConnector; +import com.sun.jdi.connect.ListeningConnector; +import com.sun.jdi.connect.Transport; +import com.sun.jdi.connect.spi.Connection; +import com.sun.jdi.connect.spi.TransportService; +import com.sun.jdi.event.VMDisconnectEvent; +import com.sun.jdi.event.VMStartEvent; /** * A manager of connections to target virtual machines. The @@ -41,14 +49,14 @@ import java.io.IOException; * mirror for available target VMs. *

* Connections can be made using one of several different - * {@link com.sun.jdi.connect.Connector} objects. Each connector encapsulates + * {@link Connector} objects. Each connector encapsulates * a different way of connecting the debugger with a target VM. *

* The VirtualMachineManager supports many different scenarios for * connecting a debugger to a virtual machine. Four examples * are presented in the table below. The * examples use the command line syntax in Sun's implementation. - * Some {@link com.sun.jdi.connect.Connector} implementations may require slightly + * Some {@link Connector} implementations may require slightly * different handling than presented below. * * @@ -59,8 +67,7 @@ import java.io.IOException; * * * - * @@ -166,12 +171,12 @@ import java.io.IOException; * the name "xxx". *
  • * Debugger changes the default connector parameters (obtained through - * {@link com.sun.jdi.connect.Connector#defaultArguments()}) to specify + * {@link Connector#defaultArguments()}) to specify * the transport specific address at which the VM is listenig. Optionally, * other connector arguments can be presented to the user. *
  • * Debugger calls the - * {@link com.sun.jdi.connect.AttachingConnector#attach(java.util.Map)} method + * {@link AttachingConnector#attach(java.util.Map)} method * of the selected to attach to the target VM. A {@link VirtualMachine} * mirror is returned. * @@ -181,7 +186,7 @@ import java.io.IOException; * *

    Connectors are created at start-up time. That is, they * are created the first time that {@link - * com.sun.jdi.Bootstrap#virtualMachineManager()} is invoked. + * Bootstrap#virtualMachineManager()} is invoked. * The list of all Connectors created at start-up time can be * obtained from the VirtualMachineManager by invoking the * {@link #allConnectors allConnectors} method. @@ -189,23 +194,23 @@ import java.io.IOException; *

    Connectors are created at start-up time if they are * installed on the platform. In addition, Connectors are created * automatically by the VirtualMachineManager to encapsulate any - * {@link com.sun.jdi.connect.spi.TransportService} implementations + * {@link TransportService} implementations * that are installed on the platform. These two mechanisms for * creating Connectors are described here. * *

    A Connector is installed on the platform if it is installed * in a jar file that is visible to the defining class loader of - * the {@link com.sun.jdi.connect.Connector} type, + * the {@link Connector} type, * and that jar file contains a provider configuration file named - * {@code com.sun.jdi.connect.Connector} in the resource directory + * {@code Connector} in the resource directory * {@code META-INF/services}, and the provider configuration file * lists the full-qualified class name of the Connector * implementation. A Connector is a class that implements the - * {@link com.sun.jdi.connect.Connector Connector} interface. More + * {@link Connector Connector} interface. More * appropriately the class implements one of the specific Connector - * types, namely {@link com.sun.jdi.connect.AttachingConnector - * AttachingConnector}, {@link com.sun.jdi.connect.ListeningConnector - * ListeningConnector}, or {@link com.sun.jdi.connect.LaunchingConnector + * types, namely {@link AttachingConnector + * AttachingConnector}, {@link ListeningConnector + * ListeningConnector}, or {@link LaunchingConnector * LaunchingConnector}. The format of the provider configuration file * is one fully-qualified class name per line. Space and tab characters * surrounding each class, as well as blank lines are ignored. The @@ -221,40 +226,37 @@ import java.io.IOException; * *

    In addition to Connectors installed on the platform the * VirtualMachineManager will also create Connectors to encapsulate - * any {@link com.sun.jdi.connect.spi.TransportService} implementations + * any {@link TransportService} implementations * that are installed on the platform. A TransportService is * installed on the platform if it installed in a jar file that is * visible to the defining class loader for the - * {@link com.sun.jdi.connect.spi.TransportService} type, and that jar + * {@link TransportService} type, and that jar * file contains a provider configuration file named - * {@code com.sun.jdi.connect.spi.TransportService} in the resource + * {@code TransportService} in the resource * directory {@code META-INF/services}, and the provider * configuration file lists the full-qualified class name of the * TransportService implementation. A TransportService is a concrete - * sub-class of {@link com.sun.jdi.connect.spi.TransportService + * sub-class of {@link TransportService * TransportService}. The format of the provider configuration file * is the same as the provider configuration file for Connectors * except that each class listed must be the fully-qualified class * name of a class that implements the TransportService interface. * *

    For each TransportService installed on the platform, the - * VirtualMachineManager creates a corresponding - * {@link com.sun.jdi.connect.AttachingConnector} and - * {@link com.sun.jdi.connect.ListeningConnector}. These - * Connectors are created to encapsulate a {@link - * com.sun.jdi.connect.Transport Transport} that in turn - * encapsulates the TransportService. + * VirtualMachineManager creates a corresponding {@link AttachingConnector} and + * {@link ListeningConnector}. These Connectors are created to encapsulate a + * {@link Transport Transport} that in turn encapsulates the TransportService. * The AttachingConnector will be named based on the name of the * transport service concatenated with the string {@code Attach}. * For example, if the transport service {@link - * com.sun.jdi.connect.spi.TransportService#name() name()} method + * TransportService#name() name()} method * returns {@code telepathic} then the AttachingConnector will * be named {@code telepathicAttach}. Similiarly the ListeningConnector * will be named with the string {@code Listen} tagged onto the * name of the transport service. The {@link - * com.sun.jdi.connect.Connector#description() description()} method + * Connector#description() description()} method * of both the AttachingConnector, and the ListeningConnector, will - * delegate to the {@link com.sun.jdi.connect.spi.TransportService#description() + * delegate to the {@link TransportService#description() * description()} method of the underlying transport service. Both * the AttachingConnector and the ListeningConnector will have two * Connector {@link com.sun.jdi.connect.Connector.Argument Arguments}. @@ -268,7 +270,7 @@ import java.io.IOException; * timeout or accept timeout. * *

    Initialization of the virtual machine manager will fail, that is - * {@link com.sun.jdi.Bootstrap#virtualMachineManager()} will throw an + * {@link Bootstrap#virtualMachineManager()} will throw an * error if the virtual machine manager is unable to create any * connectors. * @@ -282,45 +284,44 @@ public interface VirtualMachineManager { * be used as the launching connector when selection of a * connector with specific characteristics is unnecessary. * - * @return the default {@link com.sun.jdi.connect.LaunchingConnector} + * @return the default {@link LaunchingConnector} */ LaunchingConnector defaultConnector(); /** - * Returns the list of known {@link com.sun.jdi.connect.LaunchingConnector} objects. + * Returns the list of known {@link LaunchingConnector} objects. * Any of the returned objects can be used to launch a new target * VM and immediately create a {@link VirtualMachine} mirror for it. * - * Note that a target VM launched by a launching connector is not - * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been - * received. - * @return a list of {@link com.sun.jdi.connect.LaunchingConnector} objects. + * Note that a target VM launched by a launching connector is not guaranteed + * to be stable until after the {@link VMStartEvent} has been received. + * @return a list of {@link LaunchingConnector} objects. */ List launchingConnectors(); /** - * Returns the list of known {@link com.sun.jdi.connect.AttachingConnector} objects. + * Returns the list of known {@link AttachingConnector} objects. * Any of the returned objects can be used to attach to an existing target * VM and create a {@link VirtualMachine} mirror for it. * - * @return a list of {@link com.sun.jdi.connect.AttachingConnector} objects. + * @return a list of {@link AttachingConnector} objects. */ List attachingConnectors(); /** - * Returns the list of known {@link com.sun.jdi.connect.ListeningConnector} objects. + * Returns the list of known {@link ListeningConnector} objects. * Any of the returned objects can be used to listen for a * connection initiated by a target VM * and create a {@link VirtualMachine} mirror for it. * - * @return a list of {@link com.sun.jdi.connect.ListeningConnector} objects. + * @return a list of {@link ListeningConnector} objects. */ List listeningConnectors(); /** - * Returns the list of all known {@link com.sun.jdi.connect.Connector} objects. + * Returns the list of all known {@link Connector} objects. * - * @return a list of {@link com.sun.jdi.connect.Connector} objects. + * @return a list of {@link Connector} objects. */ List allConnectors(); @@ -332,7 +333,7 @@ public interface VirtualMachineManager { * target VMs to which this manager has initiated a connection. * A target VM will remain in this list * until the VM is disconnected. - * {@link com.sun.jdi.event.VMDisconnectEvent} is placed in the event queue + * {@link VMDisconnectEvent} is placed in the event queue * after the VM is removed from the list. * * @return a list of {@link VirtualMachine} objects, each mirroring @@ -364,9 +365,9 @@ public interface VirtualMachineManager { * Create a virtual machine mirror for a target VM. * *

    Creates a virtual machine mirror for a target VM - * for which a {@link com.sun.jdi.connect.spi.Connection Connection} + * for which a {@link Connection Connection} * already exists. A Connection is created when a {@link - * com.sun.jdi.connect.Connector Connector} establishes + * Connector Connector} establishes * a connection and successfully handshakes with a target VM. * A Connector can then use this method to create a virtual machine * mirror to represent the composite state of the target VM. @@ -374,9 +375,9 @@ public interface VirtualMachineManager { *

    The {@code process} argument specifies the * {@link java.lang.Process} object for the taget VM. It may be * specified as {@code null}. If the target VM is launched - * by a {@link com.sun.jdi.connect.LaunchingConnector + * by a {@link LaunchingConnector * LaunchingConnector} the {@code process} argument should be - * specified, otherwise calling {@link com.sun.jdi.VirtualMachine#process()} + * specified, otherwise calling {@link VirtualMachine#process()} * on the created virtual machine will return {@code null}. * *

    This method exists so that Connectors may create @@ -400,8 +401,8 @@ public interface VirtualMachineManager { * @throws IllegalStateException * if the connection is not open * - * @see com.sun.jdi.connect.spi.Connection#isOpen() - * @see com.sun.jdi.VirtualMachine#process() + * @see Connection#isOpen() + * @see VirtualMachine#process() * * @since 1.5 */ diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/AttachingConnector.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/AttachingConnector.java index ccb11c2b765..7e3cae886ce 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/AttachingConnector.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/AttachingConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,10 @@ package com.sun.jdi.connect; -import com.sun.jdi.VirtualMachine; -import java.util.Map; import java.io.IOException; +import java.util.Map; + +import com.sun.jdi.VirtualMachine; /** * A connector which attaches to a previously running target VM. @@ -36,6 +37,7 @@ import java.io.IOException; * @since 1.3 */ public interface AttachingConnector extends Connector { + /** * Attaches to a running application and returns a * mirror of its VM. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Connector.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Connector.java index a2b4b386b0a..0d815f5f750 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Connector.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Connector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,9 @@ package com.sun.jdi.connect; -import java.util.Map; -import java.util.List; import java.io.Serializable; +import java.util.List; +import java.util.Map; /** * A method of connection between a debugger and a target VM. @@ -46,6 +46,7 @@ import java.io.Serializable; * @since 1.3 */ public interface Connector { + /** * Returns a short identifier for the connector. Connector implementors * should follow similar naming conventions as are used with packages @@ -82,7 +83,7 @@ public interface Connector { * @return the map associating argument names with argument * information and default value. */ - Map defaultArguments(); + Map defaultArguments(); /** * Specification for and value of a Connector argument. @@ -92,6 +93,7 @@ public interface Connector { * or {@link Connector.SelectedArgument}. */ public interface Argument extends Serializable { + /** * Returns a short, unique identifier for the argument. * Not intended for exposure to end-user. @@ -157,6 +159,7 @@ public interface Connector { * by the localized versions of the strings "true" and "false". */ public interface BooleanArgument extends Argument { + /** * Sets the value of the argument. */ @@ -197,6 +200,7 @@ public interface Connector { * by their corresponding strings. */ public interface IntegerArgument extends Argument { + /** * Sets the value of the argument. * The value should be checked with {@link #isValid(int)} diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java index d122fa2b84b..8573cdf65c6 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ import java.util.Collections; public class IllegalConnectorArgumentsException extends Exception { private static final long serialVersionUID = -3042212603611350941L; + List names; /** @@ -48,8 +49,7 @@ public class IllegalConnectorArgumentsException extends Exception { * @param s the detailed message. * @param name the name of the invalid or inconsistent argument. */ - public IllegalConnectorArgumentsException(String s, - String name) { + public IllegalConnectorArgumentsException(String s, String name) { super(s); names = new ArrayList(1); names.add(name); @@ -65,7 +65,6 @@ public class IllegalConnectorArgumentsException extends Exception { */ public IllegalConnectorArgumentsException(String s, List names) { super(s); - this.names = new ArrayList(names); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/LaunchingConnector.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/LaunchingConnector.java index 2ad3ba6abfb..bfe09a539cf 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/LaunchingConnector.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/LaunchingConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,11 @@ package com.sun.jdi.connect; -import com.sun.jdi.VirtualMachine; -import java.util.Map; import java.io.IOException; +import java.util.Map; + +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.VMStartEvent; /** * A connector which can launch a target VM before connecting to it. @@ -36,6 +38,7 @@ import java.io.IOException; * @since 1.3 */ public interface LaunchingConnector extends Connector { + /** * Launches an application and connects to its VM. Properties * of the launch (possibly including options, @@ -47,14 +50,14 @@ public interface LaunchingConnector extends Connector { * Argument map values can be changed, but map entries should not be * added or deleted. *

    A target VM launched by a launching connector is not - * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been + * guaranteed to be stable until after the {@link VMStartEvent} has been * received. *

    * Important note: If a target VM is launched through this * funcctions, its output and error streams must be read as it * executes. These streams are available through the * {@link java.lang.Process Process} object returned by - * {@link com.sun.jdi.VirtualMachine#process}. If the streams are not periodically + * {@link VirtualMachine#process}. If the streams are not periodically * read, the target VM will stop executing when the buffers for these * streams are filled. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/ListeningConnector.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/ListeningConnector.java index 0057299168f..2587a9e2a00 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/ListeningConnector.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/ListeningConnector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,9 @@ package com.sun.jdi.connect; -import java.util.Map; import java.io.IOException; +import java.util.Map; + import com.sun.jdi.VirtualMachine; /** @@ -36,6 +37,7 @@ import com.sun.jdi.VirtualMachine; * @since 1.3 */ public interface ListeningConnector extends Connector { + /** * Indicates whether this listening connector supports multiple * connections for a single argument map. If so, a call to @@ -96,7 +98,6 @@ public interface ListeningConnector extends Connector { void stopListening(Map arguments) throws IOException, IllegalConnectorArgumentsException; - /** * Waits for a target VM to attach to this connector. * @@ -113,5 +114,4 @@ public interface ListeningConnector extends Connector { */ VirtualMachine accept(Map arguments) throws IOException, IllegalConnectorArgumentsException; - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Transport.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Transport.java index d185132ebfd..3542d4ceb2a 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Transport.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/Transport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,24 +25,24 @@ package com.sun.jdi.connect; -import com.sun.jdi.connect.spi.TransportService; // for javadoc +import com.sun.jdi.connect.spi.TransportService; /** * A method of communication between a debugger and a target VM. * *

    A Transport represents the transport mechanism used by a - * {@link com.sun.jdi.connect.Connector Connector} to establish a - * connection with a target VM. It consists of a name which is obtained - * by invoking the {@link #name} method. Furthermore, a Transport - * encapsulates a {@link com.sun.jdi.connect.spi.TransportService - * TransportService} which is the underlying service used - * to establish connections and exchange Java Debug Wire Protocol - * (JDWP) packets with a target VM. + * {@link Connector Connector} to establish a connection with a + * target VM. It consists of a name which is obtained by invoking + * the {@link #name} method. Furthermore, a Transport encapsulates a + * {@link TransportService TransportService} which is the underlying + * service used to establish connections and exchange + * Java Debug Wire Protocol (JDWP) packets with a target VM. * * @author Gordon Hirsch * @since 1.3 */ public interface Transport { + /** * Returns a short identifier for the transport. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/TransportTimeoutException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/TransportTimeoutException.java index d2a8e50089f..835086ac2f8 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/TransportTimeoutException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/TransportTimeoutException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.jdi.connect; +import com.sun.jdi.connect.spi.TransportService; + /** * This exception may be thrown as a result of a timeout * when attaching to a target VM, or waiting to accept a @@ -39,23 +41,23 @@ package com.sun.jdi.connect; * exception may be thrown if the connector supports a * timeout connector argument when accepting. * - *

    In addition, for developers creating {@link - * com.sun.jdi.connect.spi.TransportService TransportService} - * implementations this exception is thrown when - * {@link com.sun.jdi.connect.spi.TransportService#attach attach} - * times out when establishing a connection to a target VM, - * or {@link com.sun.jdi.connect.spi.TransportService#accept - * accept} times out while waiting for a target VM to connect.

    + *

    In addition, for developers creating {@link TransportService + * TransportService} implementations this exception is thrown when + * {@link TransportService#attach attach} times out when establishing a + * connection to a target VM, or {@link TransportService#accept accept} + * times out while waiting for a target VM to connect.

    * * @see AttachingConnector#attach * @see ListeningConnector#accept - * @see com.sun.jdi.connect.spi.TransportService#attach - * @see com.sun.jdi.connect.spi.TransportService#accept + * @see TransportService#attach + * @see TransportService#accept * * @since 1.5 */ public class TransportTimeoutException extends java.io.IOException { + private static final long serialVersionUID = 4107035242623365074L; + /** * Constructs a {@code TransportTimeoutException} with no detail * message. @@ -63,7 +65,6 @@ public class TransportTimeoutException extends java.io.IOException { public TransportTimeoutException() { } - /** * Constructs a {@code TransportTimeoutException} with the * specified detail message. @@ -73,5 +74,4 @@ public class TransportTimeoutException extends java.io.IOException { public TransportTimeoutException(String message) { super(message); } - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/VMStartException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/VMStartException.java index 0296e78a63f..0e2444ce213 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/VMStartException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/VMStartException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ package com.sun.jdi.connect; public class VMStartException extends Exception { private static final long serialVersionUID = 6408644824640801020L; + Process process; public VMStartException(Process process) { @@ -44,8 +45,7 @@ public class VMStartException extends Exception { this.process = process; } - public VMStartException(String message, - Process process) { + public VMStartException(String message, Process process) { super(message); this.process = process; } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java index 88fc547d882..5bc89f98da4 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,9 @@ package com.sun.jdi.connect.spi; * @since 1.5 */ public class ClosedConnectionException extends java.io.IOException { + private static final long serialVersionUID = 3877032124297204774L; + /** * Constructs a {@code ClosedConnectionException} with no detail * message. @@ -63,5 +65,4 @@ public class ClosedConnectionException extends java.io.IOException { public ClosedConnectionException(String message) { super(message); } - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java index 1e7943fbd70..705c4573005 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,14 +32,13 @@ import java.io.IOException; * *

    A Connection represents a bi-directional communication channel * between a debugger and a target VM. A Connection is created when - * {@link com.sun.jdi.connect.spi.TransportService TransportService} - * establishes a connection and successfully handshakes with a target - * VM. A TransportService implementation provides a reliable - * JDWP packet transportation service and consequently a Connection - * provides a reliable flow of JDWP packets between the debugger - * and the target VM. A Connection is stream oriented, that is, the - * JDWP packets written to a connection are read by the target VM - * in the order in which they were written. Similiarly packets written + * {@link TransportService TransportService} establishes a connection + * and successfully handshakes with a target VM. A TransportService + * implementation provides a reliable JDWP packet transportation service + * and consequently a Connection provides a reliable flow of JDWP packets + * between the debugger and the target VM. A Connection is stream oriented, + * that is, the JDWP packets written to a connection are read by the target VM + * in the order in which they were written. Similarly packets written * to a Connection by the target VM are read by the debugger in the * order in which they were written. * @@ -55,7 +54,6 @@ import java.io.IOException; * * @since 1.5 */ - public abstract class Connection { /** diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java index 1c06bd39447..39a9a7e2c09 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ package com.sun.jdi.connect.spi; import java.io.IOException; + +import com.sun.jdi.connect.Transport; import com.sun.jdi.connect.TransportTimeoutException; /** @@ -35,8 +37,8 @@ import com.sun.jdi.connect.TransportTimeoutException; *

    A transport service is a concrete subclass of this class * that has a zero-argument constructor and implements the abstract * methods specified below. It is the underlying service - * used by a {@link com.sun.jdi.connect.Transport} for - * connections between a debugger and a target VM. + * used by a {@link Transport} for connections between a debugger + * and a target VM. * *

    A transport service is used to establish a connection * between a debugger and a target VM, and to transport Java @@ -76,7 +78,6 @@ import com.sun.jdi.connect.TransportTimeoutException; * * @since 1.5 */ - public abstract class TransportService { /** @@ -108,7 +109,6 @@ public abstract class TransportService { */ public abstract boolean supportsMultipleConnections(); - /** * Tell whether or not this transport service supports a timeout * when attaching to a target VM. @@ -144,7 +144,6 @@ public abstract class TransportService { * @see #accept(TransportService.ListenKey,long,long) */ public abstract boolean supportsHandshakeTimeout(); - } /** @@ -373,5 +372,4 @@ public abstract class TransportService { */ public abstract Connection accept(ListenKey listenKey, long acceptTimeout, long handshakeTimeout) throws IOException; - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java index b56f0ca9e33..b9ed43b1ba2 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/AccessWatchpointEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.VirtualMachine; /** * Notification of a field access in the target VM. Field modifications diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/BreakpointEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/BreakpointEvent.java index 131a031ef72..2cca6e654ba 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/BreakpointEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/BreakpointEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,24 +25,20 @@ package com.sun.jdi.event; -import com.sun.jdi.*; - -import java.util.List; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.BreakpointRequest; /** * Notification of a breakpoint in the target VM. - * The breakpoint event - * is generated before the code at its location is executed. - * When a location - * is reached which satisfies a currently enabled - * {@link com.sun.jdi.request.BreakpointRequest breakpoint request}, - * an {@link EventSet event set} - * containing an instance of this class will be added - * to the VM's event queue. + * + * The breakpoint event is generated before the code at its location + * is executed. When a location is reached which satisfies a currently enabled + * {@link BreakpointRequest breakpoint request}, an {@link EventSet event set} + * containing an instance of this class will be added to the VM's event queue. * * @see EventQueue * @see VirtualMachine - * @see com.sun.jdi.request.BreakpointRequest + * @see BreakpointRequest * * @author Robert Field * @since 1.3 diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassPrepareEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassPrepareEvent.java index 4812994a1b2..bfb6c4e406c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassPrepareEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassPrepareEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,12 +25,15 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.EventRequest; /** * Notification of a class prepare in the target VM. See the JVM * specification for a definition of class preparation. Class prepare - * events are not generated for primtiive classes (for example, + * events are not generated for primitive classes (for example, * java.lang.Integer.TYPE). * * @see EventQueue @@ -40,6 +43,7 @@ import com.sun.jdi.*; * @since 1.3 */ public interface ClassPrepareEvent extends Event { + /** * Returns the thread in which this event has occurred. *

    @@ -51,7 +55,7 @@ public interface ClassPrepareEvent extends Event { * If the event was generated by a debugger system thread, the * value returned by this method is null, and if the requested * suspend policy for the event was - * {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD}, + * {@link EventRequest#SUSPEND_EVENT_THREAD}, * all threads will be suspended instead, and the * {@link EventSet#suspendPolicy} will reflect this change. *

    diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassUnloadEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassUnloadEvent.java index 357619563c8..9819d133fb9 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassUnloadEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ClassUnloadEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.VirtualMachine; /** * Notification of a class unload in the target VM. @@ -40,6 +40,7 @@ import com.sun.jdi.*; * @since 1.3 */ public interface ClassUnloadEvent extends Event { + /** * Returns the name of the class that has been unloaded. */ diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/Event.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/Event.java index b6f9653ef29..44023424562 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/Event.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/Event.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Mirror; +import com.sun.jdi.VirtualMachine; import com.sun.jdi.request.EventRequest; /** diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventIterator.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventIterator.java index 0028d850e0b..1ffba101acb 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventIterator.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ package com.sun.jdi.event; -import com.sun.jdi.*; - import java.util.Iterator; /** diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventQueue.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventQueue.java index f4c313abb31..e6f4a458d86 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventQueue.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventQueue.java @@ -25,28 +25,29 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Mirror; +import com.sun.jdi.VMDisconnectedException; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.EventRequest; /** * Manager of incoming debugger events for a target VM. * Events are always grouped in {@link EventSet}s. * EventSets generated by the debugger back end can be read * here. There is one instance of EventQueue assigned to a particular - * {@link com.sun.jdi.VirtualMachine VirtualMachine}. + * {@link VirtualMachine VirtualMachine}. *

    * Some events cause the suspension of the target VM - event requests * ({@link com.sun.jdi.request}) with a - * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy} - * of {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL} - * or {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD - * SUSPEND_EVENT_THREAD} and sometimes - * {@link VMStartEvent}. + * {@link EventRequest#suspendPolicy() suspend policy} + * of {@link EventRequest#SUSPEND_ALL SUSPEND_ALL} + * or {@link EventRequest#SUSPEND_EVENT_THREAD + * SUSPEND_EVENT_THREAD} and sometimes {@link VMStartEvent}. * If these suspensions are not resumed the target VM will hang. * Thus, it is always good policy to - * {@link #remove() remove()} every EventSet from the - * event queue until an EventSet containing a - * {@link VMDisconnectEvent} is read. - * Unless {@link com.sun.jdi.VirtualMachine#resume() resume} is + * {@link #remove() remove()} every EventSet from the event queue until + * an EventSet containing a {@link VMDisconnectEvent} is read. + * Unless {@link VirtualMachine#resume() resume} is * being handled in another way, each EventSet should invoke * {@link EventSet#resume()}. * @@ -56,18 +57,16 @@ import com.sun.jdi.*; * @author Robert Field * @since 1.3 */ - public interface EventQueue extends Mirror { /** * Waits forever for the next available event. * * @return the next {@link EventSet}. - * @throws InterruptedException if any thread has interrupted - * this thread. - * @throws com.sun.jdi.VMDisconnectedException if the connection - * to the target VM is no longer available. Note this will always - * be preceded by a {@link com.sun.jdi.event.VMDisconnectEvent}. + * @throws InterruptedException if any thread has interrupted this thread. + * @throws VMDisconnectedException if the connection + * to the target VM is no longer available. Note this will always + * be preceded by a {@link VMDisconnectEvent}. */ EventSet remove() throws InterruptedException; @@ -78,9 +77,9 @@ public interface EventQueue extends Mirror { * @return the next {@link EventSet}, or null if there is a timeout. * @throws InterruptedException if any thread has interrupted * this thread. - * @throws com.sun.jdi.VMDisconnectedException if the connection - * to the target VM is no longer available. Note this will always - * be preceded by a {@link com.sun.jdi.event.VMDisconnectEvent}. + * @throws VMDisconnectedException if the connection + * to the target VM is no longer available. Note this will always + * be preceded by a {@link VMDisconnectEvent}. * @throws IllegalArgumentException if the timeout argument * contains an illegal value. */ diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventSet.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventSet.java index 1acef1ef0d2..dd8e9639a32 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventSet.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/EventSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,15 +25,19 @@ package com.sun.jdi.event; -import com.sun.jdi.*; - import java.util.Set; +import com.sun.jdi.Location; +import com.sun.jdi.Mirror; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.BreakpointRequest; +import com.sun.jdi.request.EventRequest; + /** * Several {@link Event} objects may be created at a given time by * the target {@link VirtualMachine}. For example, there may be - * more than one {@link com.sun.jdi.request.BreakpointRequest} - * for a given {@link Location} + * more than one {@link BreakpointRequest} for a given {@link Location} * or you might single step to the same location as a * BreakpointRequest. These {@link Event} objects are delivered * together as an EventSet. For uniformity, an EventSet is always used @@ -125,18 +129,15 @@ import java.util.Set; * @author Robert Field * @since 1.3 */ - public interface EventSet extends Mirror, Set { /** * Returns the policy used to suspend threads in the target VM * for this event set. This policy is selected from the suspend * policies for each event's request; the target VM chooses the - * policy which suspends the most threads. The target VM - * suspends threads according to that policy - * and that policy is returned here. See - * {@link com.sun.jdi.request.EventRequest} for the possible - * policy values. + * policy which suspends the most threads. The target VM suspends + * threads according to that policy and that policy is returned here. + * See {@link EventRequest} for the possible policy values. *

    * In rare cases, the suspend policy may differ from the requested * value if a {@link ClassPrepareEvent} has occurred in a @@ -144,9 +145,9 @@ public interface EventSet extends Mirror, Set { * for details. * * @return the suspendPolicy which is either - * {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL}, - * {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD SUSPEND_EVENT_THREAD} or - * {@link com.sun.jdi.request.EventRequest#SUSPEND_NONE SUSPEND_NONE}. + * {@link EventRequest#SUSPEND_ALL SUSPEND_ALL}, + * {@link EventRequest#SUSPEND_EVENT_THREAD SUSPEND_EVENT_THREAD} or + * {@link EventRequest#SUSPEND_NONE SUSPEND_NONE}. */ int suspendPolicy(); @@ -157,13 +158,11 @@ public interface EventSet extends Mirror, Set { /** * Resumes threads suspended by this event set. If the {@link #suspendPolicy} - * is {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL}, a call - * to this method is equivalent to - * {@link com.sun.jdi.VirtualMachine#resume}. If the - * suspend policy is - * {@link com.sun.jdi.request.EventRequest#SUSPEND_EVENT_THREAD}, + * is {@link EventRequest#SUSPEND_ALL}, a call to this method is equivalent to + * {@link VirtualMachine#resume}. If the suspend policy is + * {@link EventRequest#SUSPEND_EVENT_THREAD}, * a call to this method is equivalent to - * {@link com.sun.jdi.ThreadReference#resume} for the event thread. + * {@link ThreadReference#resume} for the event thread. * Otherwise, a call to this method is a no-op. */ void resume(); diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ExceptionEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ExceptionEvent.java index ba887e56cff..267e1b45f15 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ExceptionEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ExceptionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,12 +25,14 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Location; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.request.ExceptionRequest; /** * Notification of an exception in the target VM. When an exception * is thrown which satisfies a currently enabled - * {@link com.sun.jdi.request.ExceptionRequest exception request}, + * {@link ExceptionRequest exception request}, * an {@link EventSet event set} * containing an instance of this class will be added * to the VM's event queue. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/LocatableEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/LocatableEvent.java index 489e6117a22..90f51984f3e 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/LocatableEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/LocatableEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; - -import java.util.List; - +import com.sun.jdi.Locatable; +import com.sun.jdi.ThreadReference; /** * Abstract superinterface of events which have both location * and thread. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodEntryEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodEntryEvent.java index 29216ed5d28..6605429d24d 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodEntryEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodEntryEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Method; /** * Notification of a method invocation in the target VM. This event diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodExitEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodExitEvent.java index 67ef5287827..a312c845c5f 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodExitEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MethodExitEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,10 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectCollectedException; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; /** * Notification of a method return in the target VM. This event @@ -68,6 +71,5 @@ public interface MethodExitEvent extends LocatableEvent { * * @since 1.6 */ - public Value returnValue(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java index b35a9f74875..a89d1d09ecc 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ModificationWatchpointEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,9 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.ModificationWatchpointRequest; /** * Notification of a field modification in the @@ -33,7 +35,7 @@ import com.sun.jdi.*; * * @see EventQueue * @see VirtualMachine - * @see com.sun.jdi.request.ModificationWatchpointRequest + * @see ModificationWatchpointRequest * * @author Robert Field * @since 1.3 diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java index e3b3a8f76ed..f324ffebcf4 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnterEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ThreadReference; /** * @@ -54,5 +55,5 @@ public interface MonitorContendedEnterEvent extends LocatableEvent { * * @return an {@link ObjectReference} for the monitor. */ - public ObjectReference monitor(); + public ObjectReference monitor(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java index 774e1b7732a..806b5f0fc29 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorContendedEnteredEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ThreadReference; /** * @@ -53,6 +54,5 @@ public interface MonitorContendedEnteredEvent extends LocatableEvent { * * @return an {@link ObjectReference} for the monitor. */ - public ObjectReference monitor(); - + public ObjectReference monitor(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitEvent.java index 2e5c63ffb40..dade0ad0428 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ThreadReference; /** * Notification that a thread in the target VM is about to @@ -52,12 +53,12 @@ public interface MonitorWaitEvent extends LocatableEvent { * * @return an {@link ObjectReference} for the monitor. */ - public ObjectReference monitor(); + public ObjectReference monitor(); /** * Returns the number of millisecond the thread will wait. * * @return a {@code jlong} containing monitor wait time in milliseconds. */ - public long timeout(); + public long timeout(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java index 93917b58f5f..1030ea16f6c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/MonitorWaitedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ThreadReference; /** * Notification that a thread in the target VM has finished @@ -52,14 +53,12 @@ public interface MonitorWaitedEvent extends LocatableEvent { * * @return an {@link ObjectReference} for the monitor. */ - public ObjectReference monitor(); + public ObjectReference monitor(); /** * Returns whether the wait has timed out or been interrupted. * * @return {@code true} if the wait is timed out. */ - public boolean timedout(); - - + public boolean timedout(); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/StepEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/StepEvent.java index 269ed38ce9a..3aaa141e74e 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/StepEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/StepEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,22 +25,20 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.request.StepRequest; /** * Notification of step completion in the target VM. - * The step event - * is generated immediately before the code at its location is executed; - * thus, if the step is entering a new method (as might occur with - * {@link com.sun.jdi.request.StepRequest#STEP_INTO StepRequest.STEP_INTO}) + * The step event is generated immediately before the code at its location + * is executed. Thus, if the step is entering a new method (as might occur + * with {@link StepRequest#STEP_INTO StepRequest.STEP_INTO}) * the location of the event is the first instruction of the method. * When a step leaves a method, the location of the event will be the * first instruction after the call in the calling method; note that * this location may not be at a line boundary, even if - * {@link com.sun.jdi.request.StepRequest#STEP_LINE StepRequest.STEP_LINE} - * was used. + * {@link StepRequest#STEP_LINE StepRequest.STEP_LINE} was used. * - * @see com.sun.jdi.request.StepRequest + * @see StepRequest * @see EventQueue * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadDeathEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadDeathEvent.java index 1277172c962..22e26ca46fc 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadDeathEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadDeathEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; /** * Notification of a completed thread in the target VM. The @@ -46,6 +47,7 @@ import com.sun.jdi.*; * @since 1.3 */ public interface ThreadDeathEvent extends Event { + /** * Returns the thread which is terminating. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadStartEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadStartEvent.java index e5fa0d25634..ae397b82518 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadStartEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/ThreadStartEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; /** * Notification of a new running thread in the target VM. @@ -53,6 +54,7 @@ import com.sun.jdi.*; * @since 1.3 */ public interface ThreadStartEvent extends Event { + /** * Returns the thread which has started. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDeathEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDeathEvent.java index 21e0107df2e..9afc5922221 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDeathEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDeathEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,43 +25,41 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.EventRequest; +import com.sun.jdi.request.EventRequestManager; +import com.sun.jdi.request.VMDeathRequest; /** * Notification of target VM termination. * This event occurs if the target VM terminates before the * VM disconnects ({@link VMDisconnectEvent}). - * Thus, this event will NOT occur if - * external forces terminate the connection (e.g. a crash) - * or if the connection is intentionally terminated with - * {@link com.sun.jdi.VirtualMachine#dispose() - * VirtualMachine.dispose()} + * Thus, this event will NOT occur if external forces terminate + * the connection (e.g. a crash) or if the connection is intentionally + * terminated with {@link VirtualMachine#dispose() VirtualMachine.dispose()} *

    - * On VM termination, a single unsolicited VMDeathEvent - * will always be sent with a - * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy} - * of {@link com.sun.jdi.request.EventRequest#SUSPEND_NONE SUSPEND_NONE}. + * On VM termination, a single unsolicited VMDeathEvent will always be sent with a + * {@link EventRequest#suspendPolicy() suspend policy} + * of {@link EventRequest#SUSPEND_NONE SUSPEND_NONE}. * Additional VMDeathEvents will be sent in the same event set if they are - * requested with a - * {@link com.sun.jdi.request.VMDeathRequest VMDeathRequest}. + * requested with a {@link VMDeathRequest VMDeathRequest}. *

    * The VM is still intact and can be queried at the point this * event was initiated but immediately thereafter it is not * considered intact and cannot be queried. * Note: If the enclosing {@link EventSet} has a - * {@link com.sun.jdi.request.EventRequest#suspendPolicy() suspend policy} - * other than - * {@link com.sun.jdi.request.EventRequest#SUSPEND_ALL SUSPEND_ALL} + * {@link EventRequest#suspendPolicy() suspend policy} other than + * {@link EventRequest#SUSPEND_ALL SUSPEND_ALL} * the initiating point may be long past. *

    * All VMDeathEvents will be in a single {@link EventSet}, - * no other events will be in the event set. A resume + * no other events will be in the event set. A resume * must occur to continue execution after any event set which * performs suspensions - in this case to allow proper shutdown. * * @see VMDisconnectEvent - * @see com.sun.jdi.request.EventRequestManager#createVMDeathRequest - * @see com.sun.jdi.request.VMDeathRequest + * @see EventRequestManager#createVMDeathRequest + * @see VMDeathRequest * @see EventQueue * @see VirtualMachine * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDisconnectEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDisconnectEvent.java index a2cf66ea537..6e9fa41be8b 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDisconnectEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMDisconnectEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,14 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.request.EventRequest; /** * Notification of disconnection from target VM. * May be caused by normal termination of a VM, * VM termination by uncaught exception or other error, - * debugger action ( - * {@link VirtualMachine#dispose} or + * debugger action ({@link VirtualMachine#dispose} or * {@link VirtualMachine#exit}) or by external events * (for example, target process termination by the * operating system, transport termination, etc). @@ -41,9 +41,9 @@ import com.sun.jdi.*; * will be preceded by a {@link VMDeathEvent}. *

    * This event is always sent. - * There is no corresponding {@link com.sun.jdi.request.EventRequest}. + * There is no corresponding {@link EventRequest}. * The enclosing singleton {@link EventSet} always has a - * suspend policy of {@link com.sun.jdi.request.EventRequest#SUSPEND_NONE}. + * suspend policy of {@link EventRequest#SUSPEND_NONE}. * * @see VMDeathEvent * @see EventQueue diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMStartEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMStartEvent.java index 37693ad7587..749865efaff 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMStartEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/VMStartEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; /** * Notification of initialization of a target VM. This event is @@ -44,6 +45,7 @@ import com.sun.jdi.*; * @since 1.3 */ public interface VMStartEvent extends Event { + /** * Returns the initial thread of the VM which has started. * diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/WatchpointEvent.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/WatchpointEvent.java index 4573407580f..1a3fd28a18f 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/WatchpointEvent.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/event/WatchpointEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,11 @@ package com.sun.jdi.event; -import com.sun.jdi.*; +import com.sun.jdi.Field; +import com.sun.jdi.ObjectCollectedException; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; /** * Notification of a field triggered event encountered by a thread in the diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java index 091cf44dccb..4d2a5e41464 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/AccessWatchpointRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,9 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.event.AccessWatchpointEvent; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; /** * Request for notification when the contents of a field are accessed @@ -36,20 +38,19 @@ import com.sun.jdi.*; * GetStatic<Type>Field). * Access by JDI does not trigger this event. * When an enabled AccessWatchpointRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing an - * {@link com.sun.jdi.event.AccessWatchpointEvent AccessWatchpointEvent} will be placed - * on the {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing an + * {@link AccessWatchpointEvent AccessWatchpointEvent} will be placed + * on the {@link EventQueue EventQueue}. * The collection of existing ExceptionRequests is * managed by the {@link EventRequestManager} - * The collection of existing - * watchpoints is + * The collection of existing watchpoints is * managed by the {@link EventRequestManager}. *

    * Note that the modification * of a Field is not considered an access. * * @see ModificationWatchpointRequest - * @see com.sun.jdi.event.EventQueue + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/BreakpointRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/BreakpointRequest.java index 259aa547705..05e9645b9e7 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/BreakpointRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/BreakpointRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,22 +25,29 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.Locatable; +import com.sun.jdi.Location; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.BreakpointEvent; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; /** * Identifies a {@link Location} in the target VM at which * execution should be stopped. When an enabled BreakpointRequest is * satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing an - * {@link com.sun.jdi.event.BreakpointEvent BreakpointEvent} + * {@link EventSet event set} containing an + * {@link BreakpointEvent BreakpointEvent} * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue} and + * {@link EventQueue EventQueue} and * the application is interrupted. The collection of existing breakpoints is * managed by the {@link EventRequestManager} * * @see Location - * @see com.sun.jdi.event.BreakpointEvent - * @see com.sun.jdi.event.EventQueue + * @see BreakpointEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassPrepareRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassPrepareRequest.java index efaf237c7d0..079f993c019 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassPrepareRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassPrepareRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,23 +25,27 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.ClassPrepareEvent; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; /** * Request for notification when a class is prepared in the target VM. * When an enabled ClassPrepareRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.ClassPrepareEvent ClassPrepareEvent} + * {@link EventSet event set} containing a + * {@link ClassPrepareEvent ClassPrepareEvent} * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventQueue EventQueue}. * The collection of existing ClassPrepareRequests is * managed by the {@link EventRequestManager} *

    * Class preparation is defined in the Java Virtual Machine * Specification. * - * @see com.sun.jdi.event.ClassPrepareEvent - * @see com.sun.jdi.event.EventQueue + * @see ClassPrepareEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassUnloadRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassUnloadRequest.java index 2f2758e5108..45b5d84778a 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassUnloadRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ClassUnloadRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,22 +25,24 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.event.ClassUnloadEvent; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; /** * Request for notification when a class is unloaded in the target VM. * When an enabled ClassUnloadRequest is satisfied, a - * {@link com.sun.jdi.event.EventSet event set} containing an - * {@link com.sun.jdi.event.ClassUnloadEvent ClassUnloadEvent} will - * be placed on the {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing an + * {@link ClassUnloadEvent ClassUnloadEvent} will + * be placed on the {@link EventQueue EventQueue}. * The collection of existing ClassUnloadRequests is * managed by the {@link EventRequestManager} *

    * Refer to the Java Virtual Machine Specification for more information * on class unloading. * - * @see com.sun.jdi.event.ClassUnloadEvent - * @see com.sun.jdi.event.EventQueue + * @see ClassUnloadEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/DuplicateRequestException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/DuplicateRequestException.java index fa8c0783fb8..d654001797c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/DuplicateRequestException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/DuplicateRequestException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ package com.sun.jdi.request; * @since 1.3 */ public class DuplicateRequestException extends RuntimeException { + private static final long serialVersionUID = -3719784920313411060L; public DuplicateRequestException() { diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequest.java index 062fc53fe34..b605d774233 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,22 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.Mirror; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VMDisconnectedException; +import com.sun.jdi.VMOutOfMemoryException; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.BreakpointEvent; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.VMDisconnectEvent; /** * Represents a request for notification of an event. Examples include * {@link BreakpointRequest} and {@link ExceptionRequest}. * When an event occurs for which an enabled request is present, - * an {@link com.sun.jdi.event.EventSet EventSet} will - * be placed on the {@link com.sun.jdi.event.EventQueue EventQueue}. + * an {@link EventSet EventSet} will + * be placed on the {@link EventQueue EventQueue}. * The collection of existing event requests is * managed by the {@link EventRequestManager}. *

    @@ -63,16 +71,16 @@ import com.sun.jdi.*; *

    * Any method on {@code EventRequest} which * takes {@code EventRequest} as an parameter may throw - * {@link com.sun.jdi.VMDisconnectedException} if the target VM is - * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is - * available to be read from the {@link com.sun.jdi.event.EventQueue}. + * {@link VMDisconnectedException} if the target VM is + * disconnected and the {@link VMDisconnectEvent} has been or is + * available to be read from the {@link EventQueue}. *

    * Any method on {@code EventRequest} which * takes {@code EventRequest} as an parameter may throw - * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory. + * {@link VMOutOfMemoryException} if the target VM has run out of memory. * - * @see com.sun.jdi.event.BreakpointEvent - * @see com.sun.jdi.event.EventQueue + * @see BreakpointEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field @@ -159,8 +167,8 @@ public interface EventRequest extends Mirror { *

    * Thread suspensions through events have the same functionality * as explicitly requested suspensions. See - * {@link com.sun.jdi.ThreadReference#suspend} and - * {@link com.sun.jdi.VirtualMachine#suspend} for details. + * {@link ThreadReference#suspend} and + * {@link VirtualMachine#suspend} for details. * * @param policy the selected suspend policy. * @throws InvalidRequestStateException if this request is currently diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java index cfd53b7762f..2ffa7008ee4 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,30 @@ package com.sun.jdi.request; -import com.sun.jdi.*; - import java.util.List; +import com.sun.jdi.Field; +import com.sun.jdi.Location; +import com.sun.jdi.Mirror; +import com.sun.jdi.NativeMethodException; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.BreakpointEvent; +import com.sun.jdi.event.Event; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.ExceptionEvent; +import com.sun.jdi.event.VMDeathEvent; + /** * Manages the creation and deletion of {@link EventRequest}s. A single - * implementor of this interface exists in a particuar VM and + * implementor of this interface exists in a particular VM and * is accessed through {@link VirtualMachine#eventRequestManager()} * * @see EventRequest - * @see com.sun.jdi.event.Event + * @see Event * @see BreakpointRequest - * @see com.sun.jdi.event.BreakpointEvent + * @see BreakpointEvent * @see VirtualMachine * * @author Robert Field @@ -97,7 +108,7 @@ public interface EventRequestManager extends Mirror { * or both can be selected. Note, however, that * at the time an exception is thrown, it is not always * possible to determine whether it is truly caught. See - * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for + * {@link ExceptionEvent#catchLocation} for * details. * @param refType If non-null, specifies that exceptions which are * instances of refType will be reported. Note: this @@ -217,19 +228,19 @@ public interface EventRequestManager extends Mirror { *

    * The returned request will control stepping only in the specified * {@code thread}; all other threads will be unaffected. - * A {@code size} value of {@link com.sun.jdi.request.StepRequest#STEP_MIN} will generate a + * A {@code size} value of {@link StepRequest#STEP_MIN} will generate a * step event each time the code index changes. It represents the * smallest step size available and often maps to the instruction * level. - * A {@code size} value of {@link com.sun.jdi.request.StepRequest#STEP_LINE} will generate a + * A {@code size} value of {@link StepRequest#STEP_LINE} will generate a * step event each time the source line changes unless line number information is not available, * in which case a STEP_MIN will be done instead. For example, no line number information is * available during the execution of a method that has been rendered obsolete by - * by a {@link com.sun.jdi.VirtualMachine#redefineClasses} operation. - * A {@code depth} value of {@link com.sun.jdi.request.StepRequest#STEP_INTO} will generate + * by a {@link VirtualMachine#redefineClasses} operation. + * A {@code depth} value of {@link StepRequest#STEP_INTO} will generate * step events in any called methods. A {@code depth} value - * of {@link com.sun.jdi.request.StepRequest#STEP_OVER} restricts step events to the current frame - * or caller frames. A {@code depth} value of {@link com.sun.jdi.request.StepRequest#STEP_OUT} + * of {@link StepRequest#STEP_OVER} restricts step events to the current frame + * or caller frames. A {@code depth} value of {@link StepRequest#STEP_OUT} * restricts step events to caller frames only. All depth * restrictions are relative to the call stack immediately before the * step takes place. @@ -327,7 +338,7 @@ public interface EventRequestManager extends Mirror { * activate this event request. *

    * This request (if enabled) will cause a - * {@link com.sun.jdi.event.VMDeathEvent} + * {@link VMDeathEvent} * to be sent on termination of the target VM. *

    * A VMDeathRequest with a suspend policy of @@ -338,8 +349,8 @@ public interface EventRequestManager extends Mirror { * events before VM death. If all event processing is being * done in the same thread as event sets are being read, * enabling the request is all that is needed since the VM - * will be suspended until the {@link com.sun.jdi.event.EventSet} - * containing the {@link com.sun.jdi.event.VMDeathEvent} + * will be suspended until the {@link EventSet} + * containing the {@link VMDeathEvent} * is resumed. *

    * Not all target virtual machines support this operation. diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ExceptionRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ExceptionRequest.java index 5dad44e466b..b6713601a97 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ExceptionRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ExceptionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,25 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.ExceptionEvent; /** * Request for notification when an exception occurs in the target VM. * When an enabled ExceptionRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing an - * {@link com.sun.jdi.event.ExceptionEvent ExceptionEvent} will be placed - * on the {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing an + * {@link ExceptionEvent ExceptionEvent} will be placed + * on the {@link EventQueue EventQueue}. * The collection of existing ExceptionRequests is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.ExceptionEvent - * @see com.sun.jdi.event.EventQueue + * @see ExceptionEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field @@ -60,7 +66,7 @@ public interface ExceptionRequest extends EventRequest { *

    * Note that at the time an exception is thrown, it is not always * possible to determine whether it is truly caught. See - * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for + * {@link ExceptionEvent#catchLocation} for * details. * @return * boolean true if caught exceptions will be reported, false @@ -74,7 +80,7 @@ public interface ExceptionRequest extends EventRequest { *

    * Note that at the time an exception is thrown, it is not always * possible to determine whether it is truly uncaught. See - * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for + * {@link ExceptionEvent#catchLocation} for * details. * @return * boolean true if caught exceptions will be reported, false diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/InvalidRequestStateException.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/InvalidRequestStateException.java index 8bcd93e0a0b..5d0e7d3c9ba 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/InvalidRequestStateException.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/InvalidRequestStateException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,14 +36,14 @@ package com.sun.jdi.request; * @since 1.3 */ public class InvalidRequestStateException extends RuntimeException { + private static final long serialVersionUID = -3774632428543322148L; - public InvalidRequestStateException() - { + + public InvalidRequestStateException() { super(); } - public InvalidRequestStateException(String s) - { + public InvalidRequestStateException(String s) { super(s); } } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodEntryRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodEntryRequest.java index 8636b108a79..a9b075221de 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodEntryRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodEntryRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,20 +25,25 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.MethodEntryEvent; /** * Request for notification when a method is invoked in the target VM. * When an enabled MethodEntryRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.MethodEntryEvent MethodEntryEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link MethodEntryEvent MethodEntryEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing MethodEntryRequests is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.MethodEntryEvent - * @see com.sun.jdi.event.EventQueue + * @see MethodEntryEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodExitRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodExitRequest.java index f8a852a13f0..77fefd405af 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodExitRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MethodExitRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,20 +25,25 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.MethodExitEvent; /** * Request for notification when a method returns in the target VM. * When an enabled MethodExitRequest is hit, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.MethodExitEvent MethodExitEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link MethodExitEvent MethodExitEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing MethodExitRequests is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.MethodExitEvent - * @see com.sun.jdi.event.EventQueue + * @see MethodExitEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java index 29247dfed23..9ed8984f5f9 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ModificationWatchpointRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,9 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.ModificationWatchpointEvent; /** * Request for notification when a field is set. @@ -37,19 +39,16 @@ import com.sun.jdi.*; * Setting a field to a value which is the same as the previous value * still triggers this event. * Modification by JDI does not trigger this event. - * When an enabled - * ModificationWatchpointRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.ModificationWatchpointEvent ModificationWatchpointEvent} - * will be placed on - * the {@link com.sun.jdi.event.EventQueue EventQueue}. - * The collection of existing - * watchpoints is + * When an enabled ModificationWatchpointRequest is satisfied, an + * {@link EventSet event set} containing a + * {@link ModificationWatchpointEvent ModificationWatchpointEvent} + * will be placed on the {@link EventQueue EventQueue}. + * The collection of existing watchpoints is * managed by the {@link EventRequestManager}. * - * @see com.sun.jdi.event.ModificationWatchpointEvent + * @see ModificationWatchpointEvent * @see AccessWatchpointRequest - * @see com.sun.jdi.event.EventQueue + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java index 2422dad489a..c0adcfccf7c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnterRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,21 +25,26 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.MonitorContendedEnterEvent; /** * Request for notification of a thread in the target VM * attempting to enter a monitor already acquired by another thread. * When an enabled MonitorContededEnterRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.MonitorContendedEnterEvent MonitorContendedEnterEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link MonitorContendedEnterEvent MonitorContendedEnterEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing MonitorContendedEnterEvents is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.MonitorContendedEnterEvent - * @see com.sun.jdi.event.EventQueue + * @see MonitorContendedEnterEvent + * @see EventQueue * @see EventRequestManager * * @author Swamy Venkataramanappa diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java index ad617722102..953d53764d8 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorContendedEnteredRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,21 +25,26 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.MonitorContendedEnteredEvent; /** * Request for notification of a thread in the target VM entering a monitor * after waiting for it to be released by another thread. * When an enabled MonitorContededEnteredRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.MonitorContendedEnteredEvent MonitorContendedEnteredEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link MonitorContendedEnteredEvent MonitorContendedEnteredEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing MonitorContendedEnteredEvents is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.MonitorContendedEnteredEvent - * @see com.sun.jdi.event.EventQueue + * @see MonitorContendedEnteredEvent + * @see EventQueue * @see EventRequestManager * * @author Swamy Venkataramanappa diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitRequest.java index 81433ca6242..4dcf0f8a38a 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,21 +25,26 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.MonitorWaitEvent; /** * Request for notification when a thread in the target VM is about to * wait on a monitor object. That is, a thread is entering Object.wait(). * When an enabled MonitorWaitRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.MonitorWaitEvent MonitorWaitEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link MonitorWaitEvent MonitorWaitEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing MonitorWaitEvents is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.MonitorWaitEvent - * @see com.sun.jdi.event.EventQueue + * @see MonitorWaitEvent + * @see EventQueue * @see EventRequestManager * * @author Swamy Venkataramanappa diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java index 1b278ef9300..6a3b62c1943 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/MonitorWaitedRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,21 +25,26 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.MonitorWaitedEvent; /** * Request for notification when a thread in the target VM has finished waiting on * a monitor object. That is, a thread is leaving Object.wait(). " * When an enabled MonitorWaitedRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.MonitorWaitedEvent MonitorWaitedEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link MonitorWaitedEvent MonitorWaitedEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing MonitorWaitedEvents is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.MonitorWaitedEvent - * @see com.sun.jdi.event.EventQueue + * @see MonitorWaitedEvent + * @see EventQueue * @see EventRequestManager * * @author Swamy Venkataramanappa diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/StepRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/StepRequest.java index df3c899f2c0..5c34f8fd2ff 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/StepRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/StepRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,25 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.StepEvent; /** * Request for notification when a step occurs in the target VM. * When an enabled StepRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.StepEvent StepEvent} will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link StepEvent StepEvent} will be placed on the + * {@link EventQueue EventQueue}. * The collection of existing StepRequests is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.StepEvent - * @see com.sun.jdi.event.EventQueue + * @see StepEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadDeathRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadDeathRequest.java index f39eb3e7903..77334bc040c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadDeathRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadDeathRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,20 +25,23 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.ThreadDeathEvent; /** * Request for notification when a thread terminates in the target VM. * When an enabled ThreadDeathRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.ThreadDeathEvent ThreadDeathEvent} + * {@link EventSet event set} containing a + * {@link ThreadDeathEvent ThreadDeathEvent} * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventQueue EventQueue}. * The collection of existing ThreadDeathRequests is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.ThreadDeathEvent - * @see com.sun.jdi.event.EventQueue + * @see ThreadDeathEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadStartRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadStartRequest.java index 0ee00a0201a..55e3c3f5fe5 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadStartRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/ThreadStartRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,20 +25,23 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.ThreadStartEvent; /** * Request for notification when a thread starts execution in the target VM. * When an enabled ThreadStartRequest is hit, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.ThreadStartEvent ThreadStartEvent} + * {@link EventSet event set} containing a + * {@link ThreadStartEvent ThreadStartEvent} * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventQueue EventQueue}. * The collection of existing ThreadStartRequests is * managed by the {@link EventRequestManager} * - * @see com.sun.jdi.event.ThreadStartEvent - * @see com.sun.jdi.event.EventQueue + * @see ThreadStartEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/VMDeathRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/VMDeathRequest.java index 4aadcc9d827..02580746644 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/VMDeathRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/VMDeathRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,15 +25,16 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.VMDeathEvent; /** * Request for notification when the target VM terminates. * When an enabled VMDeathRequest is satisfied, an - * {@link com.sun.jdi.event.EventSet event set} containing a - * {@link com.sun.jdi.event.VMDeathEvent VMDeathEvent} - * will be placed on the - * {@link com.sun.jdi.event.EventQueue EventQueue}. + * {@link EventSet event set} containing a + * {@link VMDeathEvent VMDeathEvent} + * will be placed on the {@link EventQueue EventQueue}. * The collection of existing VMDeathRequests is * managed by the {@link EventRequestManager} *

    @@ -49,13 +50,12 @@ import com.sun.jdi.*; * to be alive (e.g. event processing). Note: the * unsolicited VMDeathEvent will still be sent. * - * @see com.sun.jdi.event.VMDeathEvent - * @see com.sun.jdi.event.EventQueue + * @see VMDeathEvent + * @see EventQueue * @see EventRequestManager * * @author Robert Field * @since 1.4 */ public interface VMDeathRequest extends EventRequest { - } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/WatchpointRequest.java b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/WatchpointRequest.java index 9fb63ca117b..81f1edf2e6f 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/WatchpointRequest.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/request/WatchpointRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,19 @@ package com.sun.jdi.request; -import com.sun.jdi.*; +import com.sun.jdi.Field; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.EventQueue; /** * Identifies a {@link Field} in the target VM being watched. * * @see AccessWatchpointRequest * @see ModificationWatchpointRequest - * @see com.sun.jdi.event.EventQueue + * @see EventQueue * @see EventRequestManager * * @author Robert Field From eb2f52dc0b3e0c0b626f6d3fdbed94ee17b0a4eb Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Fri, 16 Jun 2017 08:00:53 -0700 Subject: [PATCH 36/59] 8182321: Mark java/lang/ProcessHandle/OnExitTest.java as intermittent Reviewed-by: rriggs --- jdk/test/java/lang/ProcessHandle/OnExitTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/lang/ProcessHandle/OnExitTest.java b/jdk/test/java/lang/ProcessHandle/OnExitTest.java index 444143782e9..7c54e475a46 100644 --- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java +++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java @@ -40,6 +40,7 @@ import org.testng.TestNG; /* * @test + * @key intermittent * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.management From dd0b582f4b691d91917f4cc6589a1d58ea0c1f5a Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Fri, 16 Jun 2017 17:06:35 -0700 Subject: [PATCH 37/59] 8182388: Backout 8182143 Reviewed-by: xuelei --- .../ssl/SignatureAndHashAlgorithm.java | 18 +++++++++++------- .../net/ssl/TLSv12/SignatureAlgorithms.java | 19 +++++++++++++++++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java index b9f11f851bf..8445a665da3 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -411,12 +411,16 @@ final class SignatureAndHashAlgorithm { "SHA1withRSA", --p); supports(HashAlgorithm.SHA1, SignatureAlgorithm.ECDSA, "SHA1withECDSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA, - "SHA224withDSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA, - "SHA224withRSA", --p); - supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA, - "SHA224withECDSA", --p); + + if (Security.getProvider("SunMSCAPI") == null) { + supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA, + "SHA224withDSA", --p); + supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA, + "SHA224withRSA", --p); + supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA, + "SHA224withECDSA", --p); + } + supports(HashAlgorithm.SHA256, SignatureAlgorithm.DSA, "SHA256withDSA", --p); supports(HashAlgorithm.SHA256, SignatureAlgorithm.RSA, diff --git a/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java b/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java index 0533d31135e..8b51703df41 100644 --- a/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java +++ b/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -30,7 +30,7 @@ /* * @test - * @bug 8049321 8182143 + * @bug 8049321 * @summary Support SHA256WithDSA in JSSE * @run main/othervm SignatureAlgorithms PKIX "SHA-224,SHA-256" * TLS_DHE_DSS_WITH_AES_128_CBC_SHA @@ -434,6 +434,21 @@ public class SignatureAlgorithms { */ parseArguments(args); + + /* + * Ignore testing on Windows if only SHA-224 is available. + */ + if ((Security.getProvider("SunMSCAPI") != null) && + (disabledAlgorithms.contains("SHA-1")) && + (disabledAlgorithms.contains("SHA-256"))) { + + System.out.println( + "Windows system does not support SHA-224 algorithms yet. " + + "Ignore the testing"); + + return; + } + /* * Expose the target algorithms by diabling unexpected algorithms. */ From 81e85e6a501fa4324636eea9bebc5052ed175b94 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:42 +0000 Subject: [PATCH 38/59] Added tag jdk-10+12 for changeset 31045970cc45 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 81d2093273c..fe3b2c958fd 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -429,3 +429,4 @@ b94be69cbb1d2943b886bf2d458745756df146e4 jdk-10+9 6b750cdb823a029a25ff2e560302cc2d28a86cb6 jdk-10+11 88d7fd969e7df0e07a53b201cfd29393ca33ede9 jdk-9+173 5466f409346e0446ee9a6daeb7f5d75c8fc76823 jdk-9+174 +8d4ed1e06fe184c9cb08c5b708e7d6f5c066644f jdk-10+12 From 47a47dfd6b272c93eb3596145908ec364d4f3271 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:45 +0000 Subject: [PATCH 39/59] Added tag jdk-10+12 for changeset 3955aa021599 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index d58a1758875..9e2f8bd8ab2 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -429,3 +429,4 @@ df64bd4757d0d130d62a22b8143ba31d3a16ac18 jdk-10+10 7c54889c0ec649ee04643e5cace434623d0dc667 jdk-10+11 a5506b425f1bf91530d8417b57360e5d89328c0c jdk-9+173 42f18c931bd4fae5c206ccf6d8e591e4c4e69d31 jdk-9+174 +5f504872a75b71f2fb19299f0d1e3395cf32eaa0 jdk-10+12 From 6aa63669b18f3a7d3529e12af33af098feb995f1 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:49 +0000 Subject: [PATCH 40/59] Added tag jdk-10+12 for changeset 31f4fe261732 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index b62ad6baac0..c84b66e9b45 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -429,3 +429,4 @@ c62e5964cfcf144d8f72e9ba69757897785349a9 jdk-9+171 8ef8a0f1c4dfea17e10125e1f885920538e63085 jdk-10+11 534ba4f8cfcf12accc5b9adb943103f2ff79fe16 jdk-9+173 3615768c12904e29bb2ec1b506cd4633cd8a9ced jdk-9+174 +00ae6307d78bac49883ddc85d687aa88c49f3971 jdk-10+12 From 82a5b81e1c2e6615ddd8bc6a733e680c20b69a2d Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:50 +0000 Subject: [PATCH 41/59] Added tag jdk-10+12 for changeset 2b591c4d54e8 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index cfb315cd62f..c5d17921cc0 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -589,3 +589,4 @@ c6cd3ec8d46b034e57c86399380ffcf7f25706e4 jdk-10+10 7f14e550f1e8abea41c223e5fdad2261e99ba929 jdk-10+11 e64b1cb48d6e7703928a9d1da106fc27f8cb65fd jdk-9+173 944791f8160185bffa13fbb821fc09b6198f1f25 jdk-9+174 +070aa7a2eb14c4645f7eb31384cba0a2ba72a4b5 jdk-10+12 From 27811438d74626bc87d979b2bf74f2658aaebdac Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:54 +0000 Subject: [PATCH 42/59] Added tag jdk-10+12 for changeset 11062587f5ad --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 773518afe66..ca0f5c2f382 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -432,3 +432,4 @@ e705867d9989d00e4357f66f18b302c95e13b5e7 jdk-10+8 2d22d6732a73e615b9e13d6bc93bf026db3bc231 jdk-10+11 2bd967aa452c1e0e87a6173bef6fbb96ef1c521b jdk-9+173 c2296642010f1b215ac35da89e92c3ce44104e32 jdk-9+174 +712a3a657654079514590d37a0f4894d43541d5c jdk-10+12 From 87cf68f36129f24877c5b3319b578c3feeaff58e Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:55 +0000 Subject: [PATCH 43/59] Added tag jdk-10+12 for changeset dc68478b53b9 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 1eeb0ed13db..cdfd5b35528 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -429,3 +429,4 @@ eedb6e54c8bd6197ecba5fc0d8568bac8ae852dd jdk-9+172 95bab8bf9201ae8bfdf28e164bf33b78e49477e7 jdk-10+11 9788347e0629d0cb3a0e55a903494ff741d4fa15 jdk-9+173 b9c0b105002272d7414c8b34af9aded151f9cad6 jdk-9+174 +ff293e39e83366c40a5687dacd1ccb2305ed2c1e jdk-10+12 From 9672778c0190bbc9157603638f521714c55e1e06 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Sat, 17 Jun 2017 00:15:56 +0000 Subject: [PATCH 44/59] Added tag jdk-10+12 for changeset 4a203b007156 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index b466a82bff5..f93a3165701 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -420,3 +420,4 @@ c8d6b740f0f7ec834b4157bf0d4523e8bbddb3f0 jdk-9+172 ae0c4f1560e41e94a843e9933558d0223575869d jdk-10+11 fa8e4de50e821eed876388c84f7129a6739268be jdk-9+173 7d4006eaa088848c4fa2ac4aef0ba9982f80752a jdk-9+174 +de571c0a93258599054f18184cbdeae42cd95265 jdk-10+12 From 87beee49ce5e00fd227bb0116bdcb4a5437c5c16 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Mon, 19 Jun 2017 09:27:17 +0800 Subject: [PATCH 45/59] 8181309: Refactor shell test AsynchronousChannelProvider/custom_provider.sh to java Reviewed-by: alanb --- .../CheckProvider.java | 11 ++- .../Provider1.java | 8 ++- .../Provider2.java | 8 ++- .../custom_provider.sh | 71 ------------------- 4 files changed, 20 insertions(+), 78 deletions(-) delete mode 100644 jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh diff --git a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java index b3af8fa6771..3a53b46ba6f 100644 --- a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java +++ b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,6 +21,15 @@ * questions. */ +/* + * @test + * @summary Unit test for java.nio.channels.spi.AsynchronousChannelProvider + * @build Provider1 Provider2 + * @run main/othervm CheckProvider Provider1 + * @run main/othervm -Djava.nio.channels.spi.AsynchronousChannelProvider=Provider2 + * CheckProvider Provider2 + */ + import java.nio.channels.spi.AsynchronousChannelProvider; public class CheckProvider { diff --git a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java index e531e90368e..fbd3b69f85c 100644 --- a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java +++ b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,13 @@ * questions. */ +import java.io.IOException; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousSocketChannel; import java.nio.channels.spi.AsynchronousChannelProvider; -import java.nio.channels.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; -import java.io.IOException; public class Provider1 extends AsynchronousChannelProvider { public Provider1() { diff --git a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java index bb587adf8b2..10e7fc67d39 100644 --- a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java +++ b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,13 @@ * questions. */ +import java.io.IOException; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousSocketChannel; import java.nio.channels.spi.AsynchronousChannelProvider; -import java.nio.channels.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; -import java.io.IOException; public class Provider2 extends AsynchronousChannelProvider { public Provider2() { diff --git a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh deleted file mode 100644 index b10fcb39eb7..00000000000 --- a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @summary Unit test for java.nio.channels.spi.AsynchronousChannelProvider -# @build Provider1 Provider2 CheckProvider -# @run shell custom_provider.sh - -# if TESTJAVA isn't set then we assume an interactive run. - -if [ -z "$TESTJAVA" ]; then - TESTSRC=. - TESTCLASSES=. - JAVA=java -else - JAVA="${TESTJAVA}/bin/java" -fi - -OS=`uname -s` -case "$OS" in - Windows_* | CYGWIN* ) - CLASSPATH="${TESTCLASSES};${TESTSRC}" - ;; - * ) - CLASSPATH=${TESTCLASSES}:${TESTSRC} - ;; -esac -export CLASSPATH - -failures=0 - -go() { - echo '' - $JAVA ${TESTVMOPTS} $1 $2 $3 2>&1 - if [ $? != 0 ]; then failures=`expr $failures + 1`; fi -} - -# Run the tests - -go CheckProvider Provider1 -go -Djava.nio.channels.spi.AsynchronousChannelProvider=Provider2 CheckProvider \ - Provider2 - -# -# Results -# -echo '' -if [ $failures -gt 0 ]; - then echo "$failures test(s) failed"; - else echo "All test(s) passed"; fi -exit $failures From b0f734047c8634e08078402ff0f43ac07ff3d688 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Mon, 19 Jun 2017 09:41:59 +0800 Subject: [PATCH 46/59] 8181395: Refactor locale related shell tests Charset/default.sh and CheckSJISMappingProp.sh to java Reviewed-by: alanb --- jdk/test/TEST.groups | 1 - .../charset/Charset/DefaultCharsetTest.java | 110 ++++++++++++++++++ jdk/test/java/nio/charset/Charset/default.sh | 97 --------------- .../charset/coders/CheckSJISMappingProp.sh | 76 ------------ .../charset/coders/SJISMappingPropTest.java | 91 +++++++++++++++ .../java/nio/charset/coders/SJISPropTest.java | 7 +- 6 files changed, 203 insertions(+), 179 deletions(-) create mode 100644 jdk/test/java/nio/charset/Charset/DefaultCharsetTest.java delete mode 100644 jdk/test/java/nio/charset/Charset/default.sh delete mode 100644 jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh create mode 100644 jdk/test/java/nio/charset/coders/SJISMappingPropTest.java diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 11da7640e98..706824d5cb0 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -554,7 +554,6 @@ needs_charsets = \ java/nio/charset/Charset/NIOCharsetAvailabilityTest.java \ java/nio/charset/Charset/RegisteredCharsets.java \ java/nio/charset/CharsetEncoder/Flush.java \ - java/nio/charset/coders/CheckSJISMappingProp.sh \ java/nio/charset/coders/ResetISO2022JP.java \ java/util/Locale/InternationalBAT.java \ java/util/Locale/LocaleProviders.sh \ diff --git a/jdk/test/java/nio/charset/Charset/DefaultCharsetTest.java b/jdk/test/java/nio/charset/Charset/DefaultCharsetTest.java new file mode 100644 index 00000000000..e7a6197888e --- /dev/null +++ b/jdk/test/java/nio/charset/Charset/DefaultCharsetTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 4772857 + * @summary Unit test for Charset.defaultCharset + * @requires (os.family == "linux" | os.family == "solaris") + * @library /test/lib + * @build jdk.test.lib.Utils + * jdk.test.lib.Asserts + * jdk.test.lib.JDKToolFinder + * jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Platform + * jdk.test.lib.process.* + * Default + * @run testng DefaultCharsetTest + */ + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import jdk.test.lib.Platform; +import jdk.test.lib.process.ProcessTools; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertTrue; + +public class DefaultCharsetTest { + + private static final ProcessBuilder pb + = ProcessTools.createJavaProcessBuilder(true, Default.class.getName()); + private static final Map env = pb.environment(); + private static String UNSUPPORTED = null; + + @BeforeClass + public static void checkSupports() throws Exception { + UNSUPPORTED = runWithLocale("nonexist"); + } + + @DataProvider + public static Iterator locales() { + List data = new ArrayList<>(); + data.add(new String[]{"en_US", "iso-8859-1"}); + data.add(new String[]{"ja_JP.utf8", "utf-8"}); + data.add(new String[]{"tr_TR", "iso-8859-9"}); + data.add(new String[]{"C", "us-ascii"}); + if (Platform.isLinux()) { + data.add(new String[]{"ja_JP", "x-euc-jp-linux"}); + data.add(new String[]{"ja_JP.eucjp", "x-euc-jp-linux"}); + data.add(new String[]{"ja_JP.ujis", "x-euc-jp-linux"}); + data.add(new String[]{"ja_JP.utf8", "utf-8"}); + } + if (Platform.isSolaris()) { + data.add(new String[]{"ja", "x-eucjp-open"}); + data.add(new String[]{"ja_JP.eucJP", "x-eucjp-open"}); + data.add(new String[]{"ja_JP.PCK", "x-PCK"}); + data.add(new String[]{"ja_JP.UTF-8", "utf-8"}); + } + return data.iterator(); + } + + @Test(dataProvider = "locales") + public void testDefaultCharset(String locale, String expectedCharset) + throws Exception { + String actual = runWithLocale(locale); + if (UNSUPPORTED.equals(actual)) { + System.out.println(locale + ": Locale not supported, skipping..."); + } else { + assertTrue(actual.equalsIgnoreCase(expectedCharset), + String.format("LC_ALL = %s, got defaultCharset = %s, " + + "NOT as expected %s", + locale, actual, expectedCharset)); + } + } + + private static String runWithLocale(String locale) throws Exception { + env.remove("LC_ALL"); + env.put("LC_ALL", locale); + return ProcessTools.executeProcess(pb) + .shouldHaveExitValue(0) + .getStdout() + .replace(System.lineSeparator(), ""); + } +} diff --git a/jdk/test/java/nio/charset/Charset/default.sh b/jdk/test/java/nio/charset/Charset/default.sh deleted file mode 100644 index c93aa71bdef..00000000000 --- a/jdk/test/java/nio/charset/Charset/default.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4772857 -# @summary Unit test for Charset.defaultCharset -# -# @build Default -# @run shell default.sh -# - -# Command-line usage: sh default.sh [/path/to/build] - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA=$1; shift - TESTSRC=`pwd` - TESTCLASSES=`pwd` -fi - -s="`uname -s`" -if [ "$s" != Linux -a "$s" != SunOS ]; then - echo "$s: locale command not supported on this system, skipping..." - exit 0 -fi - -JAVA=$TESTJAVA/bin/java - -tolower() { - echo "$1" | tr '[A-Z]' '[a-z]' -} - -go() { - - L="$1" - shift - if [ "x`locale -a | grep \^$L\$`" != "x$L" ]; then - echo "$L: Locale not supported, skipping..." - return - fi - - ecs="$1"; shift - - echo -n "$L: " - cs="`LC_ALL=$L $JAVA ${TESTVMOPTS} -cp $TESTCLASSES Default`" - if [ $? != 0 ]; then - exit 1 - elif [ "`tolower $cs`" != "`tolower $ecs`" ]; then - echo "$cs, expected $ecs -- ERROR" - exit 1 - else - echo "$cs, as expected" - fi - -} - -go en_US iso-8859-1 -go ja_JP.utf8 utf-8 -go tr_TR iso-8859-9 -go C us-ascii - -if [ "$s" = Linux ]; then - go ja_JP x-euc-jp-linux - go ja_JP.eucjp x-euc-jp-linux - go ja_JP.ujis x-euc-jp-linux - go ja_JP.utf8 utf-8 -fi - -# Solaris -if [ "$s" = SunOS ]; then - go ja x-eucjp-open - go ja_JP.eucJP x-eucjp-open - go ja_JP.PCK x-PCK - go ja_JP.UTF-8 utf-8 -fi diff --git a/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh b/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh deleted file mode 100644 index 5c14e7392ec..00000000000 --- a/jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @summary Verify that sun.nio.cs.map property interpreted in ja multibyte locales -# @bug 4879123 -# @build SJISPropTest -# -# @run shell/timeout=300 CheckSJISMappingProp.sh - -# set platform-dependent variables - -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin | AIX ) ;; - # Skip locale test for Windows - Windows* | CYGWIN* ) - echo "Passed"; exit 0 ;; - * ) echo "Unrecognized system!" ; exit 1 ;; -esac - -expectPass() { - if [ $1 -eq 0 ] - then echo "--- passed as expected" - else - echo "--- failed" - exit $1 - fi -} - - -JAVA="${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES}" -runTest() { - echo "Testing:" ${1} - LC_ALL="$1" ; export LC_ALL - locale - # Firstly, test with property set - # (shift_jis should map to windows-31J charset) - ${JAVA} -Dsun.nio.cs.map="Windows-31J/Shift_JIS" SJISPropTest MS932 - expectPass $? - - # Next, test without property set - "shift_jis" follows IANA conventions - # and should map to the sun.nio.cs.ext.Shift_JIS charset - ${JAVA} SJISPropTest Shift_JIS - expectPass $? -} - -# Run the test in the common Solaris/Linux/Mac OS locales -# Tests will simply run in current locale if locale isn't supported -# on the test machine/platform - -for i in "ja" "ja_JP.PCK" "ja_JP.eucJP" ; do - runTest ${i} -done diff --git a/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java b/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java new file mode 100644 index 00000000000..dadca0622d7 --- /dev/null +++ b/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 4879123 + * @summary Verify that sun.nio.cs.map property interpreted in ja multibyte locales + * @requires (os.family != "windows") + * @library /test/lib + * @build jdk.test.lib.Utils + * jdk.test.lib.Asserts + * jdk.test.lib.JDKToolFinder + * jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Platform + * jdk.test.lib.process.* + * SJISPropTest + * @run testng SJISMappingPropTest + */ + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +public class SJISMappingPropTest { + + @DataProvider + public static Iterator locales() { + List data = new ArrayList<>(); + data.add(new String[]{"ja"}); + data.add(new String[]{"ja_JP.PCK"}); + data.add(new String[]{"ja_JP.eucJP"}); + return data.iterator(); + } + + @Test(dataProvider = "locales") + public void testWithProperty(String locale) throws Exception { + // with property set, shift_jis should map to windows-31J charset + runTest(locale, + "-Dsun.nio.cs.map=Windows-31J/Shift_JIS", + SJISPropTest.class.getName(), + "MS932"); + } + + @Test(dataProvider = "locales") + public void testWithoutProperty(String locale) throws Exception { + // without property set - "shift_jis" follows IANA conventions + // and should map to the sun.nio.cs.ext.Shift_JIS charset + runTest(locale, + SJISPropTest.class.getName(), + "Shift_JIS"); + } + + private void runTest(String locale, String... cmd) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd); + Map env = pb.environment(); + env.put("LC_ALL", locale); + OutputAnalyzer out = ProcessTools.executeProcess(pb) + .outputTo(System.out) + .errorTo(System.err); + assertEquals(out.getExitValue(), 0); + } +} diff --git a/jdk/test/java/nio/charset/coders/SJISPropTest.java b/jdk/test/java/nio/charset/coders/SJISPropTest.java index 135577e96fa..3a339a19d70 100644 --- a/jdk/test/java/nio/charset/coders/SJISPropTest.java +++ b/jdk/test/java/nio/charset/coders/SJISPropTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,12 +22,9 @@ */ /* - * - * - * Regression test class run by CheckSJISMappingProp.sh to verify + * Regression test class run by SJISMappingPropTest.java to verify * that sun.nio.cs.map property is correctly interpreted in * multibyte Japanese locales - * */ public class SJISPropTest { From 54b3488ad9bb9f4c03f44731f5c6638028fcc1ec Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Sun, 18 Jun 2017 18:43:24 -0700 Subject: [PATCH 47/59] 8181912: Refactor locale related shell test test/java/io/File/MacPathTest.sh to java test Reviewed-by: alanb, naoto, psandoz, xiaofeya --- jdk/test/java/io/File/MacPath.java | 47 ++++++++++++++++++++++++++ jdk/test/java/io/File/MacPathTest.java | 16 +++------ jdk/test/java/io/File/MacPathTest.sh | 39 --------------------- 3 files changed, 52 insertions(+), 50 deletions(-) create mode 100644 jdk/test/java/io/File/MacPath.java delete mode 100644 jdk/test/java/io/File/MacPathTest.sh diff --git a/jdk/test/java/io/File/MacPath.java b/jdk/test/java/io/File/MacPath.java new file mode 100644 index 00000000000..08ffc83534b --- /dev/null +++ b/jdk/test/java/io/File/MacPath.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 7130915 + * @summary Tests file path with nfc/nfd forms on MacOSX + * @requires (os.family == "mac") + * @library /test/lib + * @build jdk.test.lib.Asserts jdk.test.lib.process.ProcessTools MacPathTest + * @run main MacPath + */ + +import java.util.Map; + +import jdk.test.lib.Asserts; +import jdk.test.lib.process.ProcessTools; + +public class MacPath { + public static void main(String args[]) throws Exception { + final ProcessBuilder pb = + ProcessTools.createJavaProcessBuilder(true, MacPathTest.class.getName()); + final Map env = pb.environment(); + env.put("LC_ALL", "en_US.UTF-8"); + Process p = ProcessTools.startProcess("Mac Path Test", pb); + Asserts.assertTrue(p.waitFor() == 0, "test failed!"); + } +} diff --git a/jdk/test/java/io/File/MacPathTest.java b/jdk/test/java/io/File/MacPathTest.java index 9b310c18dfe..c5b50f7e2cf 100644 --- a/jdk/test/java/io/File/MacPathTest.java +++ b/jdk/test/java/io/File/MacPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,16 +21,10 @@ * questions. */ -/* @test - * @bug 7130915 - * @summary Tests file path with nfc/nfd forms on MacOSX - * @build MacPathTest - * @run shell MacPathTest.sh - */ - -import java.io.*; -import java.text.*; -import java.util.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.Normalizer; public class MacPathTest { diff --git a/jdk/test/java/io/File/MacPathTest.sh b/jdk/test/java/io/File/MacPathTest.sh deleted file mode 100644 index ecaa5e08881..00000000000 --- a/jdk/test/java/io/File/MacPathTest.sh +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -OS=`uname -s` -case "$OS" in - Darwin ) ;; - * ) - exit 0 - ;; -esac - -if [ "x$TESTJAVA" = x ]; then - TESTJAVA=$1; shift - TESTCLASSES=. -fi - -export LC_ALL=en_US.UTF-8 ;${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} MacPathTest From 06a254a8f572e9cb629800159ce775bdb60d90b4 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Mon, 19 Jun 2017 15:48:42 +0800 Subject: [PATCH 48/59] 8182421: Add @modules to java/nio/charset/coders/SJISMappingPropTest.java Reviewed-by: alanb --- jdk/test/java/nio/charset/coders/SJISMappingPropTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java b/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java index dadca0622d7..9c26bc27081 100644 --- a/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java +++ b/jdk/test/java/nio/charset/coders/SJISMappingPropTest.java @@ -26,6 +26,7 @@ * @bug 4879123 * @summary Verify that sun.nio.cs.map property interpreted in ja multibyte locales * @requires (os.family != "windows") + * @modules jdk.charsets * @library /test/lib * @build jdk.test.lib.Utils * jdk.test.lib.Asserts From 81a4918f1669ca2ead7b251194bfa09ef283e132 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 19 Jun 2017 09:29:11 +0200 Subject: [PATCH 49/59] 8181147: JNI_GetStringPlatformChars should have a fast path for UTF-8 8182451: Inconsistency between String.getBytes("Cp1252") and JNU_GetStringPlatformChars Reviewed-by: martin, erikj, sherman, chegar, mikael --- jdk/make/test/JtregNative.gmk | 10 + .../share/classes/java/lang/String.java | 5 +- .../java.base/share/native/libjava/jni_util.c | 285 +++++++++++++----- .../java.base/share/native/libjava/jni_util.h | 3 +- .../nativeEncoding/StringPlatformChars.java | 91 ++++++ .../nativeEncoding/libstringPlatformChars.c | 76 +++++ 6 files changed, 384 insertions(+), 86 deletions(-) create mode 100644 jdk/test/java/lang/String/nativeEncoding/StringPlatformChars.java create mode 100644 jdk/test/java/lang/String/nativeEncoding/libstringPlatformChars.c diff --git a/jdk/make/test/JtregNative.gmk b/jdk/make/test/JtregNative.gmk index 05a81e8cb5a..3e2cc51ef6a 100644 --- a/jdk/make/test/JtregNative.gmk +++ b/jdk/make/test/JtregNative.gmk @@ -42,12 +42,22 @@ include TestFilesCompilation.gmk # Add more directories here when needed. BUILD_JDK_JTREG_NATIVE_SRC := \ $(JDK_TOPDIR)/test/native_sanity \ + $(JDK_TOPDIR)/test/java/lang/String/nativeEncoding \ # BUILD_JDK_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/jdk/jtreg/native BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg +ifeq ($(OPENJDK_TARGET_OS), windows) + WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib + BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := $(WIN_LIB_JAVA) +else ifeq ($(OPENJDK_TARGET_OS), solaris) + BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava -lc +else + BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava +endif + $(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_LIBRARIES, \ TYPE := LIBRARY, \ SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \ diff --git a/jdk/src/java.base/share/classes/java/lang/String.java b/jdk/src/java.base/share/classes/java/lang/String.java index 7191669709e..6d06764c1b4 100644 --- a/jdk/src/java.base/share/classes/java/lang/String.java +++ b/jdk/src/java.base/share/classes/java/lang/String.java @@ -27,6 +27,7 @@ package java.lang; import java.io.ObjectStreamField; import java.io.UnsupportedEncodingException; +import java.lang.annotation.Native; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; @@ -3063,8 +3064,8 @@ public final class String return COMPACT_STRINGS && coder == LATIN1; } - static final byte LATIN1 = 0; - static final byte UTF16 = 1; + @Native static final byte LATIN1 = 0; + @Native static final byte UTF16 = 1; /* * StringIndexOutOfBoundsException if {@code index} is diff --git a/jdk/src/java.base/share/native/libjava/jni_util.c b/jdk/src/java.base/share/native/libjava/jni_util.c index 25888cc4655..500431bbcec 100644 --- a/jdk/src/java.base/share/native/libjava/jni_util.c +++ b/jdk/src/java.base/share/native/libjava/jni_util.c @@ -29,6 +29,7 @@ #include "jvm.h" #include "jni.h" #include "jni_util.h" +#include "java_lang_String.h" /* Due to a bug in the win32 C runtime library strings * such as "z:" need to be appended with a "." so we @@ -442,16 +443,18 @@ JNU_NewObjectByName(JNIEnv *env, const char *class_name, return obj; } -/* Optimized for char set ISO_8559_1 */ +/* Optimized for charset ISO_8559_1 */ static jstring -newString8859_1(JNIEnv *env, const char *str) +newSizedString8859_1(JNIEnv *env, const char *str, const int len) { - int len = (int)strlen(str); jchar buf[512]; jchar *str1; jstring result; int i; + if ((*env)->EnsureLocalCapacity(env, 1) < 0) + return NULL; + if (len > 512) { str1 = (jchar *)malloc(len * sizeof(jchar)); if (str1 == 0) { @@ -469,6 +472,13 @@ newString8859_1(JNIEnv *env, const char *str) return result; } +static jstring +newString8859_1(JNIEnv *env, const char *str) +{ + int len = (int)strlen(str); + return newSizedString8859_1(env, str, len); +} + static const char* getString8859_1Chars(JNIEnv *env, jstring jstr) { @@ -501,7 +511,7 @@ getString8859_1Chars(JNIEnv *env, jstring jstr) } -/* Optimized for char set ISO646-US (us-ascii) */ +/* Optimized for charset ISO646-US (us-ascii) */ static jstring newString646_US(JNIEnv *env, const char *str) { @@ -573,7 +583,7 @@ static int cp1252c1chars[32] = { 0x02Dc,0x2122,0x0161,0x203A,0x0153,0xFFFD,0x017E,0x0178 }; -/* Optimized for char set Cp1252 */ +/* Optimized for charset Cp1252 */ static jstring newStringCp1252(JNIEnv *env, const char *str) { @@ -582,6 +592,10 @@ newStringCp1252(JNIEnv *env, const char *str) jchar *str1; jstring result; int i; + + if ((*env)->EnsureLocalCapacity(env, 1) < 0) + return NULL; + if (len > 512) { str1 = (jchar *)malloc(len * sizeof(jchar)); if (str1 == 0) { @@ -625,9 +639,13 @@ getStringCp1252Chars(JNIEnv *env, jstring jstr) for (i=0; i= 0x80) && (c <= 0x9f)) { + result[i] = '?'; + } else { + result[i] = (char)c; + } + } else switch(c) { case 0x20AC: result[i] = (char)0x80; break; case 0x201A: result[i] = (char)0x82; break; case 0x0192: result[i] = (char)0x83; break; @@ -671,8 +689,89 @@ static jstring jnuEncoding = NULL; static jmethodID String_init_ID; /* String(byte[], enc) */ static jmethodID String_getBytes_ID; /* String.getBytes(enc) */ -int getFastEncoding() { - return fastEncoding; +/* Cached field IDs */ +static jfieldID String_coder_ID; /* String.coder */ +static jfieldID String_value_ID; /* String.value */ + +static jboolean isJNUEncodingSupported = JNI_FALSE; +static jboolean jnuEncodingSupported(JNIEnv *env) { + jboolean exe; + if (isJNUEncodingSupported == JNI_TRUE) { + return JNI_TRUE; + } + isJNUEncodingSupported = (jboolean) JNU_CallStaticMethodByName ( + env, &exe, + "java/nio/charset/Charset", + "isSupported", + "(Ljava/lang/String;)Z", + jnuEncoding).z; + return isJNUEncodingSupported; +} + +/* Create a new string by converting str to a heap-allocated byte array and + * calling the appropriate String constructor. + */ +static jstring +newSizedStringJava(JNIEnv *env, const char *str, const int len) +{ + jstring result = NULL; + jbyteArray bytes = 0; + + if ((*env)->EnsureLocalCapacity(env, 2) < 0) + return NULL; + + bytes = (*env)->NewByteArray(env, len); + if (bytes != NULL) { + jclass strClazz = JNU_ClassString(env); + CHECK_NULL_RETURN(strClazz, 0); + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte *)str); + if (jnuEncodingSupported(env)) { + result = (*env)->NewObject(env, strClazz, + String_init_ID, bytes, jnuEncoding); + } else { + /*If the encoding specified in sun.jnu.encoding is not endorsed + by "Charset.isSupported" we have to fall back to use String(byte[]) + explicitly here without specifying the encoding name, in which the + StringCoding class will pickup the iso-8859-1 as the fallback + converter for us. + */ + jmethodID mid = (*env)->GetMethodID(env, strClazz, + "", "([B)V"); + if (mid != NULL) { + result = (*env)->NewObject(env, strClazz, mid, bytes); + } + } + (*env)->DeleteLocalRef(env, bytes); + return result; + } + return NULL; +} + +static jstring +newStringJava(JNIEnv *env, const char *str) +{ + int len = (int)strlen(str); + return newSizedStringJava(env, str, len); +} + +/* Optimized for charset UTF-8 */ +static jstring +newStringUTF8(JNIEnv *env, const char *str) +{ + int len; + const unsigned char *p; + unsigned char asciiCheck; + for (asciiCheck = 0, p = (const unsigned char*)str; *p != '\0'; p++) { + asciiCheck |= *p; + } + len = (int)((const char*)p - str); + + if (asciiCheck < 0x80) { + // ascii fast-path + return newSizedString8859_1(env, str, len); + } + + return newSizedStringJava(env, str, len); } /* Initialize the fast encoding. If the "sun.jnu.encoding" property @@ -718,17 +817,20 @@ initializeEncoding(JNIEnv *env) if ((strcmp(encname, "8859_1") == 0) || (strcmp(encname, "ISO8859-1") == 0) || (strcmp(encname, "ISO8859_1") == 0) || - (strcmp(encname, "ISO-8859-1") == 0)) + (strcmp(encname, "ISO-8859-1") == 0)) { fastEncoding = FAST_8859_1; - else if (strcmp(encname, "ISO646-US") == 0) + } else if (strcmp(encname, "UTF-8") == 0) { + fastEncoding = FAST_UTF_8; + jnuEncoding = (jstring)(*env)->NewGlobalRef(env, enc); + } else if (strcmp(encname, "ISO646-US") == 0) { fastEncoding = FAST_646_US; - else if (strcmp(encname, "Cp1252") == 0 || + } else if (strcmp(encname, "Cp1252") == 0 || /* This is a temporary fix until we move */ /* to wide character versions of all Windows */ /* calls. */ - strcmp(encname, "utf-16le") == 0) + strcmp(encname, "utf-16le") == 0) { fastEncoding = FAST_CP1252; - else { + } else { fastEncoding = NO_FAST_ENCODING; jnuEncoding = (jstring)(*env)->NewGlobalRef(env, enc); } @@ -750,24 +852,10 @@ initializeEncoding(JNIEnv *env) CHECK_NULL(String_getBytes_ID); String_init_ID = (*env)->GetMethodID(env, strClazz, "", "([BLjava/lang/String;)V"); + String_coder_ID = (*env)->GetFieldID(env, strClazz, "coder", "B"); + String_value_ID = (*env)->GetFieldID(env, strClazz, "value", "[B"); } -static jboolean isJNUEncodingSupported = JNI_FALSE; -static jboolean jnuEncodingSupported(JNIEnv *env) { - jboolean exe; - if (isJNUEncodingSupported == JNI_TRUE) { - return JNI_TRUE; - } - isJNUEncodingSupported = (jboolean) JNU_CallStaticMethodByName ( - env, &exe, - "java/nio/charset/Charset", - "isSupported", - "(Ljava/lang/String;)Z", - jnuEncoding).z; - return isJNUEncodingSupported; -} - - JNIEXPORT jstring NewStringPlatform(JNIEnv *env, const char *str) { @@ -777,10 +865,6 @@ NewStringPlatform(JNIEnv *env, const char *str) JNIEXPORT jstring JNICALL JNU_NewStringPlatform(JNIEnv *env, const char *str) { - jstring result = NULL; - jbyteArray hab = 0; - int len; - if (fastEncoding == NO_ENCODING_YET) { initializeEncoding(env); JNU_CHECK_EXCEPTION_RETURN(env, NULL); @@ -792,36 +876,9 @@ JNU_NewStringPlatform(JNIEnv *env, const char *str) return newString646_US(env, str); if (fastEncoding == FAST_CP1252) return newStringCp1252(env, str); - - if ((*env)->EnsureLocalCapacity(env, 2) < 0) - return NULL; - - len = (int)strlen(str); - hab = (*env)->NewByteArray(env, len); - if (hab != 0) { - jclass strClazz = JNU_ClassString(env); - CHECK_NULL_RETURN(strClazz, 0); - (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str); - if (jnuEncodingSupported(env)) { - result = (*env)->NewObject(env, strClazz, - String_init_ID, hab, jnuEncoding); - } else { - /*If the encoding specified in sun.jnu.encoding is not endorsed - by "Charset.isSupported" we have to fall back to use String(byte[]) - explicitly here without specifying the encoding name, in which the - StringCoding class will pickup the iso-8859-1 as the fallback - converter for us. - */ - jmethodID mid = (*env)->GetMethodID(env, strClazz, - "", "([B)V"); - if (mid != NULL) { - result = (*env)->NewObject(env, strClazz, mid, hab); - } - } - (*env)->DeleteLocalRef(env, hab); - return result; - } - return NULL; + if (fastEncoding == FAST_UTF_8) + return newStringUTF8(env, str); + return newStringJava(env, str); } JNIEXPORT const char * @@ -830,27 +887,10 @@ GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) return JNU_GetStringPlatformChars(env, jstr, isCopy); } -JNIEXPORT const char * JNICALL -JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) -{ +static const char* getStringBytes(JNIEnv *env, jstring jstr) { char *result = NULL; jbyteArray hab = 0; - if (isCopy) - *isCopy = JNI_TRUE; - - if (fastEncoding == NO_ENCODING_YET) { - initializeEncoding(env); - JNU_CHECK_EXCEPTION_RETURN(env, 0); - } - - if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) - return getString8859_1Chars(env, jstr); - if (fastEncoding == FAST_646_US) - return getString646_USChars(env, jstr); - if (fastEncoding == FAST_CP1252) - return getStringCp1252Chars(env, jstr); - if ((*env)->EnsureLocalCapacity(env, 2) < 0) return 0; @@ -883,6 +923,85 @@ JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) return result; } +static const char* +getStringUTF8(JNIEnv *env, jstring jstr) +{ + int i; + char *result; + jbyteArray value; + jint len; + jbyte *str; + jint rlen; + int ri; + jbyte coder = (*env)->GetByteField(env, jstr, String_coder_ID); + if (coder != java_lang_String_LATIN1) { + return getStringBytes(env, jstr); + } + if ((*env)->EnsureLocalCapacity(env, 2) < 0) { + return NULL; + } + value = (*env)->GetObjectField(env, jstr, String_value_ID); + if (value == NULL) + return NULL; + len = (*env)->GetArrayLength(env, value); + str = (*env)->GetPrimitiveArrayCritical(env, value, NULL); + if (str == NULL) { + return NULL; + } + + rlen = len; + // we need two bytes for each latin-1 char above 127 (negative jbytes) + for (i = 0; i < len; i++) { + if (str[i] < 0) { + rlen++; + } + } + + result = MALLOC_MIN4(rlen); + if (result == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, value, str, 0); + JNU_ThrowOutOfMemoryError(env, 0); + return NULL; + } + + for (ri = 0, i = 0; i < len; i++) { + jbyte c = str[i]; + if (c < 0) { + result[ri++] = (char)(0xc0 | ((c & 0xff) >> 6)); + result[ri++] = (char)(0x80 | (c & 0x3f)); + } else { + result[ri++] = c; + } + } + (*env)->ReleasePrimitiveArrayCritical(env, value, str, 0); + result[rlen] = '\0'; + return result; +} + +JNIEXPORT const char * JNICALL +JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) +{ + + if (isCopy) + *isCopy = JNI_TRUE; + + if (fastEncoding == NO_ENCODING_YET) { + initializeEncoding(env); + JNU_CHECK_EXCEPTION_RETURN(env, 0); + } + + if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) + return getString8859_1Chars(env, jstr); + if (fastEncoding == FAST_646_US) + return getString646_USChars(env, jstr); + if (fastEncoding == FAST_CP1252) + return getStringCp1252Chars(env, jstr); + if (fastEncoding == FAST_UTF_8) + return getStringUTF8(env, jstr); + else + return getStringBytes(env, jstr); +} + JNIEXPORT void JNICALL JNU_ReleaseStringPlatformChars(JNIEnv *env, jstring jstr, const char *str) { diff --git a/jdk/src/java.base/share/native/libjava/jni_util.h b/jdk/src/java.base/share/native/libjava/jni_util.h index 960a225efbb..b1f9b1d6b97 100644 --- a/jdk/src/java.base/share/native/libjava/jni_util.h +++ b/jdk/src/java.base/share/native/libjava/jni_util.h @@ -382,7 +382,8 @@ enum { NO_FAST_ENCODING, /* Platform encoding is not fast */ FAST_8859_1, /* ISO-8859-1 */ FAST_CP1252, /* MS-DOS Cp1252 */ - FAST_646_US /* US-ASCII : ISO646-US */ + FAST_646_US, /* US-ASCII : ISO646-US */ + FAST_UTF_8 }; int getFastEncoding(); diff --git a/jdk/test/java/lang/String/nativeEncoding/StringPlatformChars.java b/jdk/test/java/lang/String/nativeEncoding/StringPlatformChars.java new file mode 100644 index 00000000000..db4c407a17a --- /dev/null +++ b/jdk/test/java/lang/String/nativeEncoding/StringPlatformChars.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + * @test + * @run main/othervm/native -Xcheck:jni StringPlatformChars + */ +import java.util.Arrays; + +public class StringPlatformChars { + + private static final String JNU_ENCODING = System.getProperty("sun.jnu.encoding"); + + public static void main(String... args) throws Exception { + System.out.println("sun.jnu.encoding: " + JNU_ENCODING); + System.loadLibrary("stringPlatformChars"); + + // Test varying lengths, provoking different allocation paths + StringBuilder unicodeSb = new StringBuilder(); + StringBuilder asciiSb = new StringBuilder(); + StringBuilder latinSb = new StringBuilder(); + + for (int i = 0; i < 2000; i++) { + unicodeSb.append('\uFEFE'); + testString(unicodeSb.toString()); + + asciiSb.append('x'); + testString(asciiSb.toString()); + + latinSb.append('\u00FE'); + testString(latinSb.toString()); + + testString(latinSb.toString() + asciiSb.toString() + unicodeSb.toString()); + } + + // Exhaustively test simple Strings made up of all possible chars: + for (char c = '\u0001'; c < Character.MAX_VALUE; c++) { + testString(String.valueOf(c)); + } + // Special case: \u0000 is treated as end-of-string in the native code, + // so strings with it should be truncated: + if (getBytes("\u0000abcdef").length != 0 || + getBytes("a\u0000bcdef").length != 1) { + System.out.println("Mismatching values for strings including \\u0000"); + throw new AssertionError(); + } + } + + private static void testString(String s) throws Exception { + byte[] nativeBytes = getBytes(s); + byte[] stringBytes = s.getBytes(JNU_ENCODING); + + if (!Arrays.equals(nativeBytes, stringBytes)) { + System.out.println("Mismatching values for: '" + s + "' " + Arrays.toString(s.chars().toArray())); + System.out.println("Native: " + Arrays.toString(nativeBytes)); + System.out.println("String: " + Arrays.toString(stringBytes)); + throw new AssertionError(s); + } + + String javaNewS = new String(nativeBytes, JNU_ENCODING); + String nativeNewS = newString(nativeBytes); + if (!javaNewS.equals(nativeNewS)) { + System.out.println("New string via native doesn't match via java: '" + javaNewS + "' and '" + nativeNewS + "'"); + throw new AssertionError(s); + } + } + + static native byte[] getBytes(String string); + + static native String newString(byte[] bytes); +} diff --git a/jdk/test/java/lang/String/nativeEncoding/libstringPlatformChars.c b/jdk/test/java/lang/String/nativeEncoding/libstringPlatformChars.c new file mode 100644 index 00000000000..99dbd92d92e --- /dev/null +++ b/jdk/test/java/lang/String/nativeEncoding/libstringPlatformChars.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015, 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. + */ + +#include +#include + +#include "jni.h" +#include "jni_util.h" + +JNIEXPORT jbyteArray JNICALL +Java_StringPlatformChars_getBytes(JNIEnv *env, jclass unused, jstring value) +{ + const char* str; + int len; + jbyteArray bytes = NULL; + + str = JNU_GetStringPlatformChars(env, value, NULL); + if (str == NULL) { + return NULL; + } + len = (int)strlen(str); + bytes = (*env)->NewByteArray(env, len); + if (bytes != 0) { + jclass strClazz = JNU_ClassString(env); + if (strClazz == NULL) { + return NULL; + } + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte *)str); + + return bytes; + } + return NULL; +} + +JNIEXPORT jstring JNICALL +Java_StringPlatformChars_newString(JNIEnv *env, jclass unused, jbyteArray bytes) +{ + char* str; + int len = (*env)->GetArrayLength(env, bytes); + int i; + jbyte* jbytes; + + str = (char*)malloc(len + 1); + jbytes = (*env)->GetPrimitiveArrayCritical(env, bytes, NULL); + if (jbytes == NULL) { + return NULL; + } + for (i = 0; i < len; i++) { + str[i] = (char)jbytes[i]; + } + str[len] = '\0'; + (*env)->ReleasePrimitiveArrayCritical(env, bytes, (void*)jbytes, 0); + + return JNU_NewStringPlatform(env, str); +} + From 9ba467589878fa3db16080ac46b509b209120570 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 19 Jun 2017 10:32:13 +0200 Subject: [PATCH 50/59] 8181147: JNU_GetStringPlatformChars should have a fast path for UTF-8 Reviewed-by: martin, erikj, sherman, chegar, mikael --- make/Main.gmk | 2 +- make/jprt.properties | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/make/Main.gmk b/make/Main.gmk index 23e5b086fcf..c378c2925a5 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -843,7 +843,7 @@ else build-test-hotspot-jtreg-native: buildtools-jdk \ hotspot-$(JVM_VARIANT_MAIN)-libs - build-test-jdk-jtreg-native: buildtools-jdk + build-test-jdk-jtreg-native: buildtools-jdk java.base-libs test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native diff --git a/make/jprt.properties b/make/jprt.properties index 173a445205e..ee03ccd8749 100644 --- a/make/jprt.properties +++ b/make/jprt.properties @@ -174,7 +174,13 @@ jprt.build.targets=${my.jprt.testsetHasCustomBuildTargets ? \ # Select test targets - jprt default for jprt.test.set is "default" jprt.test.targets=${my.test.targets.${jprt.test.set}} jprt.make.rule.test.targets=${my.make.rule.test.targets.${jprt.test.set}} -jprt.test.bundle.targets=${my.jprt.test.bundle.targets.${jprt.test.set}} + +# Not all test targets need the test image +jprt.test.bundle.targets=\ + ${my.make.rule.test.targets.hotspot.reg}, \ + ${my.make.rule.test.targets.hotspot.gtest} \ + ${my.make.rule.test.targets.nativesanity} \ + ${my.test.target.set:TESTNAME=jdk_lang} # 7155453: Work-around to prevent popups on OSX from blocking test completion # but the work-around is added to all platforms to be consistent @@ -473,20 +479,11 @@ my.make.rule.test.targets.hotspot= \ ${my.make.rule.test.targets.hotspot.reg} \ ${my.make.rule.test.targets.hotspot.other} -# Install the test bundle for the testset hotspot jtreg tests -# (but not for the other Makefile based tests) -my.jprt.test.bundle.targets.hotspot= \ - ${my.make.rule.test.targets.hotspot.reg}, \ - ${my.make.rule.test.targets.hotspot.gtest} - # Native jdk and hotspot test targets (testset=nativesanity) my.make.rule.test.targets.nativesanity= \ ${my.test.target.set:TESTNAME=jdk_native_sanity}, \ ${my.test.target.set:TESTNAME=hotspot_native_sanity} -# Install the test bundle for the nativesanity jtreg tests -my.jprt.test.bundle.targets.nativesanity=${my.make.rule.test.targets.nativesanity} - ################################################################################ # Testset buildinfra my.build.flavors.buildinfra = \ From b6e3d339276a65f6bd55eba5fc8375032826d7f9 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Mon, 19 Jun 2017 11:52:01 +0200 Subject: [PATCH 51/59] 8181419: Race in jdwp invoker handling may lead to crashes or invalid results Reviewed-by: sspitsyn, sgehwolf, clanger --- .../share/native/libjdwp/invoker.c | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c index c048c759d19..d3d533b14a5 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c @@ -211,30 +211,6 @@ createGlobalRefs(JNIEnv *env, InvokeRequest *request) return error; } -/* - * Delete saved global references - if any - for: - * - a potentially thrown Exception - * - a returned refernce/array value - * See invoker_doInvoke() and invoke* methods where global references - * are being saved. - */ -static void -deletePotentiallySavedGlobalRefs(JNIEnv *env, InvokeRequest *request) -{ - /* Delete potentially saved return value */ - if ((request->invokeType == INVOKE_CONSTRUCTOR) || - (returnTypeTag(request->methodSignature) == JDWP_TAG(OBJECT)) || - (returnTypeTag(request->methodSignature) == JDWP_TAG(ARRAY))) { - if (request->returnValue.l != NULL) { - tossGlobalRef(env, &(request->returnValue.l)); - } - } - /* Delete potentially saved exception */ - if (request->exception != NULL) { - tossGlobalRef(env, &(request->exception)); - } -} - /* * Delete global argument references from the request which got put there before a * invoke request was carried out. See fillInvokeRequest(). @@ -782,6 +758,7 @@ invoker_completeInvokeRequest(jthread thread) jint id; InvokeRequest *request; jboolean detached; + jboolean mustReleaseReturnValue = JNI_FALSE; JDI_ASSERT(thread); @@ -825,6 +802,13 @@ invoker_completeInvokeRequest(jthread thread) id = request->id; exc = request->exception; returnValue = request->returnValue; + + /* Release return value and exception references, but delay the release + * until after the return packet was sent. */ + mustReleaseReturnValue = request->invokeType == INVOKE_CONSTRUCTOR || + returnTypeTag(request->methodSignature) == JDWP_TAG(OBJECT) || + returnTypeTag(request->methodSignature) == JDWP_TAG(ARRAY); + } /* @@ -839,6 +823,12 @@ invoker_completeInvokeRequest(jthread thread) */ deleteGlobalArgumentRefs(env, request); + /* From now on, do not access the request structure anymore + * for this request id, because once we give up the invokerLock it may + * be immediately reused by a new invoke request. + */ + request = NULL; + /* * Give up the lock before I/O operation */ @@ -859,7 +849,12 @@ invoker_completeInvokeRequest(jthread thread) */ eventHandler_lock(); // for proper lock order debugMonitorEnter(invokerLock); - deletePotentiallySavedGlobalRefs(env, request); + if (mustReleaseReturnValue && returnValue.l != NULL) { + tossGlobalRef(env, &returnValue.l); + } + if (exc != NULL) { + tossGlobalRef(env, &exc); + } debugMonitorExit(invokerLock); eventHandler_unlock(); } From f9a9f88e7c923db14aed216e3f2c34d20b726393 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Mon, 19 Jun 2017 18:02:06 -0700 Subject: [PATCH 52/59] 8181478: Refactor java/io shell tests to plain java tests Reviewed-by: alanb, psandoz --- jdk/test/java/io/File/Basic.java | 61 ++++++++------ jdk/test/java/io/File/basic.sh | 56 ------------- jdk/test/java/io/FileOutputStream/FileOpen.sh | 78 ------------------ .../java/io/FileOutputStream/FileOpenNeg.java | 45 ---------- .../java/io/FileOutputStream/FileOpenPos.java | 37 --------- .../io/FileOutputStream/FileOpenTest.java | 82 +++++++++++++++++++ 6 files changed, 120 insertions(+), 239 deletions(-) delete mode 100644 jdk/test/java/io/File/basic.sh delete mode 100644 jdk/test/java/io/FileOutputStream/FileOpen.sh delete mode 100644 jdk/test/java/io/FileOutputStream/FileOpenNeg.java delete mode 100644 jdk/test/java/io/FileOutputStream/FileOpenPos.java create mode 100644 jdk/test/java/io/FileOutputStream/FileOpenTest.java diff --git a/jdk/test/java/io/File/Basic.java b/jdk/test/java/io/File/Basic.java index 8a094362319..9ed2bd1ca7f 100644 --- a/jdk/test/java/io/File/Basic.java +++ b/jdk/test/java/io/File/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,13 +22,13 @@ */ /* @test - @bug 4165666 4203706 4288670 4290024 - @summary Basic heartbeat test for File methods that access the filesystem - - @build Basic Util - @run shell basic.sh + * @bug 4165666 4203706 4288670 4290024 + * @summary Basic heartbeat test for File methods that access the filesystem + * @build Basic Util + * @run main/othervm Basic */ +import java.io.FileOutputStream; import java.io.IOException; import java.io.File; import java.io.PrintStream; @@ -39,13 +39,13 @@ public class Basic { static PrintStream out = System.err; - static File nonExistantFile = new File("x.Basic.non"); static File rwFile = new File("x.Basic.rw"); static File bigFile = new File("x.Basic.big"); static File roFile = new File("x.Basic.ro"); static File thisDir = new File("."); static File dir = new File("x.Basic.dir"); - static File nonDir = new File("x.Basic.nonDir"); + static File dir2 = new File("x.Basic.dir2"); + static byte bytes[] = new byte[] {1, 2, 3, 4, 5, 6}; static void showBoolean(String what, boolean value) { out.println(" " + what + ": " + value); @@ -75,7 +75,6 @@ public class Basic { if (!f.canRead()) fail(f, "is not readable"); if (!Util.isPrivileged() && f.canWrite() != writeable) fail(f, writeable ? "is not writeable" : "is writeable"); - int rwLen = 6; if (f.length() != length) fail(f, "has wrong length"); } @@ -83,16 +82,31 @@ public class Basic { throw new Exception(f + " " + why); } - public static void main(String[] args) throws Exception { + static void setup() throws Exception { + rwFile.delete(); + bigFile.delete(); + roFile.delete(); + thisDir.delete(); + dir.delete(); + dir2.delete(); - show(nonExistantFile); - if (nonExistantFile.exists()) fail(nonExistantFile, "exists"); + try (FileOutputStream fos = new FileOutputStream(rwFile)) { + fos.write(bytes); + } + + roFile.createNewFile(); + roFile.setReadOnly(); + } + + public static void main(String[] args) throws Exception { + setup(); show(rwFile); - testFile(rwFile, true, 6); + testFile(rwFile, true, bytes.length); rwFile.delete(); - if (rwFile.exists()) + if (rwFile.exists()) { fail(rwFile, "could not delete"); + } show(roFile); testFile(roFile, false, 0); @@ -106,20 +120,21 @@ public class Basic { String[] fs = thisDir.list(); if (fs == null) fail(thisDir, "list() returned null"); out.print(" [" + fs.length + "]"); - for (int i = 0; i < fs.length; i++) + for (int i = 0; i < fs.length; i++) { out.print(" " + fs[i]); + } out.println(); if (fs.length == 0) fail(thisDir, "is empty"); - if (!nonExistantFile.createNewFile()) - fail(nonExistantFile, "could not create"); - nonExistantFile.deleteOnExit(); - - if (!nonDir.mkdir()) - fail(nonDir, "could not create"); - - if (!dir.renameTo(new File("x.Basic.dir2"))) + if (!dir.mkdir() || !dir.exists() || !dir.isDirectory()) { + fail(dir, "could not create"); + } + if (!dir.renameTo(dir2)) { fail(dir, "failed to rename"); + } + if (dir.exists() || !dir2.exists() || !dir2.isDirectory()) { + fail(dir, "not renamed"); + } if (System.getProperty("os.name").equals("SunOS") && System.getProperty("os.version").compareTo("5.6") >= 0) { diff --git a/jdk/test/java/io/File/basic.sh b/jdk/test/java/io/File/basic.sh deleted file mode 100644 index 69abf3d2f29..00000000000 --- a/jdk/test/java/io/File/basic.sh +++ /dev/null @@ -1,56 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# - -if [ "x$TESTJAVA" = x ]; then - TESTJAVA=$1; shift - TESTCLASSES=. -fi - -rm -rf x.Basic.* -rm -f x.Basic.non -printf "%s" "xyzzyN" > x.Basic.rw -touch x.Basic.ro -OS=`uname -s` -case "$OS" in - Windows_* | CYGWIN*) - attrib +R x.Basic.ro - ;; - *) - chmod ugo-w x.Basic.ro - ;; -esac -mkdir x.Basic.dir -if $TESTJAVA/bin/java ${TESTVMOPTS} $* -classpath "$TESTCLASSES" Basic; then - [ -f x.Basic.rw ] && (echo "x.Basic.rw not deleted"; exit 1) - ([ -d x.Basic.dir ] || [ \! -d x.Basic.dir2 ]) \ - && (echo "x.Basic.dir not renamed"; exit 1) - [ \! -d x.Basic.nonDir ] && (echo "x.Basic.nonDir not created"; exit 1) - [ -f x.Basic.non ] && (echo "x.Basic.non not deleted"; exit 1) - exit 0 -else - exit 1 -fi diff --git a/jdk/test/java/io/FileOutputStream/FileOpen.sh b/jdk/test/java/io/FileOutputStream/FileOpen.sh deleted file mode 100644 index 83dfb2773e4..00000000000 --- a/jdk/test/java/io/FileOutputStream/FileOpen.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2006, 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 6364894 -# @run shell FileOpen.sh -# @summary Test to ensure that opening of hidden Vs non-hidden, -# read/write Vs read-only files for writing works as expected. - - -# We use a TMP directory on a local disk because this test -# requires that the file to be tested be present on the local disk, -# not on a samba mounted drive or on a drive that is mapped. -# The cmd 'attrib' works only on the local files. -TMP="C:\TEMP" -hfile=${TMP}"\random_file1.txt" -ATTRIB=${SystemRoot}"\system32\attrib.exe" - -OS=`uname -s` -case "$OS" in - Windows_* ) - if [ ! -d ${TMP} ] ; then - echo "Could not find the directory-" ${TMP} "- passing test" - exit 0; - fi - ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}\\FileOpenPos.java - ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}\\FileOpenNeg.java - - echo "Opening Writable Normal File.." - ${TESTJAVA}/bin/java ${TESTVMOPTS} FileOpenPos ${hfile} - - echo "Opening Writable Hidden File.." - ${ATTRIB} +h ${hfile} - ${TESTJAVA}/bin/java ${TESTVMOPTS} FileOpenNeg ${hfile} - - echo "Opening Read-Only Normal File.." - ${ATTRIB} -h ${hfile} - ${ATTRIB} +r ${hfile} - ${TESTJAVA}/bin/java ${TESTVMOPTS} FileOpenNeg ${hfile} - - echo "Opening Read-Only Hidden File.." - ${ATTRIB} +h ${hfile} - ${TESTJAVA}/bin/java ${TESTVMOPTS} FileOpenNeg ${hfile} - - rm -f ${hfile} - exit - ;; - - * ) - echo "This test is not intended for this OS - passing test" - exit 0 - ;; -esac diff --git a/jdk/test/java/io/FileOutputStream/FileOpenNeg.java b/jdk/test/java/io/FileOutputStream/FileOpenNeg.java deleted file mode 100644 index 58384a702d0..00000000000 --- a/jdk/test/java/io/FileOutputStream/FileOpenNeg.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2006, 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.*; - -public class FileOpenNeg { - - public static void main( String[] args) throws Exception { - boolean openForWrite = true; - - File f = new File(args[0]); - try { - FileOutputStream fs = new FileOutputStream(f); - fs.write(1); - fs.close(); - } catch( IOException e ) { - System.out.println("Caught the Exception as expected"); - e.printStackTrace(System.out); - openForWrite = false; - } - if (openForWrite && !f.canWrite()) { - throw new Exception("Able to open READ-ONLY file for WRITING!"); - } - } -} diff --git a/jdk/test/java/io/FileOutputStream/FileOpenPos.java b/jdk/test/java/io/FileOutputStream/FileOpenPos.java deleted file mode 100644 index 0daf17bbecf..00000000000 --- a/jdk/test/java/io/FileOutputStream/FileOpenPos.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2006, 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.*; - -public class FileOpenPos { - - public static void main( String[] args) - throws IOException { - File f = new File(args[0]); - FileOutputStream fs = new FileOutputStream(f); - fs.write(1); - fs.close(); - System.out.println("Can Write ?" + f.canWrite()); - System.out.println("The File was successfully opened"); - } -} diff --git a/jdk/test/java/io/FileOutputStream/FileOpenTest.java b/jdk/test/java/io/FileOutputStream/FileOpenTest.java new file mode 100644 index 00000000000..894576670f1 --- /dev/null +++ b/jdk/test/java/io/FileOutputStream/FileOpenTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 6364894 + * @requires (os.family == "windows") + * @library /test/lib + * @build jdk.test.lib.Asserts + * @run main FileOpenTest + * @summary Test to ensure that opening of hidden Vs non-hidden, + * read/write Vs read-only files for writing works as expected. + */ + +import java.io.File; +import java.io.IOException; +import java.io.FileOutputStream; +import java.nio.file.Files; + +import static jdk.test.lib.Asserts.assertTrue; + +public class FileOpenTest { + + private static File tmpFile; + + public static void main(String args[]) throws Exception { + try { + tmpFile = File.createTempFile("FileOpenTest", "suffix"); + + // Opening Writable Normal File.. + test(true); + + // Opening Writable Hidden File.. + Files.setAttribute(tmpFile.toPath(), "dos:hidden", true); + test(false); + + // Opening Read-Only Hidden File.. + Files.setAttribute(tmpFile.toPath(), "dos:hidden", false); + tmpFile.setReadOnly(); + test(false); + + // Opening Read-Only Normal File.. + Files.setAttribute(tmpFile.toPath(), "dos:hidden", true); + test(false); + } finally { + tmpFile.delete(); + } + } + + private static void test(boolean writable) throws Exception { + + try (FileOutputStream fs = new FileOutputStream(tmpFile)) { + fs.write(1); + assertTrue(writable, "Able to open READ-ONLY file for WRITING!"); + assertTrue(tmpFile.canWrite(), "Able to open READ-ONLY file for WRITING!"); + } catch(IOException e) { + assertTrue(!writable, "Unable to open non-READ-ONLY file for WRITING!"); + System.out.println("Caught the Exception as expected"); + e.printStackTrace(System.out); + } + } +} From 13bee792f3f7a99b6017224ef4e3553096ae6f9c Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 20 Jun 2017 13:43:43 -0700 Subject: [PATCH 53/59] 8182611: extLink ignores text after first newline Reviewed-by: ksrini --- jdk/make/src/classes/build/tools/taglet/ExtLink.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/make/src/classes/build/tools/taglet/ExtLink.java b/jdk/make/src/classes/build/tools/taglet/ExtLink.java index 34eaed59f28..94a93824fbf 100644 --- a/jdk/make/src/classes/build/tools/taglet/ExtLink.java +++ b/jdk/make/src/classes/build/tools/taglet/ExtLink.java @@ -58,7 +58,7 @@ public class ExtLink implements Taglet { static final String URL = "https://www.oracle.com/pls/topic/lookup?ctx=javase9&id="; - static final Pattern TAG_PATTERN = Pattern.compile("(\\s*)(?\\w+)(\\s+)(?.*)"); + static final Pattern TAG_PATTERN = Pattern.compile("(?s)(\\s*)(?\\w+)(\\s+)(?.*)$"); /** * Returns the set of locations in which the tag may be used. From a14dd28e6bf95dc8a5eeca0cb9b5d84e65c8854c Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 20 Jun 2017 14:29:52 -0700 Subject: [PATCH 54/59] 8177561: Remove deprecated for removal portions of com.sun.org.apache Reviewed-by: lancea, rriggs --- .../internal/util/XMLCatalogResolver.java | 596 ----- .../apache/xml/internal/resolver/Catalog.java | 2258 ----------------- .../xml/internal/resolver/CatalogEntry.java | 251 -- .../internal/resolver/CatalogException.java | 165 -- .../xml/internal/resolver/CatalogManager.java | 870 ------- .../xml/internal/resolver/Resolver.java | 697 ----- .../resolver/helpers/BootstrapResolver.java | 207 -- .../xml/internal/resolver/helpers/Debug.java | 105 - .../internal/resolver/helpers/FileURL.java | 87 - .../internal/resolver/helpers/Namespaces.java | 110 - .../internal/resolver/helpers/PublicId.java | 169 -- .../resolver/readers/CatalogReader.java | 75 - .../resolver/readers/DOMCatalogParser.java | 47 - .../resolver/readers/DOMCatalogReader.java | 240 -- .../readers/ExtendedXMLCatalogReader.java | 181 -- .../readers/OASISXMLCatalogReader.java | 546 ---- .../resolver/readers/SAXCatalogParser.java | 39 - .../resolver/readers/SAXCatalogReader.java | 503 ---- .../resolver/readers/SAXParserHandler.java | 144 -- .../resolver/readers/TR9401CatalogReader.java | 138 - .../resolver/readers/TextCatalogReader.java | 298 --- .../resolver/readers/XCatalogReader.java | 208 -- .../resolver/tools/CatalogResolver.java | 349 --- .../resolver/tools/ResolvingParser.java | 434 ---- .../resolver/tools/ResolvingXMLFilter.java | 346 --- .../resolver/tools/ResolvingXMLReader.java | 90 - 26 files changed, 9153 deletions(-) delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogException.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Debug.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/FileURL.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Namespaces.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/PublicId.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/CatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogParser.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/ExtendedXMLCatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/OASISXMLCatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogParser.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXParserHandler.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TR9401CatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TextCatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/XCatalogReader.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingParser.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLFilter.java delete mode 100644 jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLReader.java diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java deleted file mode 100644 index 56ad116a1ae..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLCatalogResolver.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xerces.internal.util; - -import java.io.IOException; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.ext.EntityResolver2; - -import org.w3c.dom.ls.LSInput; -import org.w3c.dom.ls.LSResourceResolver; - -import javax.xml.parsers.SAXParserFactory; - -import com.sun.org.apache.xerces.internal.dom.DOMInputImpl; -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; - -import com.sun.org.apache.xerces.internal.xni.XNIException; -import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier; - -import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; -import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogManager; -import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader; -import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader; - -/** - *

    The catalog resolver handles the resolution of external - * identifiers and URI references through XML catalogs. This - * component supports XML catalogs defined by the - * - * OASIS XML Catalogs Specification. It encapsulates the - * XML Commons resolver. - * An instance of this class may be registered on the parser - * as a SAX entity resolver, as a DOM LSResourceResolver or - * as an XNI entity resolver by setting the property - * (http://apache.org/xml/properties/internal/entity-resolver).

    - * - *

    It is intended that this class may be used standalone to perform - * catalog resolution outside of a parsing context. It may be shared - * between several parsers and the application.

    - * - * @deprecated This class and the JDK internal Catalog API in package - * {@code com.sun.org.apache.xml.internal.resolver} - * is encapsulated in JDK 9. The entire implementation under the package is now - * deprecated and subject to removal in a future release. Users of the API should - * migrate to the {@linkplain javax.xml.catalog new public API}. - *

    - * The new Catalog API is supported throughout the JDK XML Processors, which allows - * the use of Catalog by simply setting a path to a Catalog file as a property. - * - * @author Michael Glavassevich, IBM - * - */ -@Deprecated(since="9", forRemoval=true) -public class XMLCatalogResolver - implements XMLEntityResolver, EntityResolver2, LSResourceResolver { - - /** Internal catalog manager for Apache catalogs. **/ - private CatalogManager fResolverCatalogManager = null; - - /** Internal catalog structure. **/ - private Catalog fCatalog = null; - - /** An array of catalog URIs. **/ - private String [] fCatalogsList = null; - - /** - * Indicates whether the list of catalogs has - * changed since it was processed. - */ - private boolean fCatalogsChanged = true; - - /** Application specified prefer public setting. **/ - private boolean fPreferPublic = true; - - /** - * Indicates whether the application desires that - * the parser or some other component performing catalog - * resolution should use the literal system identifier - * instead of the expanded system identifier. - */ - private boolean fUseLiteralSystemId = true; - - /** - *

    Constructs a catalog resolver with a default configuration.

    - */ - public XMLCatalogResolver () { - this(null, true); - } - - /** - *

    Constructs a catalog resolver with the given - * list of entry files.

    - * - * @param catalogs an ordered array list of absolute URIs - */ - public XMLCatalogResolver (String [] catalogs) { - this(catalogs, true); - } - - /** - *

    Constructs a catalog resolver with the given - * list of entry files and the preference for whether - * system or public matches are preferred.

    - * - * @param catalogs an ordered array list of absolute URIs - * @param preferPublic the prefer public setting - */ - public XMLCatalogResolver (String [] catalogs, boolean preferPublic) { - init(catalogs, preferPublic); - } - - /** - *

    Returns the initial list of catalog entry files.

    - * - * @return the initial list of catalog entry files - */ - public final synchronized String [] getCatalogList () { - return (fCatalogsList != null) - ? (String[]) fCatalogsList.clone() : null; - } - - /** - *

    Sets the initial list of catalog entry files. - * If there were any catalog mappings cached from - * the previous list they will be replaced by catalog - * mappings from the new list the next time the catalog - * is queried.

    - * - * @param catalogs an ordered array list of absolute URIs - */ - public final synchronized void setCatalogList (String [] catalogs) { - fCatalogsChanged = true; - fCatalogsList = (catalogs != null) - ? (String[]) catalogs.clone() : null; - } - - /** - *

    Forces the cache of catalog mappings to be cleared.

    - */ - public final synchronized void clear () { - fCatalog = null; - } - - /** - *

    Returns the preference for whether system or public - * matches are preferred. This is used in the absence - * of any occurence of the prefer attribute - * on the catalog entry of a catalog. If this - * property has not yet been explicitly set its value is - * true.

    - * - * @return the prefer public setting - */ - public final boolean getPreferPublic () { - return fPreferPublic; - } - - /** - *

    Sets the preference for whether system or public - * matches are preferred. This is used in the absence - * of any occurence of the prefer attribute - * on the catalog entry of a catalog.

    - * - * @param preferPublic the prefer public setting - */ - public final void setPreferPublic (boolean preferPublic) { - fPreferPublic = preferPublic; - fResolverCatalogManager.setPreferPublic(preferPublic); - } - - /** - *

    Returns the preference for whether the literal system - * identifier should be used when resolving system - * identifiers when both it and the expanded system - * identifier are available. If this property has not yet - * been explicitly set its value is true.

    - * - * @return the preference for using literal system identifers - * for catalog resolution - * - * @see #setUseLiteralSystemId - */ - public final boolean getUseLiteralSystemId () { - return fUseLiteralSystemId; - } - - /** - *

    Sets the preference for whether the literal system - * identifier should be used when resolving system - * identifiers when both it and the expanded system - * identifier are available.

    - * - *

    The literal system identifier is the URI as it was - * provided before absolutization. It may be embedded within - * an entity. It may be provided externally or it may be the - * result of redirection. For example, redirection may - * have come from the protocol level through HTTP or from - * an application's entity resolver.

    - * - *

    The expanded system identifier is an absolute URI - * which is the result of resolving the literal system - * identifier against a base URI.

    - * - * @param useLiteralSystemId the preference for using - * literal system identifers for catalog resolution - */ - public final void setUseLiteralSystemId (boolean useLiteralSystemId) { - fUseLiteralSystemId = useLiteralSystemId; - } - - /** - *

    Resolves an external entity. If the entity cannot be - * resolved, this method should return null. This - * method returns an input source if an entry was found in the - * catalog for the given external identifier. It should be - * overrided if other behaviour is required.

    - * - * @param publicId the public identifier, or null if none was supplied - * @param systemId the system identifier - * - * @throws SAXException any SAX exception, possibly wrapping another exception - * @throws IOException thrown if some i/o error occurs - */ - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { - - String resolvedId = null; - if (publicId != null && systemId != null) { - resolvedId = resolvePublic(publicId, systemId); - } - else if (systemId != null) { - resolvedId = resolveSystem(systemId); - } - - if (resolvedId != null) { - InputSource source = new InputSource(resolvedId); - source.setPublicId(publicId); - return source; - } - return null; - } - - /** - *

    Resolves an external entity. If the entity cannot be - * resolved, this method should return null. This - * method returns an input source if an entry was found in the - * catalog for the given external identifier. It should be - * overrided if other behaviour is required.

    - * - * @param name the identifier of the external entity - * @param publicId the public identifier, or null if none was supplied - * @param baseURI the URI with respect to which relative systemIDs are interpreted. - * @param systemId the system identifier - * - * @throws SAXException any SAX exception, possibly wrapping another exception - * @throws IOException thrown if some i/o error occurs - */ - public InputSource resolveEntity(String name, String publicId, - String baseURI, String systemId) throws SAXException, IOException { - - String resolvedId = null; - - if (!getUseLiteralSystemId() && baseURI != null) { - // Attempt to resolve the system identifier against the base URI. - try { - URI uri = new URI(new URI(baseURI), systemId); - systemId = uri.toString(); - } - // Ignore the exception. Fallback to the literal system identifier. - catch (URI.MalformedURIException ex) {} - } - - if (publicId != null && systemId != null) { - resolvedId = resolvePublic(publicId, systemId); - } - else if (systemId != null) { - resolvedId = resolveSystem(systemId); - } - - if (resolvedId != null) { - InputSource source = new InputSource(resolvedId); - source.setPublicId(publicId); - return source; - } - return null; - } - - /** - *

    Locates an external subset for documents which do not explicitly - * provide one. This method always returns null. It - * should be overrided if other behaviour is required.

    - * - * @param name the identifier of the document root element - * @param baseURI the document's base URI - * - * @throws SAXException any SAX exception, possibly wrapping another exception - * @throws IOException thrown if some i/o error occurs - */ - public InputSource getExternalSubset(String name, String baseURI) - throws SAXException, IOException { - return null; - } - - /** - *

    Resolves a resource using the catalog. This method interprets that - * the namespace URI corresponds to uri entries in the catalog. - * Where both a namespace and an external identifier exist, the namespace - * takes precedence.

    - * - * @param type the type of the resource being resolved - * @param namespaceURI the namespace of the resource being resolved, - * or null if none was supplied - * @param publicId the public identifier of the resource being resolved, - * or null if none was supplied - * @param systemId the system identifier of the resource being resolved, - * or null if none was supplied - * @param baseURI the absolute base URI of the resource being parsed, - * or null if there is no base URI - */ - public LSInput resolveResource(String type, String namespaceURI, - String publicId, String systemId, String baseURI) { - - String resolvedId = null; - - try { - // The namespace is useful for resolving namespace aware - // grammars such as XML schema. Let it take precedence over - // the external identifier if one exists. - if (namespaceURI != null) { - resolvedId = resolveURI(namespaceURI); - } - - if (!getUseLiteralSystemId() && baseURI != null) { - // Attempt to resolve the system identifier against the base URI. - try { - URI uri = new URI(new URI(baseURI), systemId); - systemId = uri.toString(); - } - // Ignore the exception. Fallback to the literal system identifier. - catch (URI.MalformedURIException ex) {} - } - - // Resolve against an external identifier if one exists. This - // is useful for resolving DTD external subsets and other - // external entities. For XML schemas if there was no namespace - // mapping we might be able to resolve a system identifier - // specified as a location hint. - if (resolvedId == null) { - if (publicId != null && systemId != null) { - resolvedId = resolvePublic(publicId, systemId); - } - else if (systemId != null) { - resolvedId = resolveSystem(systemId); - } - } - } - // Ignore IOException. It cannot be thrown from this method. - catch (IOException ex) {} - - if (resolvedId != null) { - return new DOMInputImpl(publicId, resolvedId, baseURI); - } - return null; - } - - - /** - *

    Resolves an external entity. If the entity cannot be - * resolved, this method should return null. This - * method only calls resolveIdentifier and returns - * an input source if an entry was found in the catalog. It - * should be overrided if other behaviour is required.

    - * - * @param resourceIdentifier location of the XML resource to resolve - * - * @throws XNIException thrown on general error - * @throws IOException thrown if some i/o error occurs - */ - public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) - throws XNIException, IOException { - - String resolvedId = resolveIdentifier(resourceIdentifier); - if (resolvedId != null) { - return new XMLInputSource(resourceIdentifier.getPublicId(), - resolvedId, resourceIdentifier.getBaseSystemId(), false); - } - return null; - } - - /** - *

    Resolves an identifier using the catalog. This method interprets that - * the namespace of the identifier corresponds to uri entries in the catalog. - * Where both a namespace and an external identifier exist, the namespace - * takes precedence.

    - * - * @param resourceIdentifier the identifier to resolve - * - * @throws XNIException thrown on general error - * @throws IOException thrown if some i/o error occurs - */ - public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier) - throws IOException, XNIException { - - String resolvedId = null; - - // The namespace is useful for resolving namespace aware - // grammars such as XML schema. Let it take precedence over - // the external identifier if one exists. - String namespace = resourceIdentifier.getNamespace(); - if (namespace != null) { - resolvedId = resolveURI(namespace); - } - - // Resolve against an external identifier if one exists. This - // is useful for resolving DTD external subsets and other - // external entities. For XML schemas if there was no namespace - // mapping we might be able to resolve a system identifier - // specified as a location hint. - if (resolvedId == null) { - String publicId = resourceIdentifier.getPublicId(); - String systemId = getUseLiteralSystemId() - ? resourceIdentifier.getLiteralSystemId() - : resourceIdentifier.getExpandedSystemId(); - if (publicId != null && systemId != null) { - resolvedId = resolvePublic(publicId, systemId); - } - else if (systemId != null) { - resolvedId = resolveSystem(systemId); - } - } - return resolvedId; - } - - /** - *

    Returns the URI mapping in the catalog for the given - * external identifier or null if no mapping - * exists. If the system identifier is an URN in the - * publicid namespace it is converted into - * a public identifier by URN "unwrapping" as specified - * in the XML Catalogs specification.

    - * - * @param systemId the system identifier to locate in the catalog - * - * @return the mapped URI or null if no mapping - * was found in the catalog - * - * @throws IOException if an i/o error occurred while reading - * the catalog - */ - public final synchronized String resolveSystem (String systemId) - throws IOException { - - if (fCatalogsChanged) { - parseCatalogs(); - fCatalogsChanged = false; - } - return (fCatalog != null) - ? fCatalog.resolveSystem(systemId) : null; - } - - /** - *

    Returns the URI mapping in the catalog for the given - * external identifier or null if no mapping - * exists. Public identifiers are normalized before - * comparison.

    - * - * @param publicId the public identifier to locate in the catalog - * @param systemId the system identifier to locate in the catalog - * - * @return the mapped URI or null if no mapping - * was found in the catalog - * - * @throws IOException if an i/o error occurred while reading - * the catalog - */ - public final synchronized String resolvePublic (String publicId, String systemId) - throws IOException { - - if (fCatalogsChanged) { - parseCatalogs(); - fCatalogsChanged = false; - } - return (fCatalog != null) - ? fCatalog.resolvePublic(publicId, systemId) : null; - } - - /** - *

    Returns the URI mapping in the catalog for the given URI - * reference or null if no mapping exists. - * URI comparison is case sensitive. If the URI reference - * is an URN in the publicid namespace - * it is converted into a public identifier by URN "unwrapping" - * as specified in the XML Catalogs specification and then - * resolution is performed following the semantics of - * external identifier resolution.

    - * - * @param uri the URI to locate in the catalog - * - * @return the mapped URI or null if no mapping - * was found in the catalog - * - * @throws IOException if an i/o error occurred while reading - * the catalog - */ - public final synchronized String resolveURI (String uri) - throws IOException { - - if (fCatalogsChanged) { - parseCatalogs(); - fCatalogsChanged = false; - } - return (fCatalog != null) - ? fCatalog.resolveURI(uri) : null; - } - - /** - * Initialization. Create a CatalogManager and set all - * the properties upfront. This prevents JVM wide system properties - * or a property file somewhere in the environment from affecting - * the behaviour of this catalog resolver. - */ - private void init (String [] catalogs, boolean preferPublic) { - fCatalogsList = (catalogs != null) ? (String[]) catalogs.clone() : null; - fPreferPublic = preferPublic; - fResolverCatalogManager = new CatalogManager(); - fResolverCatalogManager.setAllowOasisXMLCatalogPI(false); - fResolverCatalogManager.setCatalogClassName("com.sun.org.apache.xml.internal.resolver.Catalog"); - fResolverCatalogManager.setCatalogFiles(""); - fResolverCatalogManager.setIgnoreMissingProperties(true); - fResolverCatalogManager.setPreferPublic(fPreferPublic); - fResolverCatalogManager.setRelativeCatalogs(false); - fResolverCatalogManager.setUseStaticCatalog(false); - fResolverCatalogManager.setVerbosity(0); - } - - /** - * Instruct the Catalog to parse each of the - * catalogs in the list. Only the first catalog will actually be - * parsed immediately. The others will be queued and read if - * they are needed later. - */ - private void parseCatalogs () throws IOException { - if (fCatalogsList != null) { - fCatalog = new Catalog(fResolverCatalogManager); - attachReaderToCatalog(fCatalog); - for (int i = 0; i < fCatalogsList.length; ++i) { - String catalog = fCatalogsList[i]; - if (catalog != null && catalog.length() > 0) { - fCatalog.parseCatalog(catalog); - } - } - } - else { - fCatalog = null; - } - } - - /** - * Attaches the reader to the catalog. - */ - private void attachReaderToCatalog (Catalog catalog) { - - SAXParserFactory spf = new SAXParserFactoryImpl(); - spf.setNamespaceAware(true); - spf.setValidating(false); - - SAXCatalogReader saxReader = new SAXCatalogReader(spf); - saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", - "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader"); - catalog.addReader("application/xml", saxReader); - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java deleted file mode 100644 index 574049f45e2..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Catalog.java +++ /dev/null @@ -1,2258 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - */ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver; - -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; -import com.sun.org.apache.xerces.internal.utils.SecuritySupport; -import com.sun.org.apache.xml.internal.resolver.helpers.FileURL; -import com.sun.org.apache.xml.internal.resolver.helpers.PublicId; -import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader; -import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader; -import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader; -import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader; -import java.io.DataInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Vector; -import javax.xml.parsers.SAXParserFactory; - -/** - * Represents OASIS Open Catalog files. - * - *

    This class implements the semantics of OASIS Open Catalog files - * (defined by - * OASIS Technical - * Resolution 9401:1997 (Amendment 2 to TR 9401)).

    - * - *

    The primary purpose of the Catalog is to associate resources in the - * document with local system identifiers. Some entities - * (document types, XML entities, and notations) have names and all of them - * can have either public or system identifiers or both. (In XML, only a - * notation can have a public identifier without a system identifier, but - * the methods implemented in this class obey the Catalog semantics - * from the SGML - * days when system identifiers were optional.)

    - * - *

    The system identifiers returned by the resolution methods in this - * class are valid, i.e. usable by, and in fact constructed by, the - * java.net.URL class. Unfortunately, this class seems to behave in - * somewhat non-standard ways and the system identifiers returned may - * not be directly usable in a browser or filesystem context. - * - *

    This class recognizes all of the Catalog entries defined in - * TR9401:1997:

    - * - *
      - *
    • BASE - * changes the base URI for resolving relative system identifiers. The - * initial base URI is the URI of the location of the catalog (which is, - * in turn, relative to the location of the current working directory - * at startup, as returned by the user.dir system property).
    • - *
    • CATALOG - * processes other catalog files. An included catalog occurs logically - * at the end of the including catalog.
    • - *
    • DELEGATE_PUBLIC - * specifies alternate catalogs for some public identifiers. The delegated - * catalogs are not loaded until they are needed, but they are cached - * once loaded.
    • - *
    • DELEGATE_SYSTEM - * specifies alternate catalogs for some system identifiers. The delegated - * catalogs are not loaded until they are needed, but they are cached - * once loaded.
    • - *
    • DELEGATE_URI - * specifies alternate catalogs for some URIs. The delegated - * catalogs are not loaded until they are needed, but they are cached - * once loaded.
    • - *
    • REWRITE_SYSTEM - * specifies alternate prefix for a system identifier.
    • - *
    • REWRITE_URI - * specifies alternate prefix for a URI.
    • - *
    • SYSTEM_SUFFIX - * maps any system identifier that ends with a particular suffix to another - * system identifier.
    • - *
    • URI_SUFFIX - * maps any URI that ends with a particular suffix to another URI.
    • - *
    • DOCTYPE - * associates the names of root elements with URIs. (In other words, an XML - * processor might infer the doctype of an XML document that does not include - * a doctype declaration by looking for the DOCTYPE entry in the - * catalog which matches the name of the root element of the document.)
    • - *
    • DOCUMENT - * provides a default document.
    • - *
    • DTDDECL - * recognized and silently ignored. Not relevant for XML.
    • - *
    • ENTITY - * associates entity names with URIs.
    • - *
    • LINKTYPE - * recognized and silently ignored. Not relevant for XML.
    • - *
    • NOTATION - * associates notation names with URIs.
    • - *
    • OVERRIDE - * changes the override behavior. Initial behavior is set by the - * system property xml.catalog.override. The default initial - * behavior is 'YES', that is, entries in the catalog override - * system identifiers specified in the document.
    • - *
    • PUBLIC - * maps a public identifier to a system identifier.
    • - *
    • SGMLDECL - * recognized and silently ignored. Not relevant for XML.
    • - *
    • SYSTEM - * maps a system identifier to another system identifier.
    • - *
    • URI - * maps a URI to another URI.
    • - *
    - * - *

    Note that BASE entries are treated as described by RFC2396. In - * particular, this has the counter-intuitive property that after a BASE - * entry identifing "http://example.com/a/b/c" as the base URI, - * the relative URI "foo" is resolved to the absolute URI - * "http://example.com/a/b/foo". You must provide the trailing slash if - * you do not want the final component of the path to be discarded as a - * filename would in a URI for a resource: "http://example.com/a/b/c/". - *

    - * - *

    Note that subordinate catalogs (all catalogs except the first, - * including CATALOG and DELEGATE* catalogs) are only loaded if and when - * they are required.

    - * - *

    This class relies on classes which implement the CatalogReader - * interface to actually load catalog files. This allows the catalog - * semantics to be implemented for TR9401 text-based catalogs, XML - * catalogs, or any number of other storage formats.

    - * - *

    Additional catalogs may also be loaded with the - * {@link #parseCatalog} method.

    - * - *

    Change Log:

    - *
    - *
    2.0
    - *

    Rewrite to use CatalogReaders.

    - *
    1.1
    - *

    Allow quoted components in xml.catalog.files - * so that URLs containing colons can be used on Unix. - * The string passed to xml.catalog.files can now have the form:

    - *
    - * unquoted-path-with-no-sep-chars:"double-quoted path with or without sep chars":'single-quoted path with or without sep chars'
    - * 
    - *

    (Where ":" is the separater character in this example.)

    - *

    If an unquoted path contains an embedded double or single quote - * character, no special processig is performed on that character. No - * path can contain separater characters, double, and single quotes - * simultaneously.

    - *

    Fix bug in calculation of BASE entries: if - * a catalog contains multiple BASE entries, each is relative to the preceding - * base, not the default base URI of the catalog.

    - *
    - *
    1.0.1
    - *

    Fixed a bug in the calculation of the list of subordinate catalogs. - * This bug caused an infinite loop where parsing would alternately process - * two catalogs indefinitely.

    - *
    - *
    - * - * @see CatalogReader - * @see CatalogEntry - * @deprecated The JDK internal Catalog API in package - * {@code com.sun.org.apache.xml.internal.resolver} - * is encapsulated in JDK 9. The entire implementation under the package is now - * deprecated and subject to removal in a future release. Users of the API - * should migrate to the {@linkplain javax.xml.catalog new public API}. - *

    - * The new Catalog API is supported throughout the JDK XML Processors, which allows - * the use of Catalog by simply setting a path to a Catalog file as a property. - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - * - *

    Derived from public domain code originally published by Arbortext, - * Inc.

    - */ -@Deprecated(since="9", forRemoval=true) -public class Catalog { - /** The BASE Catalog Entry type. */ - public static final int BASE = CatalogEntry.addEntryType("BASE", 1); - - /** The CATALOG Catalog Entry type. */ - public static final int CATALOG = CatalogEntry.addEntryType("CATALOG", 1); - - /** The DOCUMENT Catalog Entry type. */ - public static final int DOCUMENT = CatalogEntry.addEntryType("DOCUMENT", 1); - - /** The OVERRIDE Catalog Entry type. */ - public static final int OVERRIDE = CatalogEntry.addEntryType("OVERRIDE", 1); - - /** The SGMLDECL Catalog Entry type. */ - public static final int SGMLDECL = CatalogEntry.addEntryType("SGMLDECL", 1); - - /** The DELEGATE_PUBLIC Catalog Entry type. */ - public static final int DELEGATE_PUBLIC = CatalogEntry.addEntryType("DELEGATE_PUBLIC", 2); - - /** The DELEGATE_SYSTEM Catalog Entry type. */ - public static final int DELEGATE_SYSTEM = CatalogEntry.addEntryType("DELEGATE_SYSTEM", 2); - - /** The DELEGATE_URI Catalog Entry type. */ - public static final int DELEGATE_URI = CatalogEntry.addEntryType("DELEGATE_URI", 2); - - /** The DOCTYPE Catalog Entry type. */ - public static final int DOCTYPE = CatalogEntry.addEntryType("DOCTYPE", 2); - - /** The DTDDECL Catalog Entry type. */ - public static final int DTDDECL = CatalogEntry.addEntryType("DTDDECL", 2); - - /** The ENTITY Catalog Entry type. */ - public static final int ENTITY = CatalogEntry.addEntryType("ENTITY", 2); - - /** The LINKTYPE Catalog Entry type. */ - public static final int LINKTYPE = CatalogEntry.addEntryType("LINKTYPE", 2); - - /** The NOTATION Catalog Entry type. */ - public static final int NOTATION = CatalogEntry.addEntryType("NOTATION", 2); - - /** The PUBLIC Catalog Entry type. */ - public static final int PUBLIC = CatalogEntry.addEntryType("PUBLIC", 2); - - /** The SYSTEM Catalog Entry type. */ - public static final int SYSTEM = CatalogEntry.addEntryType("SYSTEM", 2); - - /** The URI Catalog Entry type. */ - public static final int URI = CatalogEntry.addEntryType("URI", 2); - - /** The REWRITE_SYSTEM Catalog Entry type. */ - public static final int REWRITE_SYSTEM = CatalogEntry.addEntryType("REWRITE_SYSTEM", 2); - - /** The REWRITE_URI Catalog Entry type. */ - public static final int REWRITE_URI = CatalogEntry.addEntryType("REWRITE_URI", 2); - /** The SYSTEM_SUFFIX Catalog Entry type. */ - public static final int SYSTEM_SUFFIX = CatalogEntry.addEntryType("SYSTEM_SUFFIX", 2); - /** The URI_SUFFIX Catalog Entry type. */ - public static final int URI_SUFFIX = CatalogEntry.addEntryType("URI_SUFFIX", 2); - - /** - * The base URI for relative system identifiers in the catalog. - * This may be changed by BASE entries in the catalog. - */ - protected URL base; - - /** The base URI of the Catalog file currently being parsed. */ - protected URL catalogCwd; - - /** The catalog entries currently known to the system. */ - protected Vector catalogEntries = new Vector(); - - /** The default initial override setting. */ - protected boolean default_override = true; - - /** The catalog manager in use for this instance. */ - protected CatalogManager catalogManager = CatalogManager.getStaticManager(); - - /** - * A vector of catalog files to be loaded. - * - *

    This list is initially established by - * loadSystemCatalogs when - * it parses the system catalog list, but CATALOG entries may - * contribute to it during the course of parsing.

    - * - * @see #loadSystemCatalogs - * @see #localCatalogFiles - */ - protected Vector catalogFiles = new Vector(); - - /** - * A vector of catalog files constructed during processing of - * CATALOG entries in the current catalog. - * - *

    This two-level system is actually necessary to correctly implement - * the semantics of the CATALOG entry. If one catalog file includes - * another with a CATALOG entry, the included catalog logically - * occurs at the end of the including catalog, and after any - * preceding CATALOG entries. In other words, the CATALOG entry - * cannot insert anything into the middle of a catalog file.

    - * - *

    When processing reaches the end of each catalog files, any - * elements on this vector are added to the front of the - * catalogFiles vector.

    - * - * @see #catalogFiles - */ - protected Vector localCatalogFiles = new Vector(); - - /** - * A vector of Catalogs. - * - *

    The semantics of Catalog resolution are such that each - * catalog is effectively a list of Catalogs (in other words, - * a recursive list of Catalog instances).

    - * - *

    Catalogs that are processed as the result of CATALOG or - * DELEGATE* entries are subordinate to the catalog that contained - * them, but they may in turn have subordinate catalogs.

    - * - *

    Catalogs are only loaded when they are needed, so this vector - * initially contains a list of Catalog filenames (URLs). If, during - * processing, one of these catalogs has to be loaded, the resulting - * Catalog object is placed in the vector, effectively caching it - * for the next query.

    - */ - protected Vector catalogs = new Vector(); - - /** - * A vector of DELEGATE* Catalog entries constructed during - * processing of the Catalog. - * - *

    This two-level system has two purposes; first, it allows - * us to sort the DELEGATE* entries by the length of the partial - * public identifier so that a linear search encounters them in - * the correct order and second, it puts them all at the end of - * the Catalog.

    - * - *

    When processing reaches the end of each catalog file, any - * elements on this vector are added to the end of the - * catalogEntries vector. This assures that matching - * PUBLIC keywords are encountered before DELEGATE* entries.

    - */ - protected Vector localDelegate = new Vector(); - - /** - * A hash of CatalogReaders. - * - *

    This hash maps MIME types to elements in the readerArr - * vector. This allows the Catalog to quickly locate the reader - * for a particular MIME type.

    - */ - protected Map readerMap = new HashMap<>(); - - /** - * A vector of CatalogReaders. - * - *

    This vector contains all of the readers in the order that they - * were added. In the event that a catalog is read from a file, where - * the MIME type is unknown, each reader is attempted in turn until - * one succeeds.

    - */ - protected Vector readerArr = new Vector(); - - /** - * Constructs an empty Catalog. - * - *

    The constructor interrogates the relevant system properties - * using the default (static) CatalogManager - * and initializes the catalog data structures.

    - */ - public Catalog() { - // nop; - } - - /** - * Constructs an empty Catalog with a specific CatalogManager. - * - *

    The constructor interrogates the relevant system properties - * using the specified Catalog Manager - * and initializes the catalog data structures.

    - */ - public Catalog(CatalogManager manager) { - catalogManager = manager; - } - - /** - * Return the CatalogManager used by this catalog. - * - */ - public CatalogManager getCatalogManager() { - return catalogManager; - } - - /** - * Establish the CatalogManager used by this catalog. - * - */ - public void setCatalogManager(CatalogManager manager) { - catalogManager = manager; - } - - /** - * Setup readers. - */ - public void setupReaders() { - SAXParserFactory spf = catalogManager.useServicesMechanism() ? - SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); - spf.setNamespaceAware(true); - spf.setValidating(false); - - SAXCatalogReader saxReader = new SAXCatalogReader(spf); - - saxReader.setCatalogParser(null, "XMLCatalog", - "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); - - saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, - "catalog", - "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader"); - - addReader("application/xml", saxReader); - - TR9401CatalogReader textReader = new TR9401CatalogReader(); - addReader("text/plain", textReader); - } - - /** - * Add a new CatalogReader to the Catalog. - * - *

    This method allows you to add a new CatalogReader to the - * catalog. The reader will be associated with the specified mimeType. - * You can only have one reader per mimeType.

    - * - *

    In the absence of a mimeType (e.g., when reading a catalog - * directly from a file on the local system), the readers are attempted - * in the order that you add them to the Catalog.

    - * - *

    Note that subordinate catalogs (created by CATALOG or - * DELEGATE* entries) get a copy of the set of readers present in - * the primary catalog when they are created. Readers added subsequently - * will not be available. For this reason, it is best to add all - * of the readers before the first call to parse a catalog.

    - * - * @param mimeType The MIME type associated with this reader. - * @param reader The CatalogReader to use. - */ - public void addReader(String mimeType, CatalogReader reader) { - if (readerMap.containsKey(mimeType)) { - Integer pos = readerMap.get(mimeType); - readerArr.set(pos, reader); - } else { - readerArr.add(reader); - Integer pos = readerArr.size()-1; - readerMap.put(mimeType, pos); - } - } - - /** - * Copies the reader list from the current Catalog to a new Catalog. - * - *

    This method is used internally when constructing a new catalog. - * It copies the current reader associations over to the new catalog. - *

    - * - * @param newCatalog The new Catalog. - */ - protected void copyReaders(Catalog newCatalog) { - // Have to copy the readers in the right order...convert hash to arr - Vector mapArr = new Vector(readerMap.size()); - - // Pad the mapArr out to the right length - for (int count = 0; count < readerMap.size(); count++) { - mapArr.add(null); - } - - for (Map.Entry entry : readerMap.entrySet()) { - mapArr.set(entry.getValue().intValue(), entry.getKey()); - } - - for (int count = 0; count < mapArr.size(); count++) { - String mimeType = (String) mapArr.get(count); - Integer pos = readerMap.get(mimeType); - newCatalog.addReader(mimeType, - (CatalogReader) - readerArr.get(pos.intValue())); - } - } - - /** - * Create a new Catalog object. - * - *

    This method constructs a new instance of the running Catalog - * class (which might be a subtype of com.sun.org.apache.xml.internal.resolver.Catalog). - * All new catalogs are managed by the same CatalogManager. - *

    - * - *

    N.B. All Catalog subtypes should call newCatalog() to construct - * a new Catalog. Do not simply use "new Subclass()" since that will - * confuse future subclasses.

    - */ - protected Catalog newCatalog() { - String catalogClass = this.getClass().getName(); - - try { - Catalog c = (Catalog) (Class.forName(catalogClass).newInstance()); - c.setCatalogManager(catalogManager); - copyReaders(c); - return c; - } catch (ClassNotFoundException cnfe) { - catalogManager.debug.message(1, "Class Not Found Exception: " + catalogClass); - } catch (IllegalAccessException iae) { - catalogManager.debug.message(1, "Illegal Access Exception: " + catalogClass); - } catch (InstantiationException ie) { - catalogManager.debug.message(1, "Instantiation Exception: " + catalogClass); - } catch (ClassCastException cce) { - catalogManager.debug.message(1, "Class Cast Exception: " + catalogClass); - } catch (Exception e) { - catalogManager.debug.message(1, "Other Exception: " + catalogClass); - } - - Catalog c = new Catalog(); - c.setCatalogManager(catalogManager); - copyReaders(c); - return c; - } - - /** - * Returns the current base URI. - */ - public String getCurrentBase() { - return base.toString(); - } - - /** - * Returns the default override setting associated with this - * catalog. - * - *

    All catalog files loaded by this catalog will have the - * initial override setting specified by this default.

    - */ - public String getDefaultOverride() { - if (default_override) { - return "yes"; - } else { - return "no"; - } - } - - /** - * Load the system catalog files. - * - *

    The method adds all of the - * catalogs specified in the xml.catalog.files property - * to the Catalog list.

    - * - * @throws MalformedURLException One of the system catalogs is - * identified with a filename that is not a valid URL. - * @throws IOException One of the system catalogs cannot be read. - */ - public void loadSystemCatalogs() - throws MalformedURLException, IOException { - - Vector catalogs = catalogManager.getCatalogFiles(); - if (catalogs != null) { - for (int count = 0; count < catalogs.size(); count++) { - catalogFiles.addElement(catalogs.elementAt(count)); - } - } - - if (catalogFiles.size() > 0) { - // This is a little odd. The parseCatalog() method expects - // a filename, but it adds that name to the end of the - // catalogFiles vector, and then processes that vector. - // This allows the system to handle CATALOG entries - // correctly. - // - // In this init case, we take the last element off the - // catalogFiles vector and pass it to parseCatalog. This - // will "do the right thing" in the init case, and allow - // parseCatalog() to do the right thing in the non-init - // case. Honest. - // - String catfile = (String) catalogFiles.lastElement(); - catalogFiles.removeElement(catfile); - parseCatalog(catfile); - } - } - - /** - * Parse a catalog file, augmenting internal data structures. - * - * @param fileName The filename of the catalog file to process - * - * @throws MalformedURLException The fileName cannot be turned into - * a valid URL. - * @throws IOException Error reading catalog file. - */ - public synchronized void parseCatalog(String fileName) - throws MalformedURLException, IOException { - - default_override = catalogManager.getPreferPublic(); - catalogManager.debug.message(4, "Parse catalog: " + fileName); - - // Put the file into the list of catalogs to process... - // In all cases except the case when initCatalog() is the - // caller, this will be the only catalog initially in the list... - catalogFiles.addElement(fileName); - - // Now process all the pending catalogs... - parsePendingCatalogs(); - } - - /** - * Parse a catalog file, augmenting internal data structures. - * - *

    Catalogs retrieved over the net may have an associated MIME type. - * The MIME type can be used to select an appropriate reader.

    - * - * @param mimeType The MIME type of the catalog file. - * @param is The InputStream from which the catalog should be read - * - * @throws CatalogException Failed to load catalog - * mimeType. - * @throws IOException Error reading catalog file. - */ - public synchronized void parseCatalog(String mimeType, InputStream is) - throws IOException, CatalogException { - - default_override = catalogManager.getPreferPublic(); - catalogManager.debug.message(4, "Parse " + mimeType + " catalog on input stream"); - - CatalogReader reader = null; - - if (readerMap.containsKey(mimeType)) { - int arrayPos = ((Integer) readerMap.get(mimeType)).intValue(); - reader = (CatalogReader) readerArr.get(arrayPos); - } - - if (reader == null) { - String msg = "No CatalogReader for MIME type: " + mimeType; - catalogManager.debug.message(2, msg); - throw new CatalogException(CatalogException.UNPARSEABLE, msg); - } - - reader.readCatalog(this, is); - - // Now process all the pending catalogs... - parsePendingCatalogs(); - } - - /** - * Parse a catalog document, augmenting internal data structures. - * - *

    This method supports catalog files stored in jar files: e.g., - * jar:file:///path/to/filename.jar!/path/to/catalog.xml". That URI - * doesn't survive transmogrification through the URI processing that - * the parseCatalog(String) performs and passing it as an input stream - * doesn't set the base URI appropriately.

    - * - *

    Written by Stefan Wachter (2002-09-26)

    - * - * @param aUrl The URL of the catalog document to process - * - * @throws IOException Error reading catalog file. - */ - public synchronized void parseCatalog(URL aUrl) throws IOException { - catalogCwd = aUrl; - base = aUrl; - - default_override = catalogManager.getPreferPublic(); - catalogManager.debug.message(4, "Parse catalog: " + aUrl.toString()); - - DataInputStream inStream = null; - boolean parsed = false; - - for (int count = 0; !parsed && count < readerArr.size(); count++) { - CatalogReader reader = (CatalogReader) readerArr.get(count); - - try { - inStream = new DataInputStream(aUrl.openStream()); - } catch (FileNotFoundException fnfe) { - // No catalog; give up! - break; - } - - try { - reader.readCatalog(this, inStream); - parsed=true; - } catch (CatalogException ce) { - if (ce.getExceptionType() == CatalogException.PARSE_FAILED) { - // give up! - break; - } else { - // try again! - } - } - - try { - inStream.close(); - } catch (IOException e) { - //nop - } - } - - if (parsed) parsePendingCatalogs(); - } - - /** - * Parse all of the pending catalogs. - * - *

    Catalogs may refer to other catalogs, this method parses - * all of the currently pending catalog files.

    - */ - protected synchronized void parsePendingCatalogs() - throws MalformedURLException, IOException { - - if (!localCatalogFiles.isEmpty()) { - // Move all the localCatalogFiles into the front of - // the catalogFiles queue - Vector newQueue = new Vector(); - Enumeration q = localCatalogFiles.elements(); - while (q.hasMoreElements()) { - newQueue.addElement(q.nextElement()); - } - - // Put the rest of the catalogs on the end of the new list - for (int curCat = 0; curCat < catalogFiles.size(); curCat++) { - String catfile = (String) catalogFiles.elementAt(curCat); - newQueue.addElement(catfile); - } - - catalogFiles = newQueue; - localCatalogFiles.clear(); - } - - // Suppose there are no catalog files to process, but the - // single catalog already parsed included some delegate - // entries? Make sure they don't get lost. - if (catalogFiles.isEmpty() && !localDelegate.isEmpty()) { - Enumeration e = localDelegate.elements(); - while (e.hasMoreElements()) { - catalogEntries.addElement(e.nextElement()); - } - localDelegate.clear(); - } - - // Now process all the files on the catalogFiles vector. This - // vector can grow during processing if CATALOG entries are - // encountered in the catalog - while (!catalogFiles.isEmpty()) { - String catfile = (String) catalogFiles.elementAt(0); - try { - catalogFiles.remove(0); - } catch (ArrayIndexOutOfBoundsException e) { - // can't happen - } - - if (catalogEntries.size() == 0 && catalogs.size() == 0) { - // We haven't parsed any catalogs yet, let this - // catalog be the first... - try { - parseCatalogFile(catfile); - } catch (CatalogException ce) { - System.out.println("FIXME: " + ce.toString()); - } - } else { - // This is a subordinate catalog. We save its name, - // but don't bother to load it unless it's necessary. - catalogs.addElement(catfile); - } - - if (!localCatalogFiles.isEmpty()) { - // Move all the localCatalogFiles into the front of - // the catalogFiles queue - Vector newQueue = new Vector(); - Enumeration q = localCatalogFiles.elements(); - while (q.hasMoreElements()) { - newQueue.addElement(q.nextElement()); - } - - // Put the rest of the catalogs on the end of the new list - for (int curCat = 0; curCat < catalogFiles.size(); curCat++) { - catfile = (String) catalogFiles.elementAt(curCat); - newQueue.addElement(catfile); - } - - catalogFiles = newQueue; - localCatalogFiles.clear(); - } - - if (!localDelegate.isEmpty()) { - Enumeration e = localDelegate.elements(); - while (e.hasMoreElements()) { - catalogEntries.addElement(e.nextElement()); - } - localDelegate.clear(); - } - } - - // We've parsed them all, reinit the vector... - catalogFiles.clear(); - } - - /** - * Parse a single catalog file, augmenting internal data structures. - * - * @param fileName The filename of the catalog file to process - * - * @throws MalformedURLException The fileName cannot be turned into - * a valid URL. - * @throws IOException Error reading catalog file. - */ - protected synchronized void parseCatalogFile(String fileName) - throws MalformedURLException, IOException, CatalogException { - - CatalogEntry entry; - - // The base-base is the cwd. If the catalog file is specified - // with a relative path, this assures that it gets resolved - // properly... - try { - // tack on a basename because URLs point to files not dirs - catalogCwd = FileURL.makeURL("basename"); - } catch (MalformedURLException e) { - catalogManager.debug.message(1, "Malformed URL on cwd", "user.dir"); - catalogCwd = null; - } - - // The initial base URI is the location of the catalog file - try { - base = new URL(catalogCwd, fixSlashes(fileName)); - } catch (MalformedURLException e) { - try { - base = new URL("file:" + fixSlashes(fileName)); - } catch (MalformedURLException e2) { - catalogManager.debug.message(1, "Malformed URL on catalog filename", - fixSlashes(fileName)); - base = null; - } - } - - catalogManager.debug.message(2, "Loading catalog", fileName); - catalogManager.debug.message(4, "Default BASE", base.toString()); - - fileName = base.toString(); - - DataInputStream inStream = null; - boolean parsed = false; - boolean notFound = false; - - for (int count = 0; !parsed && count < readerArr.size(); count++) { - CatalogReader reader = (CatalogReader) readerArr.get(count); - - try { - notFound = false; - inStream = new DataInputStream(base.openStream()); - } catch (FileNotFoundException fnfe) { - // No catalog; give up! - notFound = true; - break; - } - - try { - reader.readCatalog(this, inStream); - parsed = true; - } catch (CatalogException ce) { - if (ce.getExceptionType() == CatalogException.PARSE_FAILED) { - // give up! - break; - } else { - // try again! - } - } - - try { - inStream.close(); - } catch (IOException e) { - //nop - } - } - - if (!parsed) { - if (notFound) { - catalogManager.debug.message(3, "Catalog does not exist", fileName); - } else { - catalogManager.debug.message(1, "Failed to parse catalog", fileName); - } - } - } - - /** - * Cleanup and process a Catalog entry. - * - *

    This method processes each Catalog entry, changing mapped - * relative system identifiers into absolute ones (based on the current - * base URI), and maintaining other information about the current - * catalog.

    - * - * @param entry The CatalogEntry to process. - */ - public void addEntry(CatalogEntry entry) { - int type = entry.getEntryType(); - - if (type == BASE) { - String value = entry.getEntryArg(0); - URL newbase = null; - - if (base == null) { - catalogManager.debug.message(5, "BASE CUR", "null"); - } else { - catalogManager.debug.message(5, "BASE CUR", base.toString()); - } - catalogManager.debug.message(4, "BASE STR", value); - - try { - value = fixSlashes(value); - newbase = new URL(base, value); - } catch (MalformedURLException e) { - try { - newbase = new URL("file:" + value); - } catch (MalformedURLException e2) { - catalogManager.debug.message(1, "Malformed URL on base", value); - newbase = null; - } - } - - if (newbase != null) { - base = newbase; - } - - catalogManager.debug.message(5, "BASE NEW", base.toString()); - } else if (type == CATALOG) { - String fsi = makeAbsolute(entry.getEntryArg(0)); - - catalogManager.debug.message(4, "CATALOG", fsi); - - localCatalogFiles.addElement(fsi); - } else if (type == PUBLIC) { - String publicid = PublicId.normalize(entry.getEntryArg(0)); - String systemid = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, publicid); - entry.setEntryArg(1, systemid); - - catalogManager.debug.message(4, "PUBLIC", publicid, systemid); - - catalogEntries.addElement(entry); - } else if (type == SYSTEM) { - String systemid = normalizeURI(entry.getEntryArg(0)); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "SYSTEM", systemid, fsi); - - catalogEntries.addElement(entry); - } else if (type == URI) { - String uri = normalizeURI(entry.getEntryArg(0)); - String altURI = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(1, altURI); - - catalogManager.debug.message(4, "URI", uri, altURI); - - catalogEntries.addElement(entry); - } else if (type == DOCUMENT) { - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(0))); - entry.setEntryArg(0, fsi); - - catalogManager.debug.message(4, "DOCUMENT", fsi); - - catalogEntries.addElement(entry); - } else if (type == OVERRIDE) { - catalogManager.debug.message(4, "OVERRIDE", entry.getEntryArg(0)); - - catalogEntries.addElement(entry); - } else if (type == SGMLDECL) { - // meaningless in XML - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(0))); - entry.setEntryArg(0, fsi); - - catalogManager.debug.message(4, "SGMLDECL", fsi); - - catalogEntries.addElement(entry); - } else if (type == DELEGATE_PUBLIC) { - String ppi = PublicId.normalize(entry.getEntryArg(0)); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, ppi); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "DELEGATE_PUBLIC", ppi, fsi); - - addDelegate(entry); - } else if (type == DELEGATE_SYSTEM) { - String psi = normalizeURI(entry.getEntryArg(0)); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, psi); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "DELEGATE_SYSTEM", psi, fsi); - - addDelegate(entry); - } else if (type == DELEGATE_URI) { - String pui = normalizeURI(entry.getEntryArg(0)); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, pui); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "DELEGATE_URI", pui, fsi); - - addDelegate(entry); - } else if (type == REWRITE_SYSTEM) { - String psi = normalizeURI(entry.getEntryArg(0)); - String rpx = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, psi); - entry.setEntryArg(1, rpx); - - catalogManager.debug.message(4, "REWRITE_SYSTEM", psi, rpx); - - catalogEntries.addElement(entry); - } else if (type == REWRITE_URI) { - String pui = normalizeURI(entry.getEntryArg(0)); - String upx = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, pui); - entry.setEntryArg(1, upx); - - catalogManager.debug.message(4, "REWRITE_URI", pui, upx); - - catalogEntries.addElement(entry); - } else if (type == SYSTEM_SUFFIX) { - String pui = normalizeURI(entry.getEntryArg(0)); - String upx = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, pui); - entry.setEntryArg(1, upx); - - catalogManager.debug.message(4, "SYSTEM_SUFFIX", pui, upx); - - catalogEntries.addElement(entry); - } else if (type == URI_SUFFIX) { - String pui = normalizeURI(entry.getEntryArg(0)); - String upx = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(0, pui); - entry.setEntryArg(1, upx); - - catalogManager.debug.message(4, "URI_SUFFIX", pui, upx); - - catalogEntries.addElement(entry); - } else if (type == DOCTYPE) { - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "DOCTYPE", entry.getEntryArg(0), fsi); - - catalogEntries.addElement(entry); - } else if (type == DTDDECL) { - // meaningless in XML - String fpi = PublicId.normalize(entry.getEntryArg(0)); - entry.setEntryArg(0, fpi); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "DTDDECL", fpi, fsi); - - catalogEntries.addElement(entry); - } else if (type == ENTITY) { - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "ENTITY", entry.getEntryArg(0), fsi); - - catalogEntries.addElement(entry); - } else if (type == LINKTYPE) { - // meaningless in XML - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "LINKTYPE", entry.getEntryArg(0), fsi); - - catalogEntries.addElement(entry); - } else if (type == NOTATION) { - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "NOTATION", entry.getEntryArg(0), fsi); - - catalogEntries.addElement(entry); - } else { - catalogEntries.addElement(entry); - } - } - - /** - * Handle unknown CatalogEntry types. - * - *

    This method exists to allow subclasses to deal with unknown - * entry types.

    - */ - public void unknownEntry(Vector strings) { - if (strings != null && strings.size() > 0) { - String keyword = (String) strings.elementAt(0); - catalogManager.debug.message(2, "Unrecognized token parsing catalog", keyword); - } - } - - /** - * Parse all subordinate catalogs. - * - *

    This method recursively parses all of the subordinate catalogs. - * If this method does not throw an exception, you can be confident that - * no subsequent call to any resolve*() method will either, with two - * possible exceptions:

    - * - *
      - *
    1. Delegated catalogs are re-parsed each time they are needed - * (because a variable list of them may be needed in each case, - * depending on the length of the matching partial public identifier).

      - *

      But they are parsed by this method, so as long as they don't - * change or disappear while the program is running, they shouldn't - * generate errors later if they don't generate errors now.

      - *
    2. If you add new catalogs with parseCatalog, they - * won't be loaded until they are needed or until you call - * parseAllCatalogs again.

      - *
    - * - *

    On the other hand, if you don't call this method, you may - * successfully parse documents without having to load all possible - * catalogs.

    - * - * @throws MalformedURLException The filename (URL) for a - * subordinate or delegated catalog is not a valid URL. - * @throws IOException Error reading some subordinate or delegated - * catalog file. - */ - public void parseAllCatalogs() - throws MalformedURLException, IOException { - - // Parse all the subordinate catalogs - for (int catPos = 0; catPos < catalogs.size(); catPos++) { - Catalog c = null; - - try { - c = (Catalog) catalogs.elementAt(catPos); - } catch (ClassCastException e) { - String catfile = (String) catalogs.elementAt(catPos); - c = newCatalog(); - - c.parseCatalog(catfile); - catalogs.setElementAt(c, catPos); - c.parseAllCatalogs(); - } - } - - // Parse all the DELEGATE catalogs - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == DELEGATE_PUBLIC - || e.getEntryType() == DELEGATE_SYSTEM - || e.getEntryType() == DELEGATE_URI) { - Catalog dcat = newCatalog(); - dcat.parseCatalog(e.getEntryArg(1)); - } - } - } - - - /** - * Return the applicable DOCTYPE system identifier. - * - * @param entityName The name of the entity (element) for which - * a doctype is required. - * @param publicId The nominal public identifier for the doctype - * (as provided in the source document). - * @param systemId The nominal system identifier for the doctype - * (as provided in the source document). - * - * @return The system identifier to use for the doctype. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveDoctype(String entityName, - String publicId, - String systemId) - throws MalformedURLException, IOException { - String resolved = null; - - catalogManager.debug.message(3, "resolveDoctype(" - +entityName+","+publicId+","+systemId+")"); - - systemId = normalizeURI(systemId); - - if (publicId != null && publicId.startsWith("urn:publicid:")) { - publicId = PublicId.decodeURN(publicId); - } - - if (systemId != null && systemId.startsWith("urn:publicid:")) { - systemId = PublicId.decodeURN(systemId); - if (publicId != null && !publicId.equals(systemId)) { - catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); - systemId = null; - } else { - publicId = systemId; - systemId = null; - } - } - - if (systemId != null) { - // If there's a SYSTEM entry in this catalog, use it - resolved = resolveLocalSystem(systemId); - if (resolved != null) { - return resolved; - } - } - - if (publicId != null) { - // If there's a PUBLIC entry in this catalog, use it - resolved = resolveLocalPublic(DOCTYPE, - entityName, - publicId, - systemId); - if (resolved != null) { - return resolved; - } - } - - // If there's a DOCTYPE entry in this catalog, use it - boolean over = default_override; - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == OVERRIDE) { - over = e.getEntryArg(0).equalsIgnoreCase("YES"); - continue; - } - - if (e.getEntryType() == DOCTYPE - && e.getEntryArg(0).equals(entityName)) { - if (over || systemId == null) { - return e.getEntryArg(1); - } - } - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(DOCTYPE, - entityName, - publicId, - systemId); - } - - /** - * Return the applicable DOCUMENT entry. - * - * @return The system identifier to use for the doctype. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveDocument() - throws MalformedURLException, IOException { - // If there's a DOCUMENT entry, return it - - catalogManager.debug.message(3, "resolveDocument"); - - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == DOCUMENT) { - return e.getEntryArg(0); - } - } - - return resolveSubordinateCatalogs(DOCUMENT, - null, null, null); - } - - /** - * Return the applicable ENTITY system identifier. - * - * @param entityName The name of the entity for which - * a system identifier is required. - * @param publicId The nominal public identifier for the entity - * (as provided in the source document). - * @param systemId The nominal system identifier for the entity - * (as provided in the source document). - * - * @return The system identifier to use for the entity. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveEntity(String entityName, - String publicId, - String systemId) - throws MalformedURLException, IOException { - String resolved = null; - - catalogManager.debug.message(3, "resolveEntity(" - +entityName+","+publicId+","+systemId+")"); - - systemId = normalizeURI(systemId); - - if (publicId != null && publicId.startsWith("urn:publicid:")) { - publicId = PublicId.decodeURN(publicId); - } - - if (systemId != null && systemId.startsWith("urn:publicid:")) { - systemId = PublicId.decodeURN(systemId); - if (publicId != null && !publicId.equals(systemId)) { - catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); - systemId = null; - } else { - publicId = systemId; - systemId = null; - } - } - - if (systemId != null) { - // If there's a SYSTEM entry in this catalog, use it - resolved = resolveLocalSystem(systemId); - if (resolved != null) { - return resolved; - } - } - - if (publicId != null) { - // If there's a PUBLIC entry in this catalog, use it - resolved = resolveLocalPublic(ENTITY, - entityName, - publicId, - systemId); - if (resolved != null) { - return resolved; - } - } - - // If there's a ENTITY entry in this catalog, use it - boolean over = default_override; - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == OVERRIDE) { - over = e.getEntryArg(0).equalsIgnoreCase("YES"); - continue; - } - - if (e.getEntryType() == ENTITY - && e.getEntryArg(0).equals(entityName)) { - if (over || systemId == null) { - return e.getEntryArg(1); - } - } - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(ENTITY, - entityName, - publicId, - systemId); - } - - /** - * Return the applicable NOTATION system identifier. - * - * @param notationName The name of the notation for which - * a doctype is required. - * @param publicId The nominal public identifier for the notation - * (as provided in the source document). - * @param systemId The nominal system identifier for the notation - * (as provided in the source document). - * - * @return The system identifier to use for the notation. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveNotation(String notationName, - String publicId, - String systemId) - throws MalformedURLException, IOException { - String resolved = null; - - catalogManager.debug.message(3, "resolveNotation(" - +notationName+","+publicId+","+systemId+")"); - - systemId = normalizeURI(systemId); - - if (publicId != null && publicId.startsWith("urn:publicid:")) { - publicId = PublicId.decodeURN(publicId); - } - - if (systemId != null && systemId.startsWith("urn:publicid:")) { - systemId = PublicId.decodeURN(systemId); - if (publicId != null && !publicId.equals(systemId)) { - catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); - systemId = null; - } else { - publicId = systemId; - systemId = null; - } - } - - if (systemId != null) { - // If there's a SYSTEM entry in this catalog, use it - resolved = resolveLocalSystem(systemId); - if (resolved != null) { - return resolved; - } - } - - if (publicId != null) { - // If there's a PUBLIC entry in this catalog, use it - resolved = resolveLocalPublic(NOTATION, - notationName, - publicId, - systemId); - if (resolved != null) { - return resolved; - } - } - - // If there's a NOTATION entry in this catalog, use it - boolean over = default_override; - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == OVERRIDE) { - over = e.getEntryArg(0).equalsIgnoreCase("YES"); - continue; - } - - if (e.getEntryType() == NOTATION - && e.getEntryArg(0).equals(notationName)) { - if (over || systemId == null) { - return e.getEntryArg(1); - } - } - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(NOTATION, - notationName, - publicId, - systemId); - } - - /** - * Return the applicable PUBLIC or SYSTEM identifier. - * - *

    This method searches the Catalog and returns the system - * identifier specified for the given system or - * public identifiers. If - * no appropriate PUBLIC or SYSTEM entry is found in the Catalog, - * null is returned.

    - * - * @param publicId The public identifier to locate in the catalog. - * Public identifiers are normalized before comparison. - * @param systemId The nominal system identifier for the entity - * in question (as provided in the source document). - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - * - * @return The system identifier to use. - * Note that the nominal system identifier is not returned if a - * match is not found in the catalog, instead null is returned - * to indicate that no match was found. - */ - public String resolvePublic(String publicId, String systemId) - throws MalformedURLException, IOException { - - catalogManager.debug.message(3, "resolvePublic("+publicId+","+systemId+")"); - - systemId = normalizeURI(systemId); - - if (publicId != null && publicId.startsWith("urn:publicid:")) { - publicId = PublicId.decodeURN(publicId); - } - - if (systemId != null && systemId.startsWith("urn:publicid:")) { - systemId = PublicId.decodeURN(systemId); - if (publicId != null && !publicId.equals(systemId)) { - catalogManager.debug.message(1, "urn:publicid: system identifier differs from public identifier; using public identifier"); - systemId = null; - } else { - publicId = systemId; - systemId = null; - } - } - - // If there's a SYSTEM entry in this catalog, use it - if (systemId != null) { - String resolved = resolveLocalSystem(systemId); - if (resolved != null) { - return resolved; - } - } - - // If there's a PUBLIC entry in this catalog, use it - String resolved = resolveLocalPublic(PUBLIC, - null, - publicId, - systemId); - if (resolved != null) { - return resolved; - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(PUBLIC, - null, - publicId, - systemId); - } - - /** - * Return the applicable PUBLIC or SYSTEM identifier. - * - *

    This method searches the Catalog and returns the system - * identifier specified for the given system or public identifiers. - * If no appropriate PUBLIC or SYSTEM entry is found in the Catalog, - * delegated Catalogs are interrogated.

    - * - *

    There are four possible cases:

    - * - *
      - *
    • If the system identifier provided matches a SYSTEM entry - * in the current catalog, the SYSTEM entry is returned. - *
    • If the system identifier is not null, the PUBLIC entries - * that were encountered when OVERRIDE YES was in effect are - * interrogated and the first matching entry is returned.
    • - *
    • If the system identifier is null, then all of the PUBLIC - * entries are interrogated and the first matching entry - * is returned. This may not be the same as the preceding case, if - * some PUBLIC entries are encountered when OVERRIDE NO is in effect. In - * XML, the only place where a public identifier may occur without - * a system identifier is in a notation declaration.
    • - *
    • Finally, if the public identifier matches one of the partial - * public identifiers specified in a DELEGATE* entry in - * the Catalog, the delegated catalog is interrogated. The first - * time that the delegated catalog is required, it will be - * retrieved and parsed. It is subsequently cached. - *
    • - *
    - * - * @param entityType The CatalogEntry type for which this query is - * being conducted. This is necessary in order to do the approprate - * query on a delegated catalog. - * @param entityName The name of the entity being searched for, if - * appropriate. - * @param publicId The public identifier of the entity in question. - * @param systemId The nominal system identifier for the entity - * in question (as provided in the source document). - * - * @throws MalformedURLException The formal system identifier of a - * delegated catalog cannot be turned into a valid URL. - * @throws IOException Error reading delegated catalog file. - * - * @return The system identifier to use. - * Note that the nominal system identifier is not returned if a - * match is not found in the catalog, instead null is returned - * to indicate that no match was found. - */ - protected synchronized String resolveLocalPublic(int entityType, - String entityName, - String publicId, - String systemId) - throws MalformedURLException, IOException { - - // Always normalize the public identifier before attempting a match - publicId = PublicId.normalize(publicId); - - // If there's a SYSTEM entry in this catalog, use it - if (systemId != null) { - String resolved = resolveLocalSystem(systemId); - if (resolved != null) { - return resolved; - } - } - - // If there's a PUBLIC entry in this catalog, use it - boolean over = default_override; - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == OVERRIDE) { - over = e.getEntryArg(0).equalsIgnoreCase("YES"); - continue; - } - - if (e.getEntryType() == PUBLIC - && e.getEntryArg(0).equals(publicId)) { - if (over || systemId == null) { - return e.getEntryArg(1); - } - } - } - - // If there's a DELEGATE_PUBLIC entry in this catalog, use it - over = default_override; - en = catalogEntries.elements(); - Vector delCats = new Vector(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == OVERRIDE) { - over = e.getEntryArg(0).equalsIgnoreCase("YES"); - continue; - } - - if (e.getEntryType() == DELEGATE_PUBLIC - && (over || systemId == null)) { - String p = (String) e.getEntryArg(0); - if (p.length() <= publicId.length() - && p.equals(publicId.substring(0, p.length()))) { - // delegate this match to the other catalog - - delCats.addElement(e.getEntryArg(1)); - } - } - } - - if (delCats.size() > 0) { - Enumeration enCats = delCats.elements(); - - if (catalogManager.debug.getDebug() > 1) { - catalogManager.debug.message(2, "Switching to delegated catalog(s):"); - while (enCats.hasMoreElements()) { - String delegatedCatalog = (String) enCats.nextElement(); - catalogManager.debug.message(2, "\t" + delegatedCatalog); - } - } - - Catalog dcat = newCatalog(); - - enCats = delCats.elements(); - while (enCats.hasMoreElements()) { - String delegatedCatalog = (String) enCats.nextElement(); - dcat.parseCatalog(delegatedCatalog); - } - - return dcat.resolvePublic(publicId, null); - } - - // Nada! - return null; - } - - /** - * Return the applicable SYSTEM system identifier. - * - *

    If a SYSTEM entry exists in the Catalog - * for the system ID specified, return the mapped value.

    - * - *

    On Windows-based operating systems, the comparison between - * the system identifier provided and the SYSTEM entries in the - * Catalog is case-insensitive.

    - * - * @param systemId The system ID to locate in the catalog. - * - * @return The resolved system identifier. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveSystem(String systemId) - throws MalformedURLException, IOException { - - catalogManager.debug.message(3, "resolveSystem("+systemId+")"); - - systemId = normalizeURI(systemId); - - if (systemId != null && systemId.startsWith("urn:publicid:")) { - systemId = PublicId.decodeURN(systemId); - return resolvePublic(systemId, null); - } - - // If there's a SYSTEM entry in this catalog, use it - if (systemId != null) { - String resolved = resolveLocalSystem(systemId); - if (resolved != null) { - return resolved; - } - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(SYSTEM, - null, - null, - systemId); - } - - /** - * Return the applicable SYSTEM system identifier in this - * catalog. - * - *

    If a SYSTEM entry exists in the catalog file - * for the system ID specified, return the mapped value.

    - * - * @param systemId The system ID to locate in the catalog - * - * @return The mapped system identifier or null - */ - protected String resolveLocalSystem(String systemId) - throws MalformedURLException, IOException { - - String osname = SecuritySupport.getSystemProperty("os.name"); - boolean windows = (osname.indexOf("Windows") >= 0); - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == SYSTEM - && (e.getEntryArg(0).equals(systemId) - || (windows - && e.getEntryArg(0).equalsIgnoreCase(systemId)))) { - return e.getEntryArg(1); - } - } - - // If there's a REWRITE_SYSTEM entry in this catalog, use it - en = catalogEntries.elements(); - String startString = null; - String prefix = null; - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - - if (e.getEntryType() == REWRITE_SYSTEM) { - String p = (String) e.getEntryArg(0); - if (p.length() <= systemId.length() - && p.equals(systemId.substring(0, p.length()))) { - // Is this the longest prefix? - if (startString == null - || p.length() > startString.length()) { - startString = p; - prefix = e.getEntryArg(1); - } - } - } - } - - if (prefix != null) { - // return the systemId with the new prefix - return prefix + systemId.substring(startString.length()); - } - - // If there's a SYSTEM_SUFFIX entry in this catalog, use it - en = catalogEntries.elements(); - String suffixString = null; - String suffixURI = null; - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - - if (e.getEntryType() == SYSTEM_SUFFIX) { - String p = (String) e.getEntryArg(0); - if (p.length() <= systemId.length() - && systemId.endsWith(p)) { - // Is this the longest prefix? - if (suffixString == null - || p.length() > suffixString.length()) { - suffixString = p; - suffixURI = e.getEntryArg(1); - } - } - } - } - - if (suffixURI != null) { - // return the systemId for the suffix - return suffixURI; - } - - // If there's a DELEGATE_SYSTEM entry in this catalog, use it - en = catalogEntries.elements(); - Vector delCats = new Vector(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - - if (e.getEntryType() == DELEGATE_SYSTEM) { - String p = (String) e.getEntryArg(0); - if (p.length() <= systemId.length() - && p.equals(systemId.substring(0, p.length()))) { - // delegate this match to the other catalog - - delCats.addElement(e.getEntryArg(1)); - } - } - } - - if (delCats.size() > 0) { - Enumeration enCats = delCats.elements(); - - if (catalogManager.debug.getDebug() > 1) { - catalogManager.debug.message(2, "Switching to delegated catalog(s):"); - while (enCats.hasMoreElements()) { - String delegatedCatalog = (String) enCats.nextElement(); - catalogManager.debug.message(2, "\t" + delegatedCatalog); - } - } - - Catalog dcat = newCatalog(); - - enCats = delCats.elements(); - while (enCats.hasMoreElements()) { - String delegatedCatalog = (String) enCats.nextElement(); - dcat.parseCatalog(delegatedCatalog); - } - - return dcat.resolveSystem(systemId); - } - - return null; - } - - /** - * Return the applicable URI. - * - *

    If a URI entry exists in the Catalog - * for the URI specified, return the mapped value.

    - * - *

    URI comparison is case sensitive.

    - * - * @param uri The URI to locate in the catalog. - * - * @return The resolved URI. - * - * @throws MalformedURLException The system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveURI(String uri) - throws MalformedURLException, IOException { - - catalogManager.debug.message(3, "resolveURI("+uri+")"); - - uri = normalizeURI(uri); - - if (uri != null && uri.startsWith("urn:publicid:")) { - uri = PublicId.decodeURN(uri); - return resolvePublic(uri, null); - } - - // If there's a URI entry in this catalog, use it - if (uri != null) { - String resolved = resolveLocalURI(uri); - if (resolved != null) { - return resolved; - } - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(URI, - null, - null, - uri); - } - - /** - * Return the applicable URI in this catalog. - * - *

    If a URI entry exists in the catalog file - * for the URI specified, return the mapped value.

    - * - * @param uri The URI to locate in the catalog - * - * @return The mapped URI or null - */ - protected String resolveLocalURI(String uri) - throws MalformedURLException, IOException { - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == URI - && (e.getEntryArg(0).equals(uri))) { - return e.getEntryArg(1); - } - } - - // If there's a REWRITE_URI entry in this catalog, use it - en = catalogEntries.elements(); - String startString = null; - String prefix = null; - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - - if (e.getEntryType() == REWRITE_URI) { - String p = (String) e.getEntryArg(0); - if (p.length() <= uri.length() - && p.equals(uri.substring(0, p.length()))) { - // Is this the longest prefix? - if (startString == null - || p.length() > startString.length()) { - startString = p; - prefix = e.getEntryArg(1); - } - } - } - } - - if (prefix != null) { - // return the uri with the new prefix - return prefix + uri.substring(startString.length()); - } - - // If there's a URI_SUFFIX entry in this catalog, use it - en = catalogEntries.elements(); - String suffixString = null; - String suffixURI = null; - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - - if (e.getEntryType() == URI_SUFFIX) { - String p = (String) e.getEntryArg(0); - if (p.length() <= uri.length() - && uri.endsWith(p)) { - // Is this the longest prefix? - if (suffixString == null - || p.length() > suffixString.length()) { - suffixString = p; - suffixURI = e.getEntryArg(1); - } - } - } - } - - if (suffixURI != null) { - // return the uri for the suffix - return suffixURI; - } - - // If there's a DELEGATE_URI entry in this catalog, use it - en = catalogEntries.elements(); - Vector delCats = new Vector(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - - if (e.getEntryType() == DELEGATE_URI) { - String p = (String) e.getEntryArg(0); - if (p.length() <= uri.length() - && p.equals(uri.substring(0, p.length()))) { - // delegate this match to the other catalog - - delCats.addElement(e.getEntryArg(1)); - } - } - } - - if (delCats.size() > 0) { - Enumeration enCats = delCats.elements(); - - if (catalogManager.debug.getDebug() > 1) { - catalogManager.debug.message(2, "Switching to delegated catalog(s):"); - while (enCats.hasMoreElements()) { - String delegatedCatalog = (String) enCats.nextElement(); - catalogManager.debug.message(2, "\t" + delegatedCatalog); - } - } - - Catalog dcat = newCatalog(); - - enCats = delCats.elements(); - while (enCats.hasMoreElements()) { - String delegatedCatalog = (String) enCats.nextElement(); - dcat.parseCatalog(delegatedCatalog); - } - - return dcat.resolveURI(uri); - } - - return null; - } - - /** - * Search the subordinate catalogs, in order, looking for a match. - * - *

    This method searches the Catalog and returns the system - * identifier specified for the given entity type with the given - * name, public, and system identifiers. In some contexts, these - * may be null.

    - * - * @param entityType The CatalogEntry type for which this query is - * being conducted. This is necessary in order to do the approprate - * query on a subordinate catalog. - * @param entityName The name of the entity being searched for, if - * appropriate. - * @param publicId The public identifier of the entity in question - * (as provided in the source document). - * @param systemId The nominal system identifier for the entity - * in question (as provided in the source document). This parameter is - * overloaded for the URI entry type. - * - * @throws MalformedURLException The formal system identifier of a - * delegated catalog cannot be turned into a valid URL. - * @throws IOException Error reading delegated catalog file. - * - * @return The system identifier to use. - * Note that the nominal system identifier is not returned if a - * match is not found in the catalog, instead null is returned - * to indicate that no match was found. - */ - protected synchronized String resolveSubordinateCatalogs(int entityType, - String entityName, - String publicId, - String systemId) - throws MalformedURLException, IOException { - - for (int catPos = 0; catPos < catalogs.size(); catPos++) { - Catalog c = null; - - try { - c = (Catalog) catalogs.elementAt(catPos); - } catch (ClassCastException e) { - String catfile = (String) catalogs.elementAt(catPos); - c = newCatalog(); - - try { - c.parseCatalog(catfile); - } catch (MalformedURLException mue) { - catalogManager.debug.message(1, "Malformed Catalog URL", catfile); - } catch (FileNotFoundException fnfe) { - catalogManager.debug.message(1, "Failed to load catalog, file not found", - catfile); - } catch (IOException ioe) { - catalogManager.debug.message(1, "Failed to load catalog, I/O error", catfile); - } - - catalogs.setElementAt(c, catPos); - } - - String resolved = null; - - // Ok, now what are we supposed to call here? - if (entityType == DOCTYPE) { - resolved = c.resolveDoctype(entityName, - publicId, - systemId); - } else if (entityType == DOCUMENT) { - resolved = c.resolveDocument(); - } else if (entityType == ENTITY) { - resolved = c.resolveEntity(entityName, - publicId, - systemId); - } else if (entityType == NOTATION) { - resolved = c.resolveNotation(entityName, - publicId, - systemId); - } else if (entityType == PUBLIC) { - resolved = c.resolvePublic(publicId, systemId); - } else if (entityType == SYSTEM) { - resolved = c.resolveSystem(systemId); - } else if (entityType == URI) { - resolved = c.resolveURI(systemId); - } - - if (resolved != null) { - return resolved; - } - } - - return null; - } - - // ----------------------------------------------------------------- - - /** - * Replace backslashes with forward slashes. (URLs always use - * forward slashes.) - * - * @param sysid The input system identifier. - * @return The same system identifier with backslashes turned into - * forward slashes. - */ - protected String fixSlashes (String sysid) { - return sysid.replace('\\', '/'); - } - - /** - * Construct an absolute URI from a relative one, using the current - * base URI. - * - * @param sysid The (possibly relative) system identifier - * @return The system identifier made absolute with respect to the - * current {@link #base}. - */ - protected String makeAbsolute(String sysid) { - URL local = null; - - sysid = fixSlashes(sysid); - - try { - local = new URL(base, sysid); - } catch (MalformedURLException e) { - catalogManager.debug.message(1, "Malformed URL on system identifier", sysid); - } - - if (local != null) { - return local.toString(); - } else { - return sysid; - } - } - - - /** - * Perform character normalization on a URI reference. - * - * @param uriref The URI reference - * @return The normalized URI reference. - */ - protected String normalizeURI(String uriref) { - if (uriref == null) { - return null; - } - final int length = uriref.length(); - for (int i = 0; i < length; ++i) { - char c = uriref.charAt(i); - if ((c <= 0x20) // ctrl - || (c > 0x7F) // high ascii - || (c == 0x22) // " - || (c == 0x3C) // < - || (c == 0x3E) // > - || (c == 0x5C) // \ - || (c == 0x5E) // ^ - || (c == 0x60) // ` - || (c == 0x7B) // { - || (c == 0x7C) // | - || (c == 0x7D) // } - || (c == 0x7F)) { - return normalizeURI(uriref, i); - } - } - return uriref; - } - - /** - * Perform character normalization on a URI reference. - * - * @param uriref The URI reference - * @param index The index of the first character which requires escaping. - * @return The normalized URI reference. - */ - private String normalizeURI(String uriref, int index) { - final StringBuilder buffer = new StringBuilder(); - for (int i = 0; i < index; ++i) { - buffer.append(uriref.charAt(i)); - } - final byte[] bytes; - try { - bytes = uriref.substring(index).getBytes("UTF-8"); - } - catch (UnsupportedEncodingException uee) { - // this can't happen - catalogManager.debug.message(1, "UTF-8 is an unsupported encoding!?"); - return uriref; - } - for (int count = 0; count < bytes.length; ++count) { - int ch = bytes[count] & 0xFF; - if ((ch <= 0x20) // ctrl - || (ch > 0x7F) // high ascii - || (ch == 0x22) // " - || (ch == 0x3C) // < - || (ch == 0x3E) // > - || (ch == 0x5C) // \ - || (ch == 0x5E) // ^ - || (ch == 0x60) // ` - || (ch == 0x7B) // { - || (ch == 0x7C) // | - || (ch == 0x7D) // } - || (ch == 0x7F)) { - writeEncodedByte(ch, buffer); - } - else { - buffer.append((char) bytes[count]); - } - } - return buffer.toString(); - } - - /** - * Perform %-encoding on a single byte. - * - * @param b The 8-bit integer that represents the byte. (Bytes are signed - * but encoding needs to look at the bytes unsigned.) - * @return The %-encoded string for the byte in question. - */ - protected String encodedByte(int b) { - StringBuilder buffer = new StringBuilder(3); - writeEncodedByte(b, buffer); - return buffer.toString(); - } - - /** - * Perform %-encoding on a single byte. - * - * @param b The 8-bit integer that represents the byte. (Bytes are signed - * but encoding needs to look at the bytes unsigned.) - * @param buffer The target for the %-encoded string for the byte in question. - */ - private void writeEncodedByte(int b, StringBuilder buffer) { - String hex = Integer.toHexString(b).toUpperCase(Locale.ENGLISH); - if (hex.length() < 2) { - buffer.append("%0"); - buffer.append(hex); - } - else { - buffer.append('%'); - buffer.append(hex); - } - } - - // ----------------------------------------------------------------- - - /** - * Add to the current list of delegated catalogs. - * - *

    This method always constructs the {@link #localDelegate} - * vector so that it is ordered by length of partial - * public identifier.

    - * - * @param entry The DELEGATE catalog entry - */ - protected void addDelegate(CatalogEntry entry) { - int pos = 0; - String partial = entry.getEntryArg(0); - - Enumeration local = localDelegate.elements(); - while (local.hasMoreElements()) { - CatalogEntry dpe = (CatalogEntry) local.nextElement(); - String dp = dpe.getEntryArg(0); - if (dp.equals(partial)) { - // we already have this prefix - return; - } - if (dp.length() > partial.length()) { - pos++; - } - if (dp.length() < partial.length()) { - break; - } - } - - // now insert partial into the vector at [pos] - if (localDelegate.size() == 0) { - localDelegate.addElement(entry); - } else { - localDelegate.insertElementAt(entry, pos); - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java deleted file mode 100644 index 19c2ceda7e7..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - */ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver; - -import java.util.Map; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Represents a Catalog entry. - * - *

    Instances of this class represent individual entries - * in a Catalog.

    - * - *

    Each catalog entry has a unique name and is associated with - * an arbitrary number of arguments (all strings). For example, the - * TR9401 catalog entry "PUBLIC" has two arguments, a public identifier - * and a system identifier. Each entry has a unique numeric type, - * assigned automatically when the entry type is created.

    - * - *

    The number and type of catalog entries is maintained - * statically. Catalog classes, or their subclasses, can add - * new entry types, but all Catalog objects share the same global pool - * of types.

    - * - *

    Initially there are no valid entries.

    - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class CatalogEntry { - /** The nextEntry is the ordinal number of the next entry type. */ - static AtomicInteger nextEntry = new AtomicInteger(0); - - /** - * The entryTypes vector maps catalog entry names - * (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.). - * Names are case sensitive. - */ - static final Map entryTypes = new ConcurrentHashMap<>(); - - /** The entryTypes vector maps catalog entry types to the - number of arguments they're required to have. */ - static final Vector entryArgs = new Vector(); - - /** - * Adds a new catalog entry type. - * - * @param name The name of the catalog entry type. This must be - * unique among all types and is case-sensitive. (Adding a duplicate - * name effectively replaces the old type with the new type.) - * @param numArgs The number of arguments that this entry type - * is required to have. There is no provision for variable numbers - * of arguments. - * @return The type for the new entry. - */ - static int addEntryType(String name, int numArgs) { - final int index = nextEntry.getAndIncrement(); - entryTypes.put(name, index); - entryArgs.add(index, numArgs); - - return index; - } - - /** - * Lookup an entry type - * - * @param name The name of the catalog entry type. - * @return The type of the catalog entry with the specified name. - * @throws InvalidCatalogEntryTypeException if no entry has the - * specified name. - */ - public static int getEntryType(String name) - throws CatalogException { - if (!entryTypes.containsKey(name)) { - throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); - } - - Integer iType = entryTypes.get(name); - - if (iType == null) { - throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); - } - - return iType; - } - - /** - * Find out how many arguments an entry is required to have. - * - * @param name The name of the catalog entry type. - * @return The number of arguments that entry type is required to have. - * @throws InvalidCatalogEntryTypeException if no entry has the - * specified name. - */ - public static int getEntryArgCount(String name) - throws CatalogException { - return getEntryArgCount(getEntryType(name)); - } - - /** - * Find out how many arguments an entry is required to have. - * - * @param type A valid catalog entry type. - * @return The number of arguments that entry type is required to have. - * @throws InvalidCatalogEntryTypeException if the type is invalid. - */ - public static int getEntryArgCount(int type) - throws CatalogException { - try { - Integer iArgs = (Integer) entryArgs.get(type); - return iArgs.intValue(); - } catch (ArrayIndexOutOfBoundsException e) { - throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); - } - } - - /** The entry type of this entry */ - protected int entryType = 0; - - /** The arguments associated with this entry */ - protected Vector args = null; - - /** - * Null constructor; something for subclasses to call. - */ - public CatalogEntry() {} - - /** - * Construct a catalog entry of the specified type. - * - * @param name The name of the entry type - * @param args A String Vector of arguments - * @throws InvalidCatalogEntryTypeException if no such entry type - * exists. - * @throws InvalidCatalogEntryException if the wrong number of arguments - * is passed. - */ - public CatalogEntry(String name, Vector args) - throws CatalogException { - Integer iType = entryTypes.get(name); - - if (iType == null) { - throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); - } - - int type = iType; - - try { - Integer iArgs = (Integer) entryArgs.get(type); - if (iArgs.intValue() != args.size()) { - throw new CatalogException(CatalogException.INVALID_ENTRY); - } - } catch (ArrayIndexOutOfBoundsException e) { - throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); - } - - entryType = type; - this.args = args; - } - - /** - * Construct a catalog entry of the specified type. - * - * @param type The entry type - * @param args A String Vector of arguments - * @throws InvalidCatalogEntryTypeException if no such entry type - * exists. - * @throws InvalidCatalogEntryException if the wrong number of arguments - * is passed. - */ - public CatalogEntry(int type, Vector args) - throws CatalogException { - try { - Integer iArgs = (Integer) entryArgs.get(type); - if (iArgs.intValue() != args.size()) { - throw new CatalogException(CatalogException.INVALID_ENTRY); - } - } catch (ArrayIndexOutOfBoundsException e) { - throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); - } - - entryType = type; - this.args = args; - } - - /** - * Get the entry type. - * - * @return The entry type of the CatalogEntry - */ - public int getEntryType() { - return entryType; - } - - /** - * Get an entry argument. - * - * @param argNum The argument number (arguments are numbered from 0). - * @return The specified argument or null if an invalid argNum is - * provided. - */ - public String getEntryArg(int argNum) { - try { - String arg = (String) args.get(argNum); - return arg; - } catch (ArrayIndexOutOfBoundsException e) { - return null; - } - } - - /** - * Set an entry argument. - * - *

    Catalogs sometimes need to adjust the catlog entry parameters, - * for example to make a relative URI absolute with respect to the - * current base URI. But in general, this function should only be - * called shortly after object creation to do some sort of cleanup. - * Catalog entries should not mutate over time.

    - * - * @param argNum The argument number (arguments are numbered from 0). - * @throws ArrayIndexOutOfBoundsException if an invalid argument - * number is provided. - */ - public void setEntryArg(int argNum, String newspec) - throws ArrayIndexOutOfBoundsException { - args.set(argNum, newspec); - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogException.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogException.java deleted file mode 100644 index 1fc92db135b..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogException.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver; - -/** - * Signal Catalog exception. - * - *

    This exception is thrown if an error occurs loading a - * catalog file.

    - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class CatalogException extends Exception { - - private static final long serialVersionUID = 4007157171817798450L; - - /** A wrapper around another exception */ - public static final int WRAPPER = 1; - /** An invalid entry */ - public static final int INVALID_ENTRY = 2; - /** An invalid entry type */ - public static final int INVALID_ENTRY_TYPE = 3; - /** Could not instantiate an XML parser */ - public static final int NO_XML_PARSER = 4; - /** Unknown XML format */ - public static final int UNKNOWN_FORMAT = 5; - /** Unparseable XML catalog (not XML)*/ - public static final int UNPARSEABLE = 6; - /** XML but parse failed */ - public static final int PARSE_FAILED = 7; - /** Text catalog ended in mid-comment */ - public static final int UNENDED_COMMENT = 8; - - /** - * The embedded exception if tunnelling, or null. - */ - private final Exception exception; - private final int exceptionType; - - /** - * Create a new CatalogException. - * - * @param type The exception type - * @param message The error or warning message. - */ - public CatalogException (int type, String message) { - super(message); - this.exceptionType = type; - this.exception = null; - } - - /** - * Create a new CatalogException. - * - * @param type The exception type - */ - public CatalogException (int type) { - super("Catalog Exception " + type); - this.exceptionType = type; - this.exception = null; - } - - /** - * Create a new CatalogException wrapping an existing exception. - * - *

    The existing exception will be embedded in the new - * one, and its message will become the default message for - * the CatalogException.

    - * - * @param e The exception to be wrapped in a CatalogException. - */ - public CatalogException (Exception e) { - super(); - this.exceptionType = WRAPPER; - this.exception = e; - } - - /** - * Create a new CatalogException from an existing exception. - * - *

    The existing exception will be embedded in the new - * one, but the new exception will have its own message.

    - * - * @param message The detail message. - * @param e The exception to be wrapped in a CatalogException. - */ - public CatalogException (String message, Exception e) { - super(message); - this.exceptionType = WRAPPER; - this.exception = e; - } - - /** - * Return a detail message for this exception. - * - *

    If there is an embedded exception, and if the CatalogException - * has no detail message of its own, this method will return - * the detail message from the embedded exception.

    - * - * @return The error or warning message. - */ - public String getMessage () - { - String message = super.getMessage(); - - if (message == null && exception != null) { - return exception.getMessage(); - } else { - return message; - } - } - - /** - * Return the embedded exception, if any. - * - * @return The embedded exception, or null if there is none. - */ - public Exception getException () - { - return exception; - } - - /** - * Return the exception type - * - * @return The exception type - */ - public int getExceptionType () - { - return exceptionType; - } - - /** - * Override toString to pick up any embedded exception. - * - * @return A string representation of this exception. - */ - public String toString () - { - if (exception != null) { - return exception.toString(); - } else { - return super.toString(); - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java deleted file mode 100644 index 605735cf1a9..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/CatalogManager.java +++ /dev/null @@ -1,870 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver; - -import com.sun.org.apache.xerces.internal.utils.SecuritySupport; -import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver; -import com.sun.org.apache.xml.internal.resolver.helpers.Debug; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.MissingResourceException; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; -import java.util.StringTokenizer; -import java.util.Vector; -import sun.reflect.misc.ReflectUtil; - -/** - * CatalogManager provides an interface to the catalog properties. - * - *

    Properties can come from two places: from system properties or - * from a CatalogManager.properties file. This class provides a transparent - * interface to both, with system properties preferred over property file values.

    - * - *

    The following table summarizes the properties:

    - * - *
  • Debugger launches target VM (simplest, most-common scenario)Debugger calls the - * {@link com.sun.jdi.connect.LaunchingConnector#launch(java.util.Map)} + * Debugger calls the {@link LaunchingConnector#launch(java.util.Map)} * method of the default connector, obtained with {@link #defaultConnector}. The * target VM is launched, and a connection between that VM and the * debugger is established. A {@link VirtualMachine} mirror is returned. @@ -71,8 +78,7 @@ import java.io.IOException; * {@link #launchingConnectors} with desired characteristics * (for example, transport type, etc.). *
  • - * Debugger calls the - * {@link com.sun.jdi.connect.LaunchingConnector#launch(java.util.Map)} + * Debugger calls the {@link LaunchingConnector#launch(java.util.Map)} * method of the selected connector. The * target VM is launched, and a connection between that VM and the * debugger is established. A {@link VirtualMachine} mirror is returned. @@ -96,11 +102,10 @@ import java.io.IOException; * the name "xxx". *
  • * Debugger presents the default connector parameters (obtained through - * {@link com.sun.jdi.connect.Connector#defaultArguments()}) to the end user, - * allowing the user to + * {@link Connector#defaultArguments()}) to the end user, allowing the user to * fill in the transport-specific address generated by the target VM. *
  • - * Debugger calls the {@link com.sun.jdi.connect.AttachingConnector#attach(java.util.Map)} method + * Debugger calls the {@link AttachingConnector#attach(java.util.Map)} method * of the selected to attach to the target VM. A {@link VirtualMachine} * mirror is returned. * @@ -116,13 +121,13 @@ import java.io.IOException; * the list returned by {@link #listeningConnectors} for one or more * transports.
  • *
  • - * Debugger calls the {@link com.sun.jdi.connect.ListeningConnector#startListening(java.util.Map)} method for each selected + * Debugger calls the {@link ListeningConnector#startListening(java.util.Map)} method for each selected * connector. For each call, a transport-specific address string is * generated and returned. The debugger makes the transport names and * corresponding address strings available to the end user. *
  • * Debugger calls - * {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} + * {@link ListeningConnector#accept(java.util.Map)} * for each selected connector to wait for * a target VM to connect.
  • *
  • @@ -131,10 +136,10 @@ import java.io.IOException; * where "xxx" the transport for one of the connectors selected by the * the debugger and "yyy" * is the address generated by - * {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} for that + * {@link ListeningConnector#accept(java.util.Map)} for that * transport.
  • *
  • - * Debugger's call to {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} returns + * Debugger's call to {@link ListeningConnector#accept(java.util.Map)} returns * a {@link VirtualMachine} mirror.
  • * *
    - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    System PropertyCatalogManager.properties
    Property
    Description
    xml.catalog.ignoreMissing If true, a missing CatalogManager.properties file or missing properties - * within that file will not generate warning messages. See also the - * ignoreMissingProperties method.
    xml.catalog.filescatalogsThe semicolon-delimited list of catalog files.
     relative-catalogsIf false, relative catalog URIs are made absolute with respect to the base URI of - * the CatalogManager.properties file. This setting only applies to catalog - * URIs obtained from the catalogs property in the - * CatalogManager.properties file
    xml.catalog.verbosityverbosityIf non-zero, the Catalog classes will print informative and debugging messages. - * The higher the number, the more messages.
    xml.catalog.preferpreferWhich identifier is preferred, "public" or "system"?
    xml.catalog.staticCatalogstatic-catalogShould a single catalog be constructed for all parsing, or should a different - * catalog be created for each parser?
    xml.catalog.allowPIallow-oasis-xml-catalog-piIf the source document contains "oasis-xml-catalog" processing instructions, - * should they be used?
    xml.catalog.classNamecatalog-class-nameIf you're using the convenience classes - * com.sun.org.apache.xml.internal.resolver.tools.*), this setting - * allows you to specify an alternate class name to use for the underlying - * catalog.
    - * - * @see Catalog - * @deprecated The JDK internal Catalog API in package - * {@code com.sun.org.apache.xml.internal.resolver} - * is encapsulated in JDK 9. The entire implementation under the package is now - * deprecated and subject to removal in a future release. Users of the API - * should migrate to the {@linkplain javax.xml.catalog new public API}. - *

    - * The new Catalog API is supported throughout the JDK XML Processors, which allows - * the use of Catalog by simply setting a path to a Catalog file as a property. - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -@Deprecated(since="9", forRemoval=true) -public class CatalogManager { - private static final String pFiles = "xml.catalog.files"; - private static final String pVerbosity = "xml.catalog.verbosity"; - private static final String pPrefer = "xml.catalog.prefer"; - private static final String pStatic = "xml.catalog.staticCatalog"; - private static final String pAllowPI = "xml.catalog.allowPI"; - private static final String pClassname = "xml.catalog.className"; - private static final String pIgnoreMissing = "xml.catalog.ignoreMissing"; - - /** A static CatalogManager instance for sharing */ - private static final CatalogManager staticManager = new CatalogManager(); - - /** The bootstrap resolver to use when loading XML Catalogs. */ - private BootstrapResolver bResolver = new BootstrapResolver(); - - /** Flag to ignore missing property files and/or properties */ - private boolean ignoreMissingProperties - = (SecuritySupport.getSystemProperty(pIgnoreMissing) != null - || SecuritySupport.getSystemProperty(pFiles) != null); - - /** Holds the resources after they are loaded from the file. */ - private ResourceBundle resources; - - /** The name of the CatalogManager properties file. */ - private String propertyFile = "CatalogManager.properties"; - - /** The location of the propertyFile */ - private URL propertyFileURI = null; - - /** Default catalog files list. */ - private String defaultCatalogFiles = "./xcatalog"; - - /** Current catalog files list. */ - private String catalogFiles = null; - - /** Did the catalogFiles come from the properties file? */ - private boolean fromPropertiesFile = false; - - /** Default verbosity level if there is no property setting for it. */ - private int defaultVerbosity = 1; - - /** Current verbosity level. */ - private Integer verbosity = null; - - /** Default preference setting. */ - private boolean defaultPreferPublic = true; - - /** Current preference setting. */ - private Boolean preferPublic = null; - - /** Default setting of the static catalog flag. */ - private boolean defaultUseStaticCatalog = true; - - /** Current setting of the static catalog flag. */ - private Boolean useStaticCatalog = null; - - /** The static catalog used by this manager. */ - private static volatile Catalog staticCatalog = null; - - /** Default setting of the oasisXMLCatalogPI flag. */ - private boolean defaultOasisXMLCatalogPI = true; - - /** Current setting of the oasisXMLCatalogPI flag. */ - private Boolean oasisXMLCatalogPI = null; - - /** Default setting of the relativeCatalogs flag. */ - private boolean defaultRelativeCatalogs = true; - - /** Current setting of the relativeCatalogs flag. */ - private Boolean relativeCatalogs = null; - - /** Current catalog class name. */ - private String catalogClassName = null; - /** - * Indicates whether implementation parts should use - * service loader (or similar). - * Note the default value (false) is the safe option.. - */ - private boolean useServicesMechanism; - - /** The manager's debug object. Used for printing debugging messages. - * - *

    This field is public so that objects that have access to this - * CatalogManager can use this debug object.

    - */ - public Debug debug = null; - - /** Constructor. */ - public CatalogManager() { - init(); - } - - /** Constructor that specifies an explicit property file. */ - public CatalogManager(String propertyFile) { - this.propertyFile = propertyFile; - init(); - } - - private void init() { - debug = new Debug(); - // Note that we don't setDebug() here; we do that lazily. Either the - // user will set it explicitly, or we'll do it automagically if they - // read from the propertyFile for some other reason. That way, there's - // no attempt to read from the file before the caller has had a chance - // to avoid it. - if (System.getSecurityManager() == null) { - useServicesMechanism = true; - } - // Make sure verbosity is set by xml.catalog.verbosity sysprop - // setting, if defined. - queryVerbosityFromSysProp(); - } - - /** Set the bootstrap resolver - * @param resolver the bootstrap resolver - */ - public void setBootstrapResolver(BootstrapResolver resolver) { - bResolver = resolver; - } - - /** Get the bootstrap resolver - * @return the bootstrap resolver - */ - public BootstrapResolver getBootstrapResolver() { - return bResolver; - } - - /** Query system property for verbosity level. */ - private void queryVerbosityFromSysProp() { - String verbStr = SecuritySupport.getSystemProperty(pVerbosity); - if (verbStr != null) { - try { - int verb = Integer.parseInt(verbStr.trim()); - verbosity = new Integer(verb); - debug.setDebug(verb); - } catch (Exception e) { - System.err.println("Cannot parse verbosity: \"" + verbStr + "\""); - } - } - } - - /** - * Load the properties from the propertyFile and build the - * resources from it. - */ - private synchronized void readProperties() { - try { - propertyFileURI = CatalogManager.class.getResource("/"+propertyFile); - InputStream in = - CatalogManager.class.getResourceAsStream("/"+propertyFile); - if (in==null) { - if (!ignoreMissingProperties) { - System.err.println("Cannot find "+propertyFile); - // there's no reason to give this warning more than once - ignoreMissingProperties = true; - } - return; - } - resources = new PropertyResourceBundle(in); - } catch (MissingResourceException mre) { - if (!ignoreMissingProperties) { - System.err.println("Cannot read "+propertyFile); - } - } catch (java.io.IOException e) { - if (!ignoreMissingProperties) { - System.err.println("Failure trying to read "+propertyFile); - } - } - - // This is a bit of a hack. After we've successfully read the properties, - // use them to set the default debug level, if the user hasn't already set - // the default debug level. - if (verbosity == null) { - try { - String verbStr = resources.getString("verbosity"); - int verb = Integer.parseInt(verbStr.trim()); - debug.setDebug(verb); - verbosity = new Integer(verb); - } catch (Exception e) { - // nop - } - } - } - - /** - * Allow access to the static CatalogManager - */ - public static CatalogManager getStaticManager() { - return staticManager; - } - - /** - * How are missing properties handled? - * - *

    If true, missing or unreadable property files will - * not be reported. Otherwise, a message will be sent to System.err. - *

    - */ - public boolean getIgnoreMissingProperties() { - return ignoreMissingProperties; - } - - /** - * How should missing properties be handled? - * - *

    If ignore is true, missing or unreadable property files will - * not be reported. Otherwise, a message will be sent to System.err. - *

    - */ - public void setIgnoreMissingProperties(boolean ignore) { - ignoreMissingProperties = ignore; - } - - /** - * How are missing properties handled? - * - *

    If ignore is true, missing or unreadable property files will - * not be reported. Otherwise, a message will be sent to System.err. - *

    - * - * @deprecated No longer static; use get/set methods. - */ - public void ignoreMissingProperties(boolean ignore) { - setIgnoreMissingProperties(ignore); - } - - /** - * Obtain the verbosity setting from the properties. - * - * @return The verbosity level from the propertyFile or the - * defaultVerbosity. - */ - private int queryVerbosity () { - String defaultVerbStr = Integer.toString(defaultVerbosity); - - String verbStr = SecuritySupport.getSystemProperty(pVerbosity); - - if (verbStr == null) { - if (resources==null) readProperties(); - if (resources != null) { - try { - verbStr = resources.getString("verbosity"); - } catch (MissingResourceException e) { - verbStr = defaultVerbStr; - } - } else { - verbStr = defaultVerbStr; - } - } - - int verb = defaultVerbosity; - - try { - verb = Integer.parseInt(verbStr.trim()); - } catch (Exception e) { - System.err.println("Cannot parse verbosity: \"" + verbStr + "\""); - } - - // This is a bit of a hack. After we've successfully got the verbosity, - // we have to use it to set the default debug level, - // if the user hasn't already set the default debug level. - if (verbosity == null) { - debug.setDebug(verb); - verbosity = new Integer(verb); - } - - return verb; - } - - /** - * What is the current verbosity? - */ - public int getVerbosity() { - if (verbosity == null) { - verbosity = new Integer(queryVerbosity()); - } - - return verbosity.intValue(); - } - - /** - * Set the current verbosity. - */ - public void setVerbosity (int verbosity) { - this.verbosity = new Integer(verbosity); - debug.setDebug(verbosity); - } - - /** - * What is the current verbosity? - * - * @deprecated No longer static; use get/set methods. - */ - public int verbosity () { - return getVerbosity(); - } - - /** - * Obtain the relativeCatalogs setting from the properties. - * - * @return The relativeCatalogs setting from the propertyFile or the - * defaultRelativeCatalogs. - */ - private boolean queryRelativeCatalogs () { - if (resources==null) readProperties(); - - if (resources==null) return defaultRelativeCatalogs; - - try { - String allow = resources.getString("relative-catalogs"); - return (allow.equalsIgnoreCase("true") - || allow.equalsIgnoreCase("yes") - || allow.equalsIgnoreCase("1")); - } catch (MissingResourceException e) { - return defaultRelativeCatalogs; - } - } - - /** - * Get the relativeCatalogs setting. - * - *

    This property is used when the catalogFiles property is - * interrogated. If true, then relative catalog entry file names - * are returned. If false, relative catalog entry file names are - * made absolute with respect to the properties file before returning - * them.

    - * - *

    This property only applies when the catalog files - * come from a properties file. If they come from a system property or - * the default list, they are never considered relative. (What would - * they be relative to?)

    - * - *

    In the properties, a value of 'yes', 'true', or '1' is considered - * true, anything else is false.

    - * - * @return The relativeCatalogs setting from the propertyFile or the - * defaultRelativeCatalogs. - */ - public boolean getRelativeCatalogs () { - if (relativeCatalogs == null) { - relativeCatalogs = queryRelativeCatalogs() ? Boolean.TRUE : Boolean.FALSE; - } - - return relativeCatalogs.booleanValue(); - } - - /** - * Set the relativeCatalogs setting. - * - * @see #getRelativeCatalogs() - */ - public void setRelativeCatalogs (boolean relative) { - relativeCatalogs = relative ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * Get the relativeCatalogs setting. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean relativeCatalogs () { - return getRelativeCatalogs(); - } - - /** - * Obtain the list of catalog files from the properties. - * - * @return A semicolon delimited list of catlog file URIs - */ - private String queryCatalogFiles () { - String catalogList = SecuritySupport.getSystemProperty(pFiles); - fromPropertiesFile = false; - - if (catalogList == null) { - if (resources == null) readProperties(); - if (resources != null) { - try { - catalogList = resources.getString("catalogs"); - fromPropertiesFile = true; - } catch (MissingResourceException e) { - System.err.println(propertyFile + ": catalogs not found."); - catalogList = null; - } - } - } - - if (catalogList == null) { - catalogList = defaultCatalogFiles; - } - - return catalogList; - } - - /** - * Return the current list of catalog files. - * - * @return A vector of the catalog file names or null if no catalogs - * are available in the properties. - */ - public Vector getCatalogFiles() { - if (catalogFiles == null) { - catalogFiles = queryCatalogFiles(); - } - - StringTokenizer files = new StringTokenizer(catalogFiles, ";"); - Vector catalogs = new Vector(); - while (files.hasMoreTokens()) { - String catalogFile = files.nextToken(); - URL absURI = null; - - if (fromPropertiesFile && !relativeCatalogs()) { - try { - absURI = new URL(propertyFileURI, catalogFile); - catalogFile = absURI.toString(); - } catch (MalformedURLException mue) { - absURI = null; - } - } - - catalogs.add(catalogFile); - } - - return catalogs; - } - - /** - * Set the list of catalog files. - */ - public void setCatalogFiles(String fileList) { - catalogFiles = fileList; - fromPropertiesFile = false; - } - - /** - * Return the current list of catalog files. - * - * @return A vector of the catalog file names or null if no catalogs - * are available in the properties. - * - * @deprecated No longer static; use get/set methods. - */ - public Vector catalogFiles() { - return getCatalogFiles(); - } - - /** - * Obtain the preferPublic setting from the properties. - * - *

    In the properties, a value of 'public' is true, - * anything else is false.

    - * - * @return True if prefer is public or the - * defaultPreferSetting. - */ - private boolean queryPreferPublic () { - String prefer = SecuritySupport.getSystemProperty(pPrefer); - - if (prefer == null) { - if (resources==null) readProperties(); - if (resources==null) return defaultPreferPublic; - try { - prefer = resources.getString("prefer"); - } catch (MissingResourceException e) { - return defaultPreferPublic; - } - } - - if (prefer == null) { - return defaultPreferPublic; - } - - return (prefer.equalsIgnoreCase("public")); - } - - /** - * Return the current prefer public setting. - * - * @return True if public identifiers are preferred. - */ - public boolean getPreferPublic () { - if (preferPublic == null) { - preferPublic = queryPreferPublic() ? Boolean.TRUE : Boolean.FALSE; - } - return preferPublic.booleanValue(); - } - - /** - * Set the prefer public setting. - */ - public void setPreferPublic (boolean preferPublic) { - this.preferPublic = preferPublic ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * Return the current prefer public setting. - * - * @return True if public identifiers are preferred. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean preferPublic () { - return getPreferPublic(); - } - - /** - * Obtain the static-catalog setting from the properties. - * - *

    In the properties, a value of 'yes', 'true', or '1' is considered - * true, anything else is false.

    - * - * @return The static-catalog setting from the propertyFile or the - * defaultUseStaticCatalog. - */ - private boolean queryUseStaticCatalog () { - String staticCatalog = SecuritySupport.getSystemProperty(pStatic); - - if (staticCatalog == null) { - if (resources==null) readProperties(); - if (resources==null) return defaultUseStaticCatalog; - try { - staticCatalog = resources.getString("static-catalog"); - } catch (MissingResourceException e) { - return defaultUseStaticCatalog; - } - } - - if (staticCatalog == null) { - return defaultUseStaticCatalog; - } - - return (staticCatalog.equalsIgnoreCase("true") - || staticCatalog.equalsIgnoreCase("yes") - || staticCatalog.equalsIgnoreCase("1")); - } - - /** - * Get the current use static catalog setting. - */ - public boolean getUseStaticCatalog() { - if (useStaticCatalog == null) { - useStaticCatalog = queryUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE; - } - - return useStaticCatalog.booleanValue(); - } - - /** - * Set the use static catalog setting. - */ - public void setUseStaticCatalog(boolean useStatic) { - useStaticCatalog = useStatic ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * Get the current use static catalog setting. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean staticCatalog() { - return getUseStaticCatalog(); - } - - /** - * Get a new catalog instance. - * - * This method always returns a new instance of the underlying catalog class. - */ - public Catalog getPrivateCatalog() { - Catalog catalog = staticCatalog; - - if (useStaticCatalog == null) { - useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE; - } - - if (catalog == null || !useStaticCatalog.booleanValue()) { - - try { - String catalogClassName = getCatalogClassName(); - - if (catalogClassName == null) { - catalog = new Catalog(); - } else { - try { - catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance(); - } catch (ClassNotFoundException cnfe) { - debug.message(1,"Catalog class named '" - + catalogClassName - + "' could not be found. Using default."); - catalog = new Catalog(); - } catch (ClassCastException cnfe) { - debug.message(1,"Class named '" - + catalogClassName - + "' is not a Catalog. Using default."); - catalog = new Catalog(); - } - } - - catalog.setCatalogManager(this); - catalog.setupReaders(); - catalog.loadSystemCatalogs(); - } catch (Exception ex) { - ex.printStackTrace(); - } - - if (useStaticCatalog.booleanValue()) { - staticCatalog = catalog; - } - } - - return catalog; - } - - /** - * Get a catalog instance. - * - * If this manager uses static catalogs, the same static catalog will - * always be returned. Otherwise a new catalog will be returned. - */ - public Catalog getCatalog() { - Catalog catalog = staticCatalog; - - if (useStaticCatalog == null) { - useStaticCatalog = getUseStaticCatalog() ? Boolean.TRUE : Boolean.FALSE; - } - - if (catalog == null || !useStaticCatalog.booleanValue()) { - catalog = getPrivateCatalog(); - if (useStaticCatalog.booleanValue()) { - staticCatalog = catalog; - } - } - - return catalog; - } - - /** - *

    Obtain the oasisXMLCatalogPI setting from the properties.

    - * - *

    In the properties, a value of 'yes', 'true', or '1' is considered - * true, anything else is false.

    - * - * @return The oasisXMLCatalogPI setting from the propertyFile or the - * defaultOasisXMLCatalogPI. - */ - public boolean queryAllowOasisXMLCatalogPI () { - String allow = SecuritySupport.getSystemProperty(pAllowPI); - - if (allow == null) { - if (resources==null) readProperties(); - if (resources==null) return defaultOasisXMLCatalogPI; - try { - allow = resources.getString("allow-oasis-xml-catalog-pi"); - } catch (MissingResourceException e) { - return defaultOasisXMLCatalogPI; - } - } - - if (allow == null) { - return defaultOasisXMLCatalogPI; - } - - return (allow.equalsIgnoreCase("true") - || allow.equalsIgnoreCase("yes") - || allow.equalsIgnoreCase("1")); - } - - /** - * Get the current XML Catalog PI setting. - */ - public boolean getAllowOasisXMLCatalogPI () { - if (oasisXMLCatalogPI == null) { - oasisXMLCatalogPI = queryAllowOasisXMLCatalogPI() ? Boolean.TRUE : Boolean.FALSE; - } - - return oasisXMLCatalogPI.booleanValue(); - } - - public boolean useServicesMechanism() { - return useServicesMechanism; - } - /** - * Set the XML Catalog PI setting - */ - public void setAllowOasisXMLCatalogPI(boolean allowPI) { - oasisXMLCatalogPI = allowPI ? Boolean.TRUE : Boolean.FALSE; - } - - /** - * Get the current XML Catalog PI setting. - * - * @deprecated No longer static; use get/set methods. - */ - public boolean allowOasisXMLCatalogPI() { - return getAllowOasisXMLCatalogPI(); - } - - /** - * Obtain the Catalog class name setting from the properties. - * - */ - public String queryCatalogClassName () { - String className = SecuritySupport.getSystemProperty(pClassname); - - if (className == null) { - if (resources==null) readProperties(); - if (resources==null) return null; - try { - return resources.getString("catalog-class-name"); - } catch (MissingResourceException e) { - return null; - } - } - - return className; - } - - /** - * Get the current Catalog class name. - */ - public String getCatalogClassName() { - if (catalogClassName == null) { - catalogClassName = queryCatalogClassName(); - } - - return catalogClassName; - } - - /** - * Set the Catalog class name. - */ - public void setCatalogClassName(String className) { - catalogClassName = className; - } - - /** - * Get the current Catalog class name. - * - * @deprecated No longer static; use get/set methods. - */ - public String catalogClassName() { - return getCatalogClassName(); - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java deleted file mode 100644 index d50a4c262b2..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/Resolver.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver; - -import java.io.IOException; -import java.io.InputStream; -import java.io.FileNotFoundException; -import java.util.Enumeration; -import java.util.Vector; -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; -import javax.xml.parsers.SAXParserFactory; -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; -import com.sun.org.apache.xerces.internal.utils.SecuritySupport; -import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader; -import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader; -import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader; - -/** - * An extension to OASIS Open Catalog files, this class supports - * suffix-based matching and an external RFC2483 resolver. - * - * @see Catalog - * @deprecated The JDK internal Catalog API in package - * {@code com.sun.org.apache.xml.internal.resolver} - * is encapsulated in JDK 9. The entire implementation under the package is now - * deprecated and subject to removal in a future release. Users of the API - * should migrate to the {@linkplain javax.xml.catalog new public API}. - *

    - * The new Catalog API is supported throughout the JDK XML Processors, which allows - * the use of Catalog by simply setting a path to a Catalog file as a property. - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -@Deprecated(since="9", forRemoval=true) -public class Resolver extends Catalog { - /** - * The URISUFFIX Catalog Entry type. - * - *

    URI suffix entries match URIs that end in a specified suffix.

    - */ - public static final int URISUFFIX = CatalogEntry.addEntryType("URISUFFIX", 2); - - /** - * The SYSTEMSUFFIX Catalog Entry type. - * - *

    System suffix entries match system identifiers that end in a - * specified suffix.

    - */ - public static final int SYSTEMSUFFIX = CatalogEntry.addEntryType("SYSTEMSUFFIX", 2); - - /** - * The RESOLVER Catalog Entry type. - * - *

    A hook for providing support for web-based backup resolvers.

    - */ - public static final int RESOLVER = CatalogEntry.addEntryType("RESOLVER", 1); - - /** - * The SYSTEMREVERSE Catalog Entry type. - * - *

    This is a bit of a hack. There's no actual SYSTEMREVERSE entry, - * but this entry type is used to indicate that a reverse lookup is - * being performed. (This allows the Resolver to implement - * RFC2483 I2N and I2NS.) - */ - public static final int SYSTEMREVERSE - = CatalogEntry.addEntryType("SYSTEMREVERSE", 1); - - /** - * Setup readers. - */ - public void setupReaders() { - SAXParserFactory spf = catalogManager.useServicesMechanism() ? - SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); - spf.setNamespaceAware(true); - spf.setValidating(false); - - SAXCatalogReader saxReader = new SAXCatalogReader(spf); - - saxReader.setCatalogParser(null, "XCatalog", - "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); - - saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, - "catalog", - "com.sun.org.apache.xml.internal.resolver.readers.ExtendedXMLCatalogReader"); - - addReader("application/xml", saxReader); - - TR9401CatalogReader textReader = new TR9401CatalogReader(); - addReader("text/plain", textReader); - } - - /** - * Cleanup and process a Catalog entry. - * - *

    This method processes each Catalog entry, changing mapped - * relative system identifiers into absolute ones (based on the current - * base URI), and maintaining other information about the current - * catalog.

    - * - * @param entry The CatalogEntry to process. - */ - public void addEntry(CatalogEntry entry) { - int type = entry.getEntryType(); - - if (type == URISUFFIX) { - String suffix = normalizeURI(entry.getEntryArg(0)); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "URISUFFIX", suffix, fsi); - } else if (type == SYSTEMSUFFIX) { - String suffix = normalizeURI(entry.getEntryArg(0)); - String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1))); - - entry.setEntryArg(1, fsi); - - catalogManager.debug.message(4, "SYSTEMSUFFIX", suffix, fsi); - } - - super.addEntry(entry); - } - - /** - * Return the applicable URI. - * - *

    If a URI entry exists in the Catalog - * for the URI specified, return the mapped value.

    - * - *

    In the Resolver (as opposed to the Catalog) class, if the - * URI isn't found by the usual algorithm, URISUFFIX entries are - * considered.

    - * - *

    URI comparison is case sensitive.

    - * - * @param uri The URI to locate in the catalog. - * - * @return The resolved URI. - * - * @throws MalformedURLException The system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveURI(String uri) - throws MalformedURLException, IOException { - - String resolved = super.resolveURI(uri); - if (resolved != null) { - return resolved; - } - - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == RESOLVER) { - resolved = resolveExternalSystem(uri, e.getEntryArg(0)); - if (resolved != null) { - return resolved; - } - } else if (e.getEntryType() == URISUFFIX) { - String suffix = e.getEntryArg(0); - String result = e.getEntryArg(1); - - if (suffix.length() <= uri.length() - && uri.substring(uri.length()-suffix.length()).equals(suffix)) { - return result; - } - } - } - - // Otherwise, look in the subordinate catalogs - return resolveSubordinateCatalogs(Catalog.URI, - null, - null, - uri); - } - - /** - * Return the applicable SYSTEM system identifier, resorting - * to external RESOLVERs if necessary. - * - *

    If a SYSTEM entry exists in the Catalog - * for the system ID specified, return the mapped value.

    - * - *

    In the Resolver (as opposed to the Catalog) class, if the - * URI isn't found by the usual algorithm, SYSTEMSUFFIX entries are - * considered.

    - * - *

    On Windows-based operating systems, the comparison between - * the system identifier provided and the SYSTEM entries in the - * Catalog is case-insensitive.

    - * - * @param systemId The system ID to locate in the catalog. - * - * @return The system identifier to use for systemId. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public String resolveSystem(String systemId) - throws MalformedURLException, IOException { - - String resolved = super.resolveSystem(systemId); - if (resolved != null) { - return resolved; - } - - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == RESOLVER) { - resolved = resolveExternalSystem(systemId, e.getEntryArg(0)); - if (resolved != null) { - return resolved; - } - } else if (e.getEntryType() == SYSTEMSUFFIX) { - String suffix = e.getEntryArg(0); - String result = e.getEntryArg(1); - - if (suffix.length() <= systemId.length() - && systemId.substring(systemId.length()-suffix.length()).equals(suffix)) { - return result; - } - } - } - - return resolveSubordinateCatalogs(Catalog.SYSTEM, - null, - null, - systemId); - } - - /** - * Return the applicable PUBLIC or SYSTEM identifier, resorting - * to external resolvers if necessary. - * - *

    This method searches the Catalog and returns the system - * identifier specified for the given system or - * public identifiers. If - * no appropriate PUBLIC or SYSTEM entry is found in the Catalog, - * null is returned.

    - * - *

    Note that a system or public identifier in the current catalog - * (or subordinate catalogs) will be used in preference to an - * external resolver. Further, if a systemId is present, the external - * resolver(s) will be queried for that before the publicId.

    - * - * @param publicId The public identifier to locate in the catalog. - * Public identifiers are normalized before comparison. - * @param systemId The nominal system identifier for the entity - * in question (as provided in the source document). - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - * - * @return The system identifier to use. - * Note that the nominal system identifier is not returned if a - * match is not found in the catalog, instead null is returned - * to indicate that no match was found. - */ - public String resolvePublic(String publicId, String systemId) - throws MalformedURLException, IOException { - - String resolved = super.resolvePublic(publicId, systemId); - if (resolved != null) { - return resolved; - } - - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == RESOLVER) { - if (systemId != null) { - resolved = resolveExternalSystem(systemId, - e.getEntryArg(0)); - if (resolved != null) { - return resolved; - } - } - resolved = resolveExternalPublic(publicId, e.getEntryArg(0)); - if (resolved != null) { - return resolved; - } - } - } - - return resolveSubordinateCatalogs(Catalog.PUBLIC, - null, - publicId, - systemId); - } - - /** - * Query an external RFC2483 resolver for a system identifier. - * - * @param systemId The system ID to locate. - * @param resolver The name of the resolver to use. - * - * @return The system identifier to use for the systemId. - */ - protected String resolveExternalSystem(String systemId, String resolver) - throws MalformedURLException, IOException { - Resolver r = queryResolver(resolver, "i2l", systemId, null); - if (r != null) { - return r.resolveSystem(systemId); - } else { - return null; - } - } - - /** - * Query an external RFC2483 resolver for a public identifier. - * - * @param publicId The system ID to locate. - * @param resolver The name of the resolver to use. - * - * @return The system identifier to use for the systemId. - */ - protected String resolveExternalPublic(String publicId, String resolver) - throws MalformedURLException, IOException { - Resolver r = queryResolver(resolver, "fpi2l", publicId, null); - if (r != null) { - return r.resolvePublic(publicId, null); - } else { - return null; - } - } - - /** - * Query an external RFC2483 resolver. - * - * @param resolver The URL of the RFC2483 resolver. - * @param command The command to send the resolver. - * @param arg1 The first argument to the resolver. - * @param arg2 The second argument to the resolver, usually null. - * - * @return The Resolver constructed. - */ - protected Resolver queryResolver(String resolver, - String command, - String arg1, - String arg2) { - InputStream iStream = null; - String RFC2483 = resolver + "?command=" + command - + "&format=tr9401&uri=" + arg1 - + "&uri2=" + arg2; - String line = null; - - try { - URL url = new URL(RFC2483); - - URLConnection urlCon = url.openConnection(); - - urlCon.setUseCaches(false); - - Resolver r = (Resolver) newCatalog(); - - String cType = urlCon.getContentType(); - - // I don't care about the character set or subtype - if (cType.indexOf(";") > 0) { - cType = cType.substring(0, cType.indexOf(";")); - } - - r.parseCatalog(cType, urlCon.getInputStream()); - - return r; - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.UNPARSEABLE) { - catalogManager.debug.message(1, "Unparseable catalog: " + RFC2483); - } else if (cex.getExceptionType() - == CatalogException.UNKNOWN_FORMAT) { - catalogManager.debug.message(1, "Unknown catalog format: " + RFC2483); - } - return null; - } catch (MalformedURLException mue) { - catalogManager.debug.message(1, "Malformed resolver URL: " + RFC2483); - return null; - } catch (IOException ie) { - catalogManager.debug.message(1, "I/O Exception opening resolver: " + RFC2483); - return null; - } - } - - /** - * Append two vectors, returning the result. - * - * @param vec The first vector - * @param appvec The vector to be appended - * @return The vector vec, with appvec's elements appended to it - */ - private Vector appendVector(Vector vec, Vector appvec) { - if (appvec != null) { - for (int count = 0; count < appvec.size(); count++) { - vec.addElement(appvec.elementAt(count)); - } - } - return vec; - } - - /** - * Find the URNs for a given system identifier in all catalogs. - * - * @param systemId The system ID to locate. - * - * @return A vector of URNs that map to the systemId. - */ - public Vector resolveAllSystemReverse(String systemId) - throws MalformedURLException, IOException { - Vector resolved = new Vector(); - - // If there's a SYSTEM entry in this catalog, use it - if (systemId != null) { - Vector localResolved = resolveLocalSystemReverse(systemId); - resolved = appendVector(resolved, localResolved); - } - - // Otherwise, look in the subordinate catalogs - Vector subResolved = resolveAllSubordinateCatalogs(SYSTEMREVERSE, - null, - null, - systemId); - - return appendVector(resolved, subResolved); - } - - /** - * Find the URN for a given system identifier. - * - * @param systemId The system ID to locate. - * - * @return A (single) URN that maps to the systemId. - */ - public String resolveSystemReverse(String systemId) - throws MalformedURLException, IOException { - Vector resolved = resolveAllSystemReverse(systemId); - if (resolved != null && resolved.size() > 0) { - return (String) resolved.elementAt(0); - } else { - return null; - } - } - - /** - * Return the applicable SYSTEM system identifiers. - * - *

    If one or more SYSTEM entries exists in the Catalog - * for the system ID specified, return the mapped values.

    - * - *

    The caller is responsible for doing any necessary - * normalization of the system identifier before calling - * this method. For example, a relative system identifier in - * a document might be converted to an absolute system identifier - * before attempting to resolve it.

    - * - *

    Note that this function will force all subordinate catalogs - * to be loaded.

    - * - *

    On Windows-based operating systems, the comparison between - * the system identifier provided and the SYSTEM entries in the - * Catalog is case-insensitive.

    - * - * @param systemId The system ID to locate in the catalog. - * - * @return The system identifier to use for the notation. - * - * @throws MalformedURLException The formal system identifier of a - * subordinate catalog cannot be turned into a valid URL. - * @throws IOException Error reading subordinate catalog file. - */ - public Vector resolveAllSystem(String systemId) - throws MalformedURLException, IOException { - Vector resolutions = new Vector(); - - // If there are SYSTEM entries in this catalog, start with them - if (systemId != null) { - Vector localResolutions = resolveAllLocalSystem(systemId); - resolutions = appendVector(resolutions, localResolutions); - } - - // Then look in the subordinate catalogs - Vector subResolutions = resolveAllSubordinateCatalogs(SYSTEM, - null, - null, - systemId); - resolutions = appendVector(resolutions, subResolutions); - - if (resolutions.size() > 0) { - return resolutions; - } else { - return null; - } - } - - /** - * Return all applicable SYSTEM system identifiers in this - * catalog. - * - *

    If one or more SYSTEM entries exists in the catalog file - * for the system ID specified, return the mapped values.

    - * - * @param systemId The system ID to locate in the catalog - * - * @return A vector of the mapped system identifiers or null - */ - private Vector resolveAllLocalSystem(String systemId) { - Vector map = new Vector(); - String osname = SecuritySupport.getSystemProperty("os.name"); - boolean windows = (osname.indexOf("Windows") >= 0); - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == SYSTEM - && (e.getEntryArg(0).equals(systemId) - || (windows - && e.getEntryArg(0).equalsIgnoreCase(systemId)))) { - map.addElement(e.getEntryArg(1)); - } - } - if (map.size() == 0) { - return null; - } else { - return map; - } - } - - /** - * Find the URNs for a given system identifier in the current catalog. - * - * @param systemId The system ID to locate. - * - * @return A vector of URNs that map to the systemId. - */ - private Vector resolveLocalSystemReverse(String systemId) { - Vector map = new Vector(); - String osname = SecuritySupport.getSystemProperty("os.name"); - boolean windows = (osname.indexOf("Windows") >= 0); - Enumeration en = catalogEntries.elements(); - while (en.hasMoreElements()) { - CatalogEntry e = (CatalogEntry) en.nextElement(); - if (e.getEntryType() == SYSTEM - && (e.getEntryArg(1).equals(systemId) - || (windows - && e.getEntryArg(1).equalsIgnoreCase(systemId)))) { - map.addElement(e.getEntryArg(0)); - } - } - if (map.size() == 0) { - return null; - } else { - return map; - } - } - - /** - * Search the subordinate catalogs, in order, looking for all - * match. - * - *

    This method searches the Catalog and returns all of the system - * identifiers specified for the given entity type with the given - * name, public, and system identifiers. In some contexts, these - * may be null.

    - * - * @param entityType The CatalogEntry type for which this query is - * being conducted. This is necessary in order to do the approprate - * query on a subordinate catalog. - * @param entityName The name of the entity being searched for, if - * appropriate. - * @param publicId The public identifier of the entity in question - * (as provided in the source document). - * @param systemId The nominal system identifier for the entity - * in question (as provided in the source document). - * - * @throws MalformedURLException The formal system identifier of a - * delegated catalog cannot be turned into a valid URL. - * @throws IOException Error reading delegated catalog file. - * - * @return The system identifier to use. - * Note that the nominal system identifier is not returned if a - * match is not found in the catalog, instead null is returned - * to indicate that no match was found. - */ - private synchronized Vector resolveAllSubordinateCatalogs(int entityType, - String entityName, - String publicId, - String systemId) - throws MalformedURLException, IOException { - - Vector resolutions = new Vector(); - - for (int catPos = 0; catPos < catalogs.size(); catPos++) { - Resolver c = null; - - try { - c = (Resolver) catalogs.elementAt(catPos); - } catch (ClassCastException e) { - String catfile = (String) catalogs.elementAt(catPos); - c = (Resolver) newCatalog(); - - try { - c.parseCatalog(catfile); - } catch (MalformedURLException mue) { - catalogManager.debug.message(1, "Malformed Catalog URL", catfile); - } catch (FileNotFoundException fnfe) { - catalogManager.debug.message(1, "Failed to load catalog, file not found", - catfile); - } catch (IOException ioe) { - catalogManager.debug.message(1, "Failed to load catalog, I/O error", catfile); - } - - catalogs.setElementAt(c, catPos); - } - - String resolved = null; - - // Ok, now what are we supposed to call here? - if (entityType == DOCTYPE) { - resolved = c.resolveDoctype(entityName, - publicId, - systemId); - if (resolved != null) { - // Only find one DOCTYPE resolution - resolutions.addElement(resolved); - return resolutions; - } - } else if (entityType == DOCUMENT) { - resolved = c.resolveDocument(); - if (resolved != null) { - // Only find one DOCUMENT resolution - resolutions.addElement(resolved); - return resolutions; - } - } else if (entityType == ENTITY) { - resolved = c.resolveEntity(entityName, - publicId, - systemId); - if (resolved != null) { - // Only find one ENTITY resolution - resolutions.addElement(resolved); - return resolutions; - } - } else if (entityType == NOTATION) { - resolved = c.resolveNotation(entityName, - publicId, - systemId); - if (resolved != null) { - // Only find one NOTATION resolution - resolutions.addElement(resolved); - return resolutions; - } - } else if (entityType == PUBLIC) { - resolved = c.resolvePublic(publicId, systemId); - if (resolved != null) { - // Only find one PUBLIC resolution - resolutions.addElement(resolved); - return resolutions; - } - } else if (entityType == SYSTEM) { - Vector localResolutions = c.resolveAllSystem(systemId); - resolutions = appendVector(resolutions, localResolutions); - break; - } else if (entityType == SYSTEMREVERSE) { - Vector localResolutions = c.resolveAllSystemReverse(systemId); - resolutions = appendVector(resolutions, localResolutions); - } - } - - if (resolutions != null) { - return resolutions; - } else { - return null; - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java deleted file mode 100644 index 25cb5057b19..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/BootstrapResolver.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - */ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.helpers; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.URIResolver; -import javax.xml.transform.sax.SAXSource; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; - -/** - * A simple bootstrapping resolver. - * - *

    This class is used as the entity resolver when reading XML Catalogs. - * It searches for the OASIS XML Catalog DTD, Relax NG Grammar and W3C XML Schema - * as resources (e.g., in the resolver jar file).

    - * - *

    If you have your own DTDs or schemas, you can extend this class and - * set the BootstrapResolver in your CatalogManager.

    - * - * @see com.sun.org.apache.xml.internal.resolver.CatalogManager - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class BootstrapResolver implements EntityResolver, URIResolver { - /** URI of the W3C XML Schema for OASIS XML Catalog files. */ - public static final String xmlCatalogXSD = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.xsd"; - - /** URI of the RELAX NG Grammar for OASIS XML Catalog files. */ - public static final String xmlCatalogRNG = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.rng"; - - /** Public identifier for OASIS XML Catalog files. */ - public static final String xmlCatalogPubId = "-//OASIS//DTD XML Catalogs V1.0//EN"; - - /** System identifier for OASIS XML Catalog files. */ - public static final String xmlCatalogSysId = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"; - - /** Public identifier for legacy Apache XCatalog files. There is no official system identifier for XCatalog files. */ - public static final String xCatalogPubId = "-//DTD XCatalog//EN"; - - /** Private hash used for public identifiers. */ - private final Map publicMap = new HashMap<>(); - - /** Private hash used for system identifiers. */ - private final Map systemMap = new HashMap<>(); - - /** Private hash used for URIs. */ - private final Map uriMap = new HashMap<>(); - - /** Constructor. */ - public BootstrapResolver() { - URL url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/catalog.dtd"); - if (url != null) { - publicMap.put(xmlCatalogPubId, url.toString()); - systemMap.put(xmlCatalogSysId, url.toString()); - } - - url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/catalog.rng"); - if (url != null) { - uriMap.put(xmlCatalogRNG, url.toString()); - } - - url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/catalog.xsd"); - if (url != null) { - uriMap.put(xmlCatalogXSD, url.toString()); - } - - url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/xcatalog.dtd"); - if (url != null) { - publicMap.put(xCatalogPubId, url.toString()); - } - } - - /** SAX resolveEntity API. */ - public InputSource resolveEntity (String publicId, String systemId) { - String resolved = null; - - if (systemId != null && systemMap.containsKey(systemId)) { - resolved = systemMap.get(systemId); - } else if (publicId != null && publicMap.containsKey(publicId)) { - resolved = publicMap.get(publicId); - } - - if (resolved != null) { - try { - InputSource iSource = new InputSource(resolved); - iSource.setPublicId(publicId); - - // Ideally this method would not attempt to open the - // InputStream, but there is a bug (in Xerces, at least) - // that causes the parser to mistakenly open the wrong - // system identifier if the returned InputSource does - // not have a byteStream. - // - // It could be argued that we still shouldn't do this here, - // but since the purpose of calling the entityResolver is - // almost certainly to open the input stream, it seems to - // do little harm. - // - URL url = new URL(resolved); - InputStream iStream = url.openStream(); - iSource.setByteStream(iStream); - - return iSource; - } catch (Exception e) { - // FIXME: silently fail? - return null; - } - } - - return null; - } - - /** Transformer resolve API. */ - public Source resolve(String href, String base) - throws TransformerException { - - String uri = href; - String fragment = null; - int hashPos = href.indexOf("#"); - if (hashPos >= 0) { - uri = href.substring(0, hashPos); - fragment = href.substring(hashPos+1); - } - - String result = null; - if (href != null && uriMap.containsKey(href)) { - result = uriMap.get(href); - } - - if (result == null) { - try { - URL url = null; - - if (base==null) { - url = new URL(uri); - result = url.toString(); - } else { - URL baseURL = new URL(base); - url = (href.length()==0 ? baseURL : new URL(baseURL, uri)); - result = url.toString(); - } - } catch (java.net.MalformedURLException mue) { - // try to make an absolute URI from the current base - String absBase = makeAbsolute(base); - if (!absBase.equals(base)) { - // don't bother if the absBase isn't different! - return resolve(href, absBase); - } else { - throw new TransformerException("Malformed URL " - + href + "(base " + base + ")", - mue); - } - } - } - - SAXSource source = new SAXSource(); - source.setInputSource(new InputSource(result)); - return source; - } - - /** Attempt to construct an absolute URI */ - private String makeAbsolute(String uri) { - if (uri == null) { - uri = ""; - } - - try { - URL url = new URL(uri); - return url.toString(); - } catch (MalformedURLException mue) { - try { - URL fileURL = FileURL.makeURL(uri); - return fileURL.toString(); - } catch (MalformedURLException mue2) { - // bail - return uri; - } - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Debug.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Debug.java deleted file mode 100644 index 6a6c03a48e5..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Debug.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.helpers; - -/** - * Static debugging/messaging class for Catalogs. - * - *

    This class defines a set of static methods that can be called - * to produce debugging messages. Messages have an associated "debug - * level" and messages below the current setting are not displayed.

    - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class Debug { - /** The internal debug level. */ - protected int debug = 0; - - /** Constructor */ - public Debug() { - // nop - } - - /** Set the debug level for future messages. */ - public void setDebug(int newDebug) { - debug = newDebug; - } - - /** Get the current debug level. */ - public int getDebug() { - return debug; - } - - /** - * Print debug message (if the debug level is high enough). - * - *

    Prints "the message"

    - * - * @param level The debug level of this message. This message - * will only be - * displayed if the current debug level is at least equal to this - * value. - * @param message The text of the message. - */ - public void message(int level, String message) { - if (debug >= level) { - System.out.println(message); - } - } - - /** - * Print debug message (if the debug level is high enough). - * - *

    Prints "the message: spec"

    - * - * @param level The debug level of this message. This message - * will only be - * displayed if the current debug level is at least equal to this - * value. - * @param message The text of the message. - * @param spec An argument to the message. - */ - public void message(int level, String message, String spec) { - if (debug >= level) { - System.out.println(message + ": " + spec); - } - } - - /** - * Print debug message (if the debug level is high enough). - * - *

    Prints "the message: spec1" and "spec2" indented on the next line.

    - * - * @param level The debug level of this message. This message - * will only be - * displayed if the current debug level is at least equal to this - * value. - * @param message The text of the message. - * @param spec1 An argument to the message. - * @param spec2 Another argument to the message. - */ - public void message(int level, String message, - String spec1, String spec2) { - if (debug >= level) { - System.out.println(message + ": " + spec1); - System.out.println("\t" + spec2); - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/FileURL.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/FileURL.java deleted file mode 100644 index 6717739005a..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/FileURL.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.helpers; - -import java.net.URL; -import java.net.MalformedURLException; -import java.io.File; - -/** - * Static method for dealing with file: URLs. - * - *

    This class defines a static method that can be used to construct - * an appropriate file: URL from parts. It's defined here so that it - * can be reused throught the resolver.

    - * - *

    (Yes, I'd rather have called this class FileURI, but - * given that a jave.net.URL is returned, it seemed...even more - * confusing.)

    - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -public abstract class FileURL { - protected FileURL() { } - - /** - * Construct a file: URL for a path name. - * - *

    URLs in the file: scheme can be constructed for paths on - * the local file system. Several possibilities need to be considered: - *

    - * - *
      - *
    • If the path does not begin with a slash, then it is assumed - * to reside in the users current working directory - * (System.getProperty("user.dir")).
    • - *
    • On Windows machines, the current working directory uses - * backslashes (\\, instead of /).
    • - *
    • If the current working directory is "/", don't add an extra - * slash before the base name.
    • - *
    - * - *

    This method is declared static so that other classes - * can use it directly.

    - * - * @param pathname The path name component for which to construct a URL. - * - * @return The appropriate file: URL. - * - * @throws MalformedURLException if the pathname can't be turned into - * a proper URL. - */ - public static URL makeURL(String pathname) throws MalformedURLException { - /*if (pathname.startsWith("/")) { - return new URL("file://" + pathname); - } - - String userdir = System.getProperty("user.dir"); - userdir.replace('\\', '/'); - - if (userdir.endsWith("/")) { - return new URL("file:///" + userdir + pathname); - } else { - return new URL("file:///" + userdir + "/" + pathname); - } - */ - File file = new File(pathname); - return file.toURI().toURL(); - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Namespaces.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Namespaces.java deleted file mode 100644 index 6511cf26224..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/Namespaces.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.helpers; - -import org.w3c.dom.*; - -/** - * Static Namespace query methods. - * - *

    This class defines a set of static methods that can be called - * to analyze the namespace properties of DOM nodes.

    - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class Namespaces { - /** - * Returns the "prefix" part of a QName or the empty string (not - * null) if the name has no prefix. - * - * @param element The QName of an element. - * @return The prefix part of the element name. - */ - public static String getPrefix(Element element) { - String name = element.getTagName(); - String prefix = ""; - - final int indexOfColon = name.indexOf(':'); - if (indexOfColon > 0) { - prefix = name.substring(0, indexOfColon); - } - - return prefix; - } - - /** - * Returns the "localname" part of a QName, which is the whole - * name if it has no prefix. - * - * @param element The QName of an element. - * @return The local part of a QName. - */ - public static String getLocalName(Element element) { - String name = element.getTagName(); - - final int indexOfColon = name.indexOf(':'); - if (indexOfColon > 0) { - name = name.substring(indexOfColon + 1); - } - - return name; - } - - /** - * Returns the namespace URI for the specified prefix at the - * specified context node. - * - * @param node The context node. - * @param prefix The prefix. - * @return The namespace URI associated with the prefix, or - * null if no namespace declaration exists for the prefix. - */ - public static String getNamespaceURI(Node node, String prefix) { - if (node == null || node.getNodeType() != Node.ELEMENT_NODE) { - return null; - } - - if (prefix.length() == 0) { - if (((Element) node).hasAttribute("xmlns")) { - return ((Element) node).getAttribute("xmlns"); - } - } else { - String nsattr = "xmlns:" + prefix; - if (((Element) node).hasAttribute(nsattr)) { - return ((Element) node).getAttribute(nsattr); - } - } - - return getNamespaceURI(node.getParentNode(), prefix); - } - - /** - * Returns the namespace URI for the namespace to which the - * element belongs. - * - * @param element The element. - * @return The namespace URI associated with the namespace of the - * element, or null if no namespace declaration exists for it. - */ - public static String getNamespaceURI(Element element) { - String prefix = getPrefix(element); - return getNamespaceURI(element, prefix); - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/PublicId.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/PublicId.java deleted file mode 100644 index d70f4f034ac..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/helpers/PublicId.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.helpers; - -/** - * Static methods for dealing with public identifiers. - * - *

    This class defines a set of static methods that can be called - * to handle public identifiers.

    - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public abstract class PublicId { - - protected PublicId() {} - - /** - * Normalize a public identifier. - * - *

    Public identifiers must be normalized according to the following - * rules before comparisons between them can be made:

    - * - *
      - *
    • Whitespace characters are normalized to spaces (e.g., line feeds, - * tabs, etc. become spaces).
    • - *
    • Leading and trailing whitespace is removed.
    • - *
    • Multiple internal whitespaces are normalized to a single - * space.
    • - *
    - * - *

    This method is declared static so that other classes - * can use it directly.

    - * - * @param publicId The unnormalized public identifier. - * - * @return The normalized identifier. - */ - public static String normalize(String publicId) { - String normal = publicId.replace('\t', ' '); - normal = normal.replace('\r', ' '); - normal = normal.replace('\n', ' '); - normal = normal.trim(); - - int pos; - - while ((pos = normal.indexOf(" ")) >= 0) { - normal = normal.substring(0, pos) + normal.substring(pos+1); - } - return normal; - } - - /** - * Encode a public identifier as a "publicid" URN. - * - *

    This method is declared static so that other classes - * can use it directly.

    - * - * @param publicId The unnormalized public identifier. - * - * @return The normalized identifier. - */ - public static String encodeURN(String publicId) { - String urn = PublicId.normalize(publicId); - - urn = PublicId.stringReplace(urn, "%", "%25"); - urn = PublicId.stringReplace(urn, ";", "%3B"); - urn = PublicId.stringReplace(urn, "'", "%27"); - urn = PublicId.stringReplace(urn, "?", "%3F"); - urn = PublicId.stringReplace(urn, "#", "%23"); - urn = PublicId.stringReplace(urn, "+", "%2B"); - urn = PublicId.stringReplace(urn, " ", "+"); - urn = PublicId.stringReplace(urn, "::", ";"); - urn = PublicId.stringReplace(urn, ":", "%3A"); - urn = PublicId.stringReplace(urn, "//", ":"); - urn = PublicId.stringReplace(urn, "/", "%2F"); - - StringBuilder buffer = new StringBuilder(13 + urn.length()); - buffer.append("urn:publicid:"); - buffer.append(urn); - return buffer.toString(); - } - - /** - * Decode a "publicid" URN into a public identifier. - * - *

    This method is declared static so that other classes - * can use it directly.

    - * - * @param urn The urn:publicid: URN - * - * @return The normalized identifier. - */ - public static String decodeURN(String urn) { - String publicId; - if (urn.startsWith("urn:publicid:")) { - publicId = urn.substring(13); - } - else { - return urn; - } - - final boolean hasEscape = (publicId.indexOf('%') >= 0); - if (hasEscape) { - publicId = PublicId.stringReplace(publicId, "%2F", "/"); - } - publicId = PublicId.stringReplace(publicId, ":", "//"); - if (hasEscape) { - publicId = PublicId.stringReplace(publicId, "%3A", ":"); - } - publicId = PublicId.stringReplace(publicId, ";", "::"); - publicId = PublicId.stringReplace(publicId, "+", " "); - if (hasEscape) { - publicId = PublicId.stringReplace(publicId, "%2B", "+"); - publicId = PublicId.stringReplace(publicId, "%23", "#"); - publicId = PublicId.stringReplace(publicId, "%3F", "?"); - publicId = PublicId.stringReplace(publicId, "%27", "'"); - publicId = PublicId.stringReplace(publicId, "%3B", ";"); - publicId = PublicId.stringReplace(publicId, "%25", "%"); - } - - return publicId; - } - - /** - * Replace one string with another. - */ - private static String stringReplace(String str, - String oldStr, - String newStr) { - int pos = str.indexOf(oldStr); - if (pos >= 0) { - final StringBuilder buffer = new StringBuilder(); - final int oldStrLength = oldStr.length(); - int start = 0; - do { - for (int i = start; i < pos; ++i) { - buffer.append(str.charAt(i)); - } - buffer.append(newStr); - start = pos + oldStrLength; - pos = str.indexOf(oldStr, start); - } - while (pos >= 0); - final int strLength = str.length(); - for (int i = start; i < strLength; ++i) { - buffer.append(str.charAt(i)); - } - return buffer.toString(); - } - return str; - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/CatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/CatalogReader.java deleted file mode 100644 index 444b38769dc..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/CatalogReader.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import java.io.IOException; -import java.net.MalformedURLException; -import com.sun.org.apache.xml.internal.resolver.CatalogException; - -import java.io.InputStream; -import com.sun.org.apache.xml.internal.resolver.Catalog; - -/** - * The CatalogReader interface. - * - *

    The Catalog class requires that classes implement this interface - * in order to be used to read catalogs. Examples of CatalogReaders - * include the TextCatalogReader, the SAXCatalogReader, and the - * DOMCatalogReader.

    - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public interface CatalogReader { - /** - * Read a catalog from a file. - * - *

    This class reads a catalog from a URL.

    - * - * @param catalog The catalog for which this reader is called. - * @param fileUrl The URL of a document to be read. - * @throws MalformedURLException if the specified URL cannot be - * turned into a URL object. - * @throws IOException if the URL cannot be read. - * @throws UnknownCatalogFormatException if the catalog format is - * not recognized. - * @throws UnparseableCatalogException if the catalog cannot be parsed. - * (For example, if it is supposed to be XML and isn't well-formed.) - */ - public void readCatalog(Catalog catalog, String fileUrl) - throws MalformedURLException, IOException, CatalogException; - - /** - * Read a catalog from an input stream. - * - *

    This class reads a catalog from an input stream.

    - * - * @param catalog The catalog for which this reader is called. - * @param is The input stream that is to be read. - * @throws IOException if the URL cannot be read. - * @throws UnknownCatalogFormatException if the catalog format is - * not recognized. - * @throws UnparseableCatalogException if the catalog cannot be parsed. - * (For example, if it is supposed to be XML and isn't well-formed.) - */ - public void readCatalog(Catalog catalog, InputStream is) - throws IOException, CatalogException; -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogParser.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogParser.java deleted file mode 100644 index c0e34011ab0..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogParser.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import org.w3c.dom.Node; - -/** - * The DOMCatalogParser interface. - * - *

    This interface must be implemented in order for a class to - * participate as a parser for the DOMCatalogReader. - * - * @see Catalog - * @see DOMCatalogReader - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public interface DOMCatalogParser { - /** - * Parse a DOM node as a catalog entry. - * - *

    This method is expected to analyze the specified node and - * construct appropriate catalog entry(ies) from it.

    - * - * @param catalog The catalog for which this node is being considered. - * @param node The DOM Node from the catalog. - */ - public void parseCatalogEntry(Catalog catalog, Node node); -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java deleted file mode 100644 index 29f1c965e70..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - */ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogException; -import com.sun.org.apache.xml.internal.resolver.helpers.Namespaces; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; -import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.*; -import org.xml.sax.SAXException; -import sun.reflect.misc.ReflectUtil; - -/** - * A DOM-based CatalogReader. - * - *

    This class is used to read XML Catalogs using the DOM. This reader - * has an advantage over the SAX-based reader that it can analyze the - * DOM tree rather than simply a series of SAX events. It has the disadvantage - * that it requires all of the code necessary to build and walk a DOM - * tree.

    - * - *

    Since the choice of CatalogReaders (in the InputStream case) can only - * be made on the basis of MIME type, the following problem occurs: only - * one CatalogReader can exist for all XML mime types. In order to get - * around this problem, the DOMCatalogReader relies on a set of external - * CatalogParsers to actually build the catalog.

    - * - *

    The selection of CatalogParsers is made on the basis of the QName - * of the root element of the document.

    - * - * - * @see Catalog - * @see CatalogReader - * @see SAXCatalogReader - * @see TextCatalogReader - * @see DOMCatalogParser - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class DOMCatalogReader implements CatalogReader { - /** - * Mapping table from QNames to CatalogParser classes. - * - *

    Each key in this hash table has the form "elementname" - * or "{namespaceuri}elementname". The former is used if the - * namespace URI is null.

    - */ - protected Map namespaceMap = new HashMap<>(); - - /** - * Add a new parser to the reader. - * - *

    This method associates the specified parserClass with the - * namespaceURI/rootElement names specified.

    - * - * @param namespaceURI The namespace URI. Not the prefix. - * @param rootElement The name of the root element. - * @param parserClass The name of the parserClass to instantiate - * for this kind of catalog. - */ - public void setCatalogParser(String namespaceURI, - String rootElement, - String parserClass) { - if (namespaceURI == null) { - namespaceMap.put(rootElement, parserClass); - } else { - namespaceMap.put("{"+namespaceURI+"}"+rootElement, parserClass); - } - } - - /** - * Get the name of the parser class for a given catalog type. - * - *

    This method returns the parserClass associated with the - * namespaceURI/rootElement names specified.

    - * - * @param namespaceURI The namespace URI. Not the prefix. - * @param rootElement The name of the root element. - * @return The parser class. - */ - public String getCatalogParser(String namespaceURI, - String rootElement) { - if (namespaceURI == null) { - return namespaceMap.get(rootElement); - } else { - return namespaceMap.get("{"+namespaceURI+"}"+rootElement); - } - } - - /** - * Null constructor; something for subclasses to call. - */ - public DOMCatalogReader() { } - - /** - * Read a catalog from an input stream. - * - *

    This class reads a catalog from an input stream:

    - * - *
      - *
    • Based on the QName of the root element, it determines which - * parser to instantiate for this catalog.
    • - *
    • It constructs a DOM Document from the catalog and
    • - *
    • For each child of the root node, it calls the parser's - * parseCatalogEntry method. This method is expected to make - * appropriate calls back into the catalog to add entries for the - * entries in the catalog. It is free to do this in whatever manner - * is appropriate (perhaps using just the node passed in, perhaps - * wandering arbitrarily throughout the tree).
    • - *
    - * - * @param catalog The catalog for which this reader is called. - * @param is The input stream that is to be read. - * @throws IOException if the URL cannot be read. - * @throws UnknownCatalogFormatException if the catalog format is - * not recognized. - * @throws UnparseableCatalogException if the catalog cannot be parsed. - * (For example, if it is supposed to be XML and isn't well-formed or - * if the parser class cannot be instantiated.) - */ - public void readCatalog(Catalog catalog, InputStream is) - throws IOException, CatalogException { - - DocumentBuilderFactory factory = null; - DocumentBuilder builder = null; - - factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(false); - factory.setValidating(false); - try { - builder = factory.newDocumentBuilder(); - } catch (ParserConfigurationException pce) { - throw new CatalogException(CatalogException.UNPARSEABLE); - } - - Document doc = null; - - try { - doc = builder.parse(is); - } catch (SAXException se) { - throw new CatalogException(CatalogException.UNKNOWN_FORMAT); - } - - Element root = doc.getDocumentElement(); - - String namespaceURI = Namespaces.getNamespaceURI(root); - String localName = Namespaces.getLocalName(root); - - String domParserClass = getCatalogParser(namespaceURI, - localName); - - if (domParserClass == null) { - if (namespaceURI == null) { - catalog.getCatalogManager().debug.message(1, "No Catalog parser for " - + localName); - } else { - catalog.getCatalogManager().debug.message(1, "No Catalog parser for " - + "{" + namespaceURI + "}" - + localName); - } - return; - } - - DOMCatalogParser domParser = null; - - try { - domParser = (DOMCatalogParser) ReflectUtil.forName(domParserClass).newInstance(); - } catch (ClassNotFoundException cnfe) { - catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass); - throw new CatalogException(CatalogException.UNPARSEABLE); - } catch (InstantiationException ie) { - catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass); - throw new CatalogException(CatalogException.UNPARSEABLE); - } catch (IllegalAccessException iae) { - catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass); - throw new CatalogException(CatalogException.UNPARSEABLE); - } catch (ClassCastException cce ) { - catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass); - throw new CatalogException(CatalogException.UNPARSEABLE); - } - - Node node = root.getFirstChild(); - while (node != null) { - domParser.parseCatalogEntry(catalog, node); - node = node.getNextSibling(); - } - } - - /** - * Read the catalog behind the specified URL. - * - * @see #readCatalog(Catalog, InputStream) - * - * @param catalog The catalog for which we are reading. - * @param fileUrl The URL of the document that should be read. - * - * @throws MalformedURLException if the specified URL cannot be - * turned into a URL object. - * @throws IOException if the URL cannot be read. - * @throws UnknownCatalogFormatException if the catalog format is - * not recognized. - * @throws UnparseableCatalogException if the catalog cannot be parsed. - * (For example, if it is supposed to be XML and isn't well-formed.) - */ - public void readCatalog(Catalog catalog, String fileUrl) - throws MalformedURLException, IOException, CatalogException { - URL url = new URL(fileUrl); - URLConnection urlCon = url.openConnection(); - readCatalog(catalog, urlCon.getInputStream()); - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/ExtendedXMLCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/ExtendedXMLCatalogReader.java deleted file mode 100644 index 2fd0dc6b1e2..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/ExtendedXMLCatalogReader.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import java.util.Vector; -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.Resolver; -import com.sun.org.apache.xml.internal.resolver.CatalogEntry; -import com.sun.org.apache.xml.internal.resolver.CatalogException; - -import org.xml.sax.*; -import org.w3c.dom.*; - -/** - * Parse Extended OASIS Entity Resolution Technical Committee - * XML Catalog files. - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader { - /** The namespace name of extended catalog elements */ - public static final String extendedNamespaceName = "http://nwalsh.com/xcatalog/1.0"; - - /** - * The SAX startElement method recognizes elements - * from the plain catalog format and instantiates CatalogEntry - * objects for them. - * - * @param namespaceURI The namespace name of the element. - * @param localName The local name of the element. - * @param qName The QName of the element. - * @param atts The list of attributes on the element. - * - * @see CatalogEntry - */ - public void startElement (String namespaceURI, - String localName, - String qName, - Attributes atts) - throws SAXException { - - // Check before calling the super because super will report our - // namespace as an extension namespace, but that doesn't count - // for this element. - boolean inExtension = inExtensionNamespace(); - - super.startElement(namespaceURI, localName, qName, atts); - - int entryType = -1; - Vector entryArgs = new Vector(); - - if (namespaceURI != null && extendedNamespaceName.equals(namespaceURI) - && !inExtension) { - // This is an Extended XML Catalog entry - - if (atts.getValue("xml:base") != null) { - String baseURI = atts.getValue("xml:base"); - entryType = Catalog.BASE; - entryArgs.add(baseURI); - baseURIStack.push(baseURI); - - debug.message(4, "xml:base", baseURI); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (base)", localName); - } - } - - entryType = -1; - entryArgs = new Vector(); - } else { - baseURIStack.push(baseURIStack.peek()); - } - - if (localName.equals("uriSuffix")) { - if (checkAttributes(atts, "suffix", "uri")) { - entryType = Resolver.URISUFFIX; - entryArgs.add(atts.getValue("suffix")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "uriSuffix", - atts.getValue("suffix"), - atts.getValue("uri")); - } - } else if (localName.equals("systemSuffix")) { - if (checkAttributes(atts, "suffix", "uri")) { - entryType = Resolver.SYSTEMSUFFIX; - entryArgs.add(atts.getValue("suffix")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "systemSuffix", - atts.getValue("suffix"), - atts.getValue("uri")); - } - } else { - // This is equivalent to an invalid catalog entry type - debug.message(1, "Invalid catalog entry type", localName); - } - - if (entryType >= 0) { - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry", localName); - } - } - } - } - } - - /** The SAX endElement method does nothing. */ - public void endElement (String namespaceURI, - String localName, - String qName) - throws SAXException { - - super.endElement(namespaceURI, localName, qName); - - // Check after popping the stack so we don't erroneously think we - // are our own extension namespace... - boolean inExtension = inExtensionNamespace(); - - int entryType = -1; - Vector entryArgs = new Vector(); - - if (namespaceURI != null - && (extendedNamespaceName.equals(namespaceURI)) - && !inExtension) { - - String popURI = (String) baseURIStack.pop(); - String baseURI = (String) baseURIStack.peek(); - - if (!baseURI.equals(popURI)) { - entryType = Catalog.BASE; - entryArgs.add(baseURI); - - debug.message(4, "(reset) xml:base", baseURI); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (rbase)", localName); - } - } - } - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/OASISXMLCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/OASISXMLCatalogReader.java deleted file mode 100644 index 04ddf623199..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/OASISXMLCatalogReader.java +++ /dev/null @@ -1,546 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogEntry; -import com.sun.org.apache.xml.internal.resolver.CatalogException; -import com.sun.org.apache.xml.internal.resolver.helpers.PublicId; -import java.util.Enumeration; -import java.util.Stack; -import java.util.Vector; -import javax.xml.parsers.SAXParserFactory; -import org.w3c.dom.*; -import org.xml.sax.*; - -/** - * Parse OASIS Entity Resolution Technical Committee - * XML Catalog files. - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalogParser { - /** The catalog object needs to be stored by the object so that - * SAX callbacks can use it. - */ - protected Catalog catalog = null; - - /** The namespace name of OASIS ERTC catalogs */ - public static final String namespaceName = "urn:oasis:names:tc:entity:xmlns:xml:catalog"; - - /** The namespace name of OASIS ERTC TR9401 catalog extension */ - public static final String tr9401NamespaceName = "urn:oasis:names:tc:entity:xmlns:tr9401:catalog"; - - protected Stack baseURIStack = new Stack(); - protected Stack overrideStack = new Stack(); - protected Stack namespaceStack = new Stack(); - - /** Set the current catalog. */ - public void setCatalog (Catalog catalog) { - this.catalog = catalog; - debug = catalog.getCatalogManager().debug; - } - - /** Get the current catalog. */ - public Catalog getCatalog () { - return catalog; - } - - /** Default constructor */ - public OASISXMLCatalogReader() { - super(); - } - - /** Constructor allowing for providing custom SAX parser factory */ - public OASISXMLCatalogReader(SAXParserFactory parserFactory, Catalog catalog) { - super(parserFactory); - setCatalog(catalog); - } - - /** - * Are we in an extension namespace? - * - * @return true if the current stack of open namespaces includes - * an extension namespace. - */ - protected boolean inExtensionNamespace() { - boolean inExtension = false; - - Enumeration elements = namespaceStack.elements(); - while (!inExtension && elements.hasMoreElements()) { - String ns = (String) elements.nextElement(); - if (ns == null) { - inExtension = true; - } else { - inExtension = (!ns.equals(tr9401NamespaceName) - && !ns.equals(namespaceName)); - } - } - - return inExtension; - } - - // ---------------------------------------------------------------------- - // Implement the SAX ContentHandler interface - - /** The SAX setDocumentLocator method does nothing. */ - public void setDocumentLocator (Locator locator) { - return; - } - - /** The SAX startDocument */ - public void startDocument () - throws SAXException { - baseURIStack.push(catalog.getCurrentBase()); - overrideStack.push(catalog.getDefaultOverride()); - return; - } - - /** The SAX endDocument method does nothing. */ - public void endDocument () - throws SAXException { - return; - } - - /** - * The SAX startElement method recognizes elements - * from the plain catalog format and instantiates CatalogEntry - * objects for them. - * - * @param namespaceURI The namespace name of the element. - * @param localName The local name of the element. - * @param qName The QName of the element. - * @param atts The list of attributes on the element. - * - * @see CatalogEntry - */ - public void startElement (String namespaceURI, - String localName, - String qName, - Attributes atts) - throws SAXException { - - int entryType = -1; - Vector entryArgs = new Vector(); - - namespaceStack.push(namespaceURI); - - boolean inExtension = inExtensionNamespace(); - - if (namespaceURI != null && namespaceName.equals(namespaceURI) - && !inExtension) { - // This is an XML Catalog entry - - if (atts.getValue("xml:base") != null) { - String baseURI = atts.getValue("xml:base"); - entryType = Catalog.BASE; - entryArgs.add(baseURI); - baseURIStack.push(baseURI); - - debug.message(4, "xml:base", baseURI); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (base)", localName); - } - } - - entryType = -1; - entryArgs = new Vector(); - - } else { - baseURIStack.push(baseURIStack.peek()); - } - - if ((localName.equals("catalog") || localName.equals("group")) - && atts.getValue("prefer") != null) { - String override = atts.getValue("prefer"); - - if (override.equals("public")) { - override = "yes"; - } else if (override.equals("system")) { - override = "no"; - } else { - debug.message(1, - "Invalid prefer: must be 'system' or 'public'", - localName); - override = catalog.getDefaultOverride(); - } - - entryType = Catalog.OVERRIDE; - entryArgs.add(override); - overrideStack.push(override); - - debug.message(4, "override", override); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (override)", localName); - } - } - - entryType = -1; - entryArgs = new Vector(); - - } else { - overrideStack.push(overrideStack.peek()); - } - - if (localName.equals("delegatePublic")) { - if (checkAttributes(atts, "publicIdStartString", "catalog")) { - entryType = Catalog.DELEGATE_PUBLIC; - entryArgs.add(atts.getValue("publicIdStartString")); - entryArgs.add(atts.getValue("catalog")); - - debug.message(4, "delegatePublic", - PublicId.normalize(atts.getValue("publicIdStartString")), - atts.getValue("catalog")); - } - } else if (localName.equals("delegateSystem")) { - if (checkAttributes(atts, "systemIdStartString", "catalog")) { - entryType = Catalog.DELEGATE_SYSTEM; - entryArgs.add(atts.getValue("systemIdStartString")); - entryArgs.add(atts.getValue("catalog")); - - debug.message(4, "delegateSystem", - atts.getValue("systemIdStartString"), - atts.getValue("catalog")); - } - } else if (localName.equals("delegateURI")) { - if (checkAttributes(atts, "uriStartString", "catalog")) { - entryType = Catalog.DELEGATE_URI; - entryArgs.add(atts.getValue("uriStartString")); - entryArgs.add(atts.getValue("catalog")); - - debug.message(4, "delegateURI", - atts.getValue("uriStartString"), - atts.getValue("catalog")); - } - } else if (localName.equals("rewriteSystem")) { - if (checkAttributes(atts, "systemIdStartString", "rewritePrefix")) { - entryType = Catalog.REWRITE_SYSTEM; - entryArgs.add(atts.getValue("systemIdStartString")); - entryArgs.add(atts.getValue("rewritePrefix")); - - debug.message(4, "rewriteSystem", - atts.getValue("systemIdStartString"), - atts.getValue("rewritePrefix")); - } - } else if (localName.equals("systemSuffix")) { - if (checkAttributes(atts, "systemIdSuffix", "uri")) { - entryType = Catalog.SYSTEM_SUFFIX; - entryArgs.add(atts.getValue("systemIdSuffix")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "systemSuffix", - atts.getValue("systemIdSuffix"), - atts.getValue("uri")); - } - } else if (localName.equals("rewriteURI")) { - if (checkAttributes(atts, "uriStartString", "rewritePrefix")) { - entryType = Catalog.REWRITE_URI; - entryArgs.add(atts.getValue("uriStartString")); - entryArgs.add(atts.getValue("rewritePrefix")); - - debug.message(4, "rewriteURI", - atts.getValue("uriStartString"), - atts.getValue("rewritePrefix")); - } - } else if (localName.equals("uriSuffix")) { - if (checkAttributes(atts, "uriSuffix", "uri")) { - entryType = Catalog.URI_SUFFIX; - entryArgs.add(atts.getValue("uriSuffix")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "uriSuffix", - atts.getValue("uriSuffix"), - atts.getValue("uri")); - } - } else if (localName.equals("nextCatalog")) { - if (checkAttributes(atts, "catalog")) { - entryType = Catalog.CATALOG; - entryArgs.add(atts.getValue("catalog")); - - debug.message(4, "nextCatalog", atts.getValue("catalog")); - } - } else if (localName.equals("public")) { - if (checkAttributes(atts, "publicId", "uri")) { - entryType = Catalog.PUBLIC; - entryArgs.add(atts.getValue("publicId")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "public", - PublicId.normalize(atts.getValue("publicId")), - atts.getValue("uri")); - } - } else if (localName.equals("system")) { - if (checkAttributes(atts, "systemId", "uri")) { - entryType = Catalog.SYSTEM; - entryArgs.add(atts.getValue("systemId")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "system", - atts.getValue("systemId"), - atts.getValue("uri")); - } - } else if (localName.equals("uri")) { - if (checkAttributes(atts, "name", "uri")) { - entryType = Catalog.URI; - entryArgs.add(atts.getValue("name")); - entryArgs.add(atts.getValue("uri")); - - debug.message(4, "uri", - atts.getValue("name"), - atts.getValue("uri")); - } - } else if (localName.equals("catalog")) { - // nop, start of catalog - } else if (localName.equals("group")) { - // nop, a group - } else { - // This is equivalent to an invalid catalog entry type - debug.message(1, "Invalid catalog entry type", localName); - } - - if (entryType >= 0) { - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry", localName); - } - } - } - } - - if (namespaceURI != null && tr9401NamespaceName.equals(namespaceURI) - && !inExtension) { - // This is a TR9401 Catalog entry - - if (atts.getValue("xml:base") != null) { - String baseURI = atts.getValue("xml:base"); - entryType = Catalog.BASE; - entryArgs.add(baseURI); - baseURIStack.push(baseURI); - - debug.message(4, "xml:base", baseURI); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (base)", localName); - } - } - - entryType = -1; - entryArgs = new Vector(); - - } else { - baseURIStack.push(baseURIStack.peek()); - } - - if (localName.equals("doctype")) { - entryType = Catalog.DOCTYPE; - entryArgs.add(atts.getValue("name")); - entryArgs.add(atts.getValue("uri")); - } else if (localName.equals("document")) { - entryType = Catalog.DOCUMENT; - entryArgs.add(atts.getValue("uri")); - } else if (localName.equals("dtddecl")) { - entryType = Catalog.DTDDECL; - entryArgs.add(atts.getValue("publicId")); - entryArgs.add(atts.getValue("uri")); - } else if (localName.equals("entity")) { - entryType = Catalog.ENTITY; - entryArgs.add(atts.getValue("name")); - entryArgs.add(atts.getValue("uri")); - } else if (localName.equals("linktype")) { - entryType = Catalog.LINKTYPE; - entryArgs.add(atts.getValue("name")); - entryArgs.add(atts.getValue("uri")); - } else if (localName.equals("notation")) { - entryType = Catalog.NOTATION; - entryArgs.add(atts.getValue("name")); - entryArgs.add(atts.getValue("uri")); - } else if (localName.equals("sgmldecl")) { - entryType = Catalog.SGMLDECL; - entryArgs.add(atts.getValue("uri")); - } else { - // This is equivalent to an invalid catalog entry type - debug.message(1, "Invalid catalog entry type", localName); - } - - if (entryType >= 0) { - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry", localName); - } - } - } - } - } - - public boolean checkAttributes (Attributes atts, String attName) { - if (atts.getValue(attName) == null) { - debug.message(1, "Error: required attribute " + attName + " missing."); - return false; - } else { - return true; - } - } - - public boolean checkAttributes (Attributes atts, - String attName1, - String attName2) { - return checkAttributes(atts, attName1) - && checkAttributes(atts, attName2); - } - - /** The SAX endElement */ - public void endElement (String namespaceURI, - String localName, - String qName) - throws SAXException { - - int entryType = -1; - Vector entryArgs = new Vector(); - - boolean inExtension = inExtensionNamespace(); - - if (namespaceURI != null - && !inExtension - && (namespaceName.equals(namespaceURI) - || tr9401NamespaceName.equals(namespaceURI))) { - - String popURI = (String) baseURIStack.pop(); - String baseURI = (String) baseURIStack.peek(); - - if (!baseURI.equals(popURI)) { - entryType = Catalog.BASE; - entryArgs.add(baseURI); - - debug.message(4, "(reset) xml:base", baseURI); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (rbase)", localName); - } - } - } - } - - if (namespaceURI != null && namespaceName.equals(namespaceURI) - && !inExtension) { - if (localName.equals("catalog") || localName.equals("group")) { - String popOverride = (String) overrideStack.pop(); - String override = (String) overrideStack.peek(); - - if (!override.equals(popOverride)) { - entryType = Catalog.OVERRIDE; - entryArgs.add(override); - overrideStack.push(override); - - debug.message(4, "(reset) override", override); - - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry (roverride)", localName); - } - } - } - } - } - - namespaceStack.pop(); - - return; - } - - /** The SAX characters method does nothing. */ - public void characters (char ch[], int start, int length) - throws SAXException { - return; - } - - /** The SAX ignorableWhitespace method does nothing. */ - public void ignorableWhitespace (char ch[], int start, int length) - throws SAXException { - return; - } - - /** The SAX processingInstruction method does nothing. */ - public void processingInstruction (String target, String data) - throws SAXException { - return; - } - - /** The SAX skippedEntity method does nothing. */ - public void skippedEntity (String name) - throws SAXException { - return; - } - - /** The SAX startPrefixMapping method does nothing. */ - public void startPrefixMapping(String prefix, String uri) - throws SAXException { - return; - } - - /** The SAX endPrefixMapping method does nothing. */ - public void endPrefixMapping(String prefix) - throws SAXException { - return; - } - -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogParser.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogParser.java deleted file mode 100644 index b70f7dc64fe..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogParser.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import org.xml.sax.*; - -/** - * The SAXCatalogParser interface. - * - *

    This interface must be implemented in order for a class to - * participate as a parser for the SAXCatalogReader. - * - * @see Catalog - * @see SAXCatalogReader - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public interface SAXCatalogParser extends ContentHandler, DocumentHandler { - /** Set the Catalog for which parsing is being performed. */ - public void setCatalog(Catalog catalog); -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java deleted file mode 100644 index 0ac3e03873d..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXCatalogReader.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - */ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogException; -import com.sun.org.apache.xml.internal.resolver.CatalogManager; -import com.sun.org.apache.xml.internal.resolver.helpers.Debug; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.Map; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import org.xml.sax.AttributeList; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.DocumentHandler; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.Parser; -import org.xml.sax.SAXException; -import sun.reflect.misc.ReflectUtil; - -/** - * A SAX-based CatalogReader. - * - *

    This class is used to read XML Catalogs using the SAX. This reader - * has an advantage over the DOM-based reader in that it functions on - * the stream of SAX events. It has the disadvantage - * that it cannot look around in the tree.

    - * - *

    Since the choice of CatalogReaders (in the InputStream case) can only - * be made on the basis of MIME type, the following problem occurs: only - * one CatalogReader can exist for all XML mime types. In order to get - * around this problem, the SAXCatalogReader relies on a set of external - * CatalogParsers to actually build the catalog.

    - * - *

    The selection of CatalogParsers is made on the basis of the QName - * of the root element of the document.

    - * - * @see Catalog - * @see CatalogReader - * @see SAXCatalogReader - * @see TextCatalogReader - * @see DOMCatalogParser - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class SAXCatalogReader implements CatalogReader, ContentHandler, DocumentHandler { - /** The SAX Parser Factory */ - protected SAXParserFactory parserFactory = null; - - /** The SAX Parser Class */ - protected String parserClass = null; - - /** - * Mapping table from QNames to CatalogParser classes. - * - *

    Each key in this hash table has the form "elementname" - * or "{namespaceuri}elementname". The former is used if the - * namespace URI is null.

    - */ - protected Map namespaceMap = new HashMap<>(); - - /** The parser in use for the current catalog. */ - private SAXCatalogParser saxParser = null; - - /** Set if something goes horribly wrong. It allows the class to - * ignore the rest of the events that are received. - */ - private boolean abandonHope = false; - - /** The Catalog that we're working for. */ - private Catalog catalog; - - /** Set the XML SAX Parser Factory. - */ - public void setParserFactory(SAXParserFactory parserFactory) { - this.parserFactory = parserFactory; - } - - /** Set the XML SAX Parser Class - */ - public void setParserClass(String parserClass) { - this.parserClass = parserClass; - } - - /** Get the parser factory currently in use. */ - public SAXParserFactory getParserFactory() { - return parserFactory; - } - - /** Get the parser class currently in use. */ - public String getParserClass() { - return parserClass; - } - - /** The debug class to use for this reader. - * - * This is a bit of a hack. Anyway, whenever we read for a catalog, - * we extract the debug object - * from the catalog's manager so that we can use it to print messages. - * - * In production, we don't really expect any messages so it doesn't - * really matter. But it's still a bit of a hack. - */ - protected Debug debug = CatalogManager.getStaticManager().debug; - - /** The constructor */ - public SAXCatalogReader() { - parserFactory = null; - parserClass = null; - } - - /** The constructor */ - public SAXCatalogReader(SAXParserFactory parserFactory) { - this.parserFactory = parserFactory; - } - - /** The constructor */ - public SAXCatalogReader(String parserClass) { - this.parserClass = parserClass; - } - - /** - * Set the SAXCatalogParser class for the given namespace/root - * element type. - */ - public void setCatalogParser(String namespaceURI, - String rootElement, - String parserClass) { - namespaceURI = namespaceURI != null ? namespaceURI.trim() : ""; - namespaceMap.put("{"+namespaceURI+"}"+rootElement, parserClass); - } - - /** - * Get the SAXCatalogParser class for the given namespace/root - * element type. - */ - public String getCatalogParser(String namespaceURI, - String rootElement) { - namespaceURI = namespaceURI != null ? namespaceURI.trim() : ""; - return namespaceMap.get("{"+namespaceURI+"}"+rootElement); - } - - /** - * Parse an XML Catalog file. - * - * @param catalog The catalog to which this catalog file belongs - * @param fileUrl The URL or filename of the catalog file to process - * - * @throws MalformedURLException Improper fileUrl - * @throws IOException Error reading catalog file - */ - public void readCatalog(Catalog catalog, String fileUrl) - throws MalformedURLException, IOException, - CatalogException { - - URL url = null; - - try { - url = new URL(fileUrl); - } catch (MalformedURLException e) { - url = new URL("file:///" + fileUrl); - } - - debug = catalog.getCatalogManager().debug; - - try { - URLConnection urlCon = url.openConnection(); - readCatalog(catalog, urlCon.getInputStream()); - } catch (FileNotFoundException e) { - catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found", - url.toString()); - } - } - - /** - * Parse an XML Catalog stream. - * - * @param catalog The catalog to which this catalog file belongs - * @param is The input stream from which the catalog will be read - * - * @throws MalformedURLException Improper fileUrl - * @throws IOException Error reading catalog file - * @throws CatalogException A Catalog exception - */ - public void readCatalog(Catalog catalog, InputStream is) - throws IOException, CatalogException { - - // Create an instance of the parser - if (parserFactory == null && parserClass == null) { - debug.message(1, "Cannot read SAX catalog without a parser"); - throw new CatalogException(CatalogException.UNPARSEABLE); - } - - debug = catalog.getCatalogManager().debug; - EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver(); - - this.catalog = catalog; - - try { - if (parserFactory != null) { - SAXParser parser = parserFactory.newSAXParser(); - SAXParserHandler spHandler = new SAXParserHandler(); - spHandler.setContentHandler(this); - if (bResolver != null) { - spHandler.setEntityResolver(bResolver); - } - parser.parse(new InputSource(is), spHandler); - } else { - Class c = ReflectUtil.forName(parserClass); - if (!Parser.class.isAssignableFrom(c)) { - throw new ClassCastException(parserClass - + " cannot be cast to " - + Parser.class.getName()); - } - Parser parser = (Parser) c.newInstance(); - parser.setDocumentHandler(this); - if (bResolver != null) { - parser.setEntityResolver(bResolver); - } - parser.parse(new InputSource(is)); - } - } catch (ClassNotFoundException cnfe) { - throw new CatalogException(CatalogException.UNPARSEABLE); - } catch (IllegalAccessException iae) { - throw new CatalogException(CatalogException.UNPARSEABLE); - } catch (InstantiationException ie) { - throw new CatalogException(CatalogException.UNPARSEABLE); - } catch (ParserConfigurationException pce) { - throw new CatalogException(CatalogException.UNKNOWN_FORMAT); - } catch (SAXException se) { - Exception e = se.getException(); - // FIXME: there must be a better way - UnknownHostException uhe = new UnknownHostException(); - FileNotFoundException fnfe = new FileNotFoundException(); - if (e != null) { - if (e.getClass() == uhe.getClass()) { - throw new CatalogException(CatalogException.PARSE_FAILED, - e.toString()); - } else if (e.getClass() == fnfe.getClass()) { - throw new CatalogException(CatalogException.PARSE_FAILED, - e.toString()); - } - } - throw new CatalogException(se); - } - } - - // ---------------------------------------------------------------------- - // Implement the SAX ContentHandler interface - - /** The SAX setDocumentLocator method. Does nothing. */ - public void setDocumentLocator (Locator locator) { - if (saxParser != null) { - saxParser.setDocumentLocator(locator); - } - } - - /** The SAX startDocument method. Does nothing. */ - public void startDocument () throws SAXException { - saxParser = null; - abandonHope = false; - return; - } - - /** The SAX endDocument method. Does nothing. */ - public void endDocument ()throws SAXException { - if (saxParser != null) { - saxParser.endDocument(); - } - } - - /** - * The SAX startElement method. - * - *

    The catalog parser is selected based on the namespace of the - * first element encountered in the catalog.

    - */ - public void startElement (String name, - AttributeList atts) - throws SAXException { - - if (abandonHope) { - return; - } - - if (saxParser == null) { - String prefix = ""; - if (name.indexOf(':') > 0) { - prefix = name.substring(0, name.indexOf(':')); - } - - String localName = name; - if (localName.indexOf(':') > 0) { - localName = localName.substring(localName.indexOf(':')+1); - } - - String namespaceURI = null; - if (prefix.length() == 0) { - namespaceURI = atts.getValue("xmlns"); - } else { - namespaceURI = atts.getValue("xmlns:" + prefix); - } - - String saxParserClass = getCatalogParser(namespaceURI, - localName); - - if (saxParserClass == null) { - abandonHope = true; - if (namespaceURI == null) { - debug.message(2, "No Catalog parser for " + name); - } else { - debug.message(2, "No Catalog parser for " - + "{" + namespaceURI + "}" - + name); - } - return; - } - - try { - saxParser = (SAXCatalogParser) - ReflectUtil.forName(saxParserClass).newInstance(); - - saxParser.setCatalog(catalog); - saxParser.startDocument(); - saxParser.startElement(name, atts); - } catch (ClassNotFoundException cnfe) { - saxParser = null; - abandonHope = true; - debug.message(2, cnfe.toString()); - } catch (InstantiationException ie) { - saxParser = null; - abandonHope = true; - debug.message(2, ie.toString()); - } catch (IllegalAccessException iae) { - saxParser = null; - abandonHope = true; - debug.message(2, iae.toString()); - } catch (ClassCastException cce ) { - saxParser = null; - abandonHope = true; - debug.message(2, cce.toString()); - } - } else { - saxParser.startElement(name, atts); - } - } - - /** - * The SAX2 startElement method. - * - *

    The catalog parser is selected based on the namespace of the - * first element encountered in the catalog.

    - */ - public void startElement (String namespaceURI, - String localName, - String qName, - Attributes atts) - throws SAXException { - - if (abandonHope) { - return; - } - - if (saxParser == null) { - String saxParserClass = getCatalogParser(namespaceURI, - localName); - - if (saxParserClass == null) { - abandonHope = true; - if (namespaceURI == null) { - debug.message(2, "No Catalog parser for " + localName); - } else { - debug.message(2, "No Catalog parser for " - + "{" + namespaceURI + "}" - + localName); - } - return; - } - - try { - saxParser = (SAXCatalogParser) - ReflectUtil.forName(saxParserClass).newInstance(); - - saxParser.setCatalog(catalog); - saxParser.startDocument(); - saxParser.startElement(namespaceURI, localName, qName, atts); - } catch (ClassNotFoundException cnfe) { - saxParser = null; - abandonHope = true; - debug.message(2, cnfe.toString()); - } catch (InstantiationException ie) { - saxParser = null; - abandonHope = true; - debug.message(2, ie.toString()); - } catch (IllegalAccessException iae) { - saxParser = null; - abandonHope = true; - debug.message(2, iae.toString()); - } catch (ClassCastException cce ) { - saxParser = null; - abandonHope = true; - debug.message(2, cce.toString()); - } - } else { - saxParser.startElement(namespaceURI, localName, qName, atts); - } - } - - /** The SAX endElement method. Does nothing. */ - public void endElement (String name) throws SAXException { - if (saxParser != null) { - saxParser.endElement(name); - } - } - - /** The SAX2 endElement method. Does nothing. */ - public void endElement (String namespaceURI, - String localName, - String qName) throws SAXException { - if (saxParser != null) { - saxParser.endElement(namespaceURI, localName, qName); - } - } - - /** The SAX characters method. Does nothing. */ - public void characters (char ch[], int start, int length) - throws SAXException { - if (saxParser != null) { - saxParser.characters(ch, start, length); - } - } - - /** The SAX ignorableWhitespace method. Does nothing. */ - public void ignorableWhitespace (char ch[], int start, int length) - throws SAXException { - if (saxParser != null) { - saxParser.ignorableWhitespace(ch, start, length); - } - } - - /** The SAX processingInstruction method. Does nothing. */ - public void processingInstruction (String target, String data) - throws SAXException { - if (saxParser != null) { - saxParser.processingInstruction(target, data); - } - } - - /** The SAX startPrefixMapping method. Does nothing. */ - public void startPrefixMapping (String prefix, String uri) - throws SAXException { - if (saxParser != null) { - saxParser.startPrefixMapping (prefix, uri); - } - } - - /** The SAX endPrefixMapping method. Does nothing. */ - public void endPrefixMapping (String prefix) - throws SAXException { - if (saxParser != null) { - saxParser.endPrefixMapping (prefix); - } - } - - /** The SAX skippedentity method. Does nothing. */ - public void skippedEntity (String name) - throws SAXException { - if (saxParser != null) { - saxParser.skippedEntity(name); - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXParserHandler.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXParserHandler.java deleted file mode 100644 index efcf32950df..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/SAXParserHandler.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import java.io.IOException; - -import org.xml.sax.*; -import org.xml.sax.helpers.*; - -/** - * An entity-resolving DefaultHandler. - * - *

    This class provides a SAXParser DefaultHandler that performs - * entity resolution. - *

    - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - */ -public class SAXParserHandler extends DefaultHandler { - private EntityResolver er = null; - private ContentHandler ch = null; - - public SAXParserHandler() { - super(); - } - - public void setEntityResolver(EntityResolver er) { - this.er = er; - } - - public void setContentHandler(ContentHandler ch) { - this.ch = ch; - } - - // Entity Resolver - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException { - - if (er != null) { - try { - return er.resolveEntity(publicId, systemId); - } catch (IOException e) { - System.out.println("resolveEntity threw IOException!"); - return null; - } - } else { - return null; - } - } - - // Content Handler - public void characters(char[] ch, int start, int length) - throws SAXException { - if (this.ch != null) { - this.ch.characters(ch, start, length); - } - } - - public void endDocument() - throws SAXException { - if (ch != null) { - ch.endDocument(); - } - } - - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { - if (ch != null) { - ch.endElement(namespaceURI, localName, qName); - } - } - - public void endPrefixMapping(String prefix) - throws SAXException { - if (ch != null) { - ch.endPrefixMapping(prefix); - } - } - - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException { - if (this.ch != null) { - this.ch.ignorableWhitespace(ch, start, length); - } - } - - public void processingInstruction(String target, String data) - throws SAXException { - if (ch != null) { - ch.processingInstruction(target, data); - } - } - - public void setDocumentLocator(Locator locator) { - if (ch != null) { - ch.setDocumentLocator(locator); - } - } - - public void skippedEntity(String name) - throws SAXException { - if (ch != null) { - ch.skippedEntity(name); - } - } - - public void startDocument() - throws SAXException { - if (ch != null) { - ch.startDocument(); - } - } - - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) - throws SAXException { - if (ch != null) { - ch.startElement(namespaceURI, localName, qName, atts); - } - } - - public void startPrefixMapping(String prefix, String uri) - throws SAXException { - if (ch != null) { - ch.startPrefixMapping(prefix, uri); - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TR9401CatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TR9401CatalogReader.java deleted file mode 100644 index fb39a433063..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TR9401CatalogReader.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogEntry; -import com.sun.org.apache.xml.internal.resolver.CatalogException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.util.Locale; -import java.util.Vector; - -/** - * Parses OASIS Open Catalog files. - * - *

    This class reads OASIS Open Catalog files, returning a stream - * of tokens.

    - * - *

    This code interrogates the following non-standard system properties:

    - * - *
    - *
    xml.catalog.debug
    - *

    Sets the debug level. A value of 0 is assumed if the - * property is not set or is not a number.

    - *
    - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class TR9401CatalogReader extends TextCatalogReader { - - /** - * Start parsing an OASIS TR9401 Open Catalog file. The file is - * actually read and parsed - * as needed by nextEntry. - * - *

    In a TR9401 Catalog the 'DELEGATE' entry delegates public - * identifiers. There is no delegate entry for system identifiers - * or URIs.

    - * - * @param catalog The Catalog to populate - * @param is The input stream from which to read the TR9401 Catalog - * - * @throws MalformedURLException Improper fileUrl - * @throws IOException Error reading catalog file - */ - public void readCatalog(Catalog catalog, InputStream is) - throws MalformedURLException, IOException { - - catfile = is; - - if (catfile == null) { - return; - } - - Vector unknownEntry = null; - - try { - while (true) { - String token = nextToken(); - - if (token == null) { - if (unknownEntry != null) { - catalog.unknownEntry(unknownEntry); - unknownEntry = null; - } - catfile.close(); - catfile = null; - return; - } - - String entryToken = null; - if (caseSensitive) { - entryToken = token; - } else { - entryToken = token.toUpperCase(Locale.ENGLISH); - } - - if (entryToken.equals("DELEGATE")) { - entryToken = "DELEGATE_PUBLIC"; - } - - try { - int type = CatalogEntry.getEntryType(entryToken); - int numArgs = CatalogEntry.getEntryArgCount(type); - Vector args = new Vector(); - - if (unknownEntry != null) { - catalog.unknownEntry(unknownEntry); - unknownEntry = null; - } - - for (int count = 0; count < numArgs; count++) { - args.addElement(nextToken()); - } - - catalog.addEntry(new CatalogEntry(entryToken, args)); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - if (unknownEntry == null) { - unknownEntry = new Vector(); - } - unknownEntry.addElement(token); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token); - unknownEntry = null; - } else if (cex.getExceptionType() == CatalogException.UNENDED_COMMENT) { - catalog.getCatalogManager().debug.message(1, cex.getMessage()); - } - } - } - } catch (CatalogException cex2) { - if (cex2.getExceptionType() == CatalogException.UNENDED_COMMENT) { - catalog.getCatalogManager().debug.message(1, cex2.getMessage()); - } - } - - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TextCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TextCatalogReader.java deleted file mode 100644 index 9440e3370cb..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/TextCatalogReader.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogEntry; -import com.sun.org.apache.xml.internal.resolver.CatalogException; -import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.Locale; -import java.util.Stack; -import java.util.Vector; - -/** - * Parses plain text Catalog files. - * - *

    This class reads plain text Open Catalog files.

    - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class TextCatalogReader implements CatalogReader { - /** The input stream used to read the catalog */ - protected InputStream catfile = null; - - /** - * Character lookahead stack. Reading a catalog sometimes requires - * up to two characters of lookahead. - */ - protected int[] stack = new int[3]; - - /** - * Token stack. Recognizing an unexpected catalog entry requires - * the ability to "push back" a token. - */ - protected Stack tokenStack = new Stack(); - - /** The current position on the lookahead stack */ - protected int top = -1; - - /** Are keywords in the catalog case sensitive? */ - protected boolean caseSensitive = false; - - /** - * Construct a CatalogReader object. - */ - public TextCatalogReader() { } - - public void setCaseSensitive(boolean isCaseSensitive) { - caseSensitive = isCaseSensitive; - } - - public boolean getCaseSensitive() { - return caseSensitive; - } - - /** - * Start parsing a text catalog file. The file is - * actually read and parsed - * as needed by nextEntry.

    - * - * @param fileUrl The URL or filename of the catalog file to process - * - * @throws MalformedURLException Improper fileUrl - * @throws IOException Error reading catalog file - */ - public void readCatalog(Catalog catalog, String fileUrl) - throws MalformedURLException, IOException { - URL catURL = null; - - try { - catURL = new URL(fileUrl); - } catch (MalformedURLException e) { - catURL = new URL("file:///" + fileUrl); - } - - URLConnection urlCon = catURL.openConnection(); - try { - readCatalog(catalog, urlCon.getInputStream()); - } catch (FileNotFoundException e) { - catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found", - catURL.toString()); - } - } - - public void readCatalog(Catalog catalog, InputStream is) - throws MalformedURLException, IOException { - - catfile = is; - - if (catfile == null) { - return; - } - - Vector unknownEntry = null; - - try { - while (true) { - String token = nextToken(); - - if (token == null) { - if (unknownEntry != null) { - catalog.unknownEntry(unknownEntry); - unknownEntry = null; - } - catfile.close(); - catfile = null; - return; - } - - String entryToken = null; - if (caseSensitive) { - entryToken = token; - } else { - entryToken = token.toUpperCase(Locale.ENGLISH); - } - - try { - int type = CatalogEntry.getEntryType(entryToken); - int numArgs = CatalogEntry.getEntryArgCount(type); - Vector args = new Vector(); - - if (unknownEntry != null) { - catalog.unknownEntry(unknownEntry); - unknownEntry = null; - } - - for (int count = 0; count < numArgs; count++) { - args.addElement(nextToken()); - } - - catalog.addEntry(new CatalogEntry(entryToken, args)); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - if (unknownEntry == null) { - unknownEntry = new Vector(); - } - unknownEntry.addElement(token); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token); - unknownEntry = null; - } else if (cex.getExceptionType() == CatalogException.UNENDED_COMMENT) { - catalog.getCatalogManager().debug.message(1, cex.getMessage()); - } - } - } - } catch (CatalogException cex2) { - if (cex2.getExceptionType() == CatalogException.UNENDED_COMMENT) { - catalog.getCatalogManager().debug.message(1, cex2.getMessage()); - } - } - } - - /** - * The destructor. - * - *

    Makes sure the catalog file is closed.

    - */ - protected void finalize() { - if (catfile != null) { - try { - catfile.close(); - } catch (IOException e) { - // whatever... - } - } - catfile = null; - } - - // ----------------------------------------------------------------- - - /** - * Return the next token in the catalog file. - * - *

    FYI: This code does not throw any sort of exception for - * a file that contains an n - * - * @return The Catalog file token from the input stream. - * @throws IOException If an error occurs reading from the stream. - */ - protected String nextToken() throws IOException, CatalogException { - String token = ""; - int ch, nextch; - - if (!tokenStack.empty()) { - return (String) tokenStack.pop(); - } - - // Skip over leading whitespace and comments - while (true) { - // skip leading whitespace - ch = catfile.read(); - while (ch <= ' ') { // all ctrls are whitespace - ch = catfile.read(); - if (ch < 0) { - return null; - } - } - - // now 'ch' is the current char from the file - nextch = catfile.read(); - if (nextch < 0) { - return null; - } - - if (ch == '-' && nextch == '-') { - // we've found a comment, skip it... - ch = ' '; - nextch = nextChar(); - while ((ch != '-' || nextch != '-') && nextch > 0) { - ch = nextch; - nextch = nextChar(); - } - - if (nextch < 0) { - throw new CatalogException(CatalogException.UNENDED_COMMENT, - "Unterminated comment in catalog file; EOF treated as end-of-comment."); - } - - // Ok, we've found the end of the comment, - // loop back to the top and start again... - } else { - stack[++top] = nextch; - stack[++top] = ch; - break; - } - } - - ch = nextChar(); - if (ch == '"' || ch == '\'') { - int quote = ch; - while ((ch = nextChar()) != quote) { - char[] chararr = new char[1]; - chararr[0] = (char) ch; - String s = new String(chararr); - token = token.concat(s); - } - return token; - } else { - // return the next whitespace or comment delimited - // string - while (ch > ' ') { - nextch = nextChar(); - if (ch == '-' && nextch == '-') { - stack[++top] = ch; - stack[++top] = nextch; - return token; - } else { - char[] chararr = new char[1]; - chararr[0] = (char) ch; - String s = new String(chararr); - token = token.concat(s); - ch = nextch; - } - } - return token; - } - } - - /** - * Return the next logical character from the input stream. - * - * @return The next (logical) character from the input stream. The - * character may be buffered from a previous lookahead. - * - * @throws IOException If an error occurs reading from the stream. - */ - protected int nextChar() throws IOException { - if (top < 0) { - return catfile.read(); - } else { - return stack[top--]; - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/XCatalogReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/XCatalogReader.java deleted file mode 100644 index ce8cc40d6a8..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/XCatalogReader.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.readers; - -import java.util.Vector; -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogEntry; -import com.sun.org.apache.xml.internal.resolver.CatalogException; -import com.sun.org.apache.xml.internal.resolver.helpers.PublicId; - -import org.xml.sax.*; - -import javax.xml.parsers.*; - -/** - * Parse "XCatalog" XML Catalog files, this is the XML Catalog format - * developed by John Cowan and supported by Apache. - * - * @see Catalog - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - */ -public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser { - /** The catalog object needs to be stored by the object so that - * SAX callbacks can use it. - */ - protected Catalog catalog = null; - - /** Set the current catalog. */ - public void setCatalog (Catalog catalog) { - this.catalog = catalog; - debug = catalog.getCatalogManager().debug; - } - - /** Get the current catalog. */ - public Catalog getCatalog () { - return catalog; - } - - /** Default constructor */ - public XCatalogReader() { - super(); - } - - /** Constructor allowing for providing custom SAX parser factory */ - public XCatalogReader(SAXParserFactory parserFactory, Catalog catalog) { - super(parserFactory); - setCatalog(catalog); - } - - // ---------------------------------------------------------------------- - // Implement the SAX ContentHandler interface - - /** The SAX setDocumentLocator method does nothing. */ - public void setDocumentLocator (Locator locator) { - return; - } - - /** The SAX startDocument method does nothing. */ - public void startDocument () - throws SAXException { - return; - } - - /** The SAX endDocument method does nothing. */ - public void endDocument () - throws SAXException { - return; - } - - /** - * The SAX startElement method recognizes elements - * from the plain catalog format and instantiates CatalogEntry - * objects for them. - * - * @param namespaceURI The namespace name of the element. - * @param localName The local name of the element. - * @param qName The QName of the element. - * @param atts The list of attributes on the element. - * - * @see CatalogEntry - */ - public void startElement (String namespaceURI, - String localName, - String qName, - Attributes atts) - throws SAXException { - - int entryType = -1; - Vector entryArgs = new Vector(); - - if (localName.equals("Base")) { - entryType = Catalog.BASE; - entryArgs.add(atts.getValue("HRef")); - - debug.message(4, "Base", atts.getValue("HRef")); - } else if (localName.equals("Delegate")) { - entryType = Catalog.DELEGATE_PUBLIC; - entryArgs.add(atts.getValue("PublicID")); - entryArgs.add(atts.getValue("HRef")); - - debug.message(4, "Delegate", - PublicId.normalize(atts.getValue("PublicID")), - atts.getValue("HRef")); - } else if (localName.equals("Extend")) { - entryType = Catalog.CATALOG; - entryArgs.add(atts.getValue("HRef")); - - debug.message(4, "Extend", atts.getValue("HRef")); - } else if (localName.equals("Map")) { - entryType = Catalog.PUBLIC; - entryArgs.add(atts.getValue("PublicID")); - entryArgs.add(atts.getValue("HRef")); - - debug.message(4, "Map", - PublicId.normalize(atts.getValue("PublicID")), - atts.getValue("HRef")); - } else if (localName.equals("Remap")) { - entryType = Catalog.SYSTEM; - entryArgs.add(atts.getValue("SystemID")); - entryArgs.add(atts.getValue("HRef")); - - debug.message(4, "Remap", - atts.getValue("SystemID"), - atts.getValue("HRef")); - } else if (localName.equals("XCatalog")) { - // nop, start of catalog - } else { - // This is equivalent to an invalid catalog entry type - debug.message(1, "Invalid catalog entry type", localName); - } - - if (entryType >= 0) { - try { - CatalogEntry ce = new CatalogEntry(entryType, entryArgs); - catalog.addEntry(ce); - } catch (CatalogException cex) { - if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { - debug.message(1, "Invalid catalog entry type", localName); - } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { - debug.message(1, "Invalid catalog entry", localName); - } - } - } - } - - /** The SAX endElement method does nothing. */ - public void endElement (String namespaceURI, - String localName, - String qName) - throws SAXException { - return; - } - - /** The SAX characters method does nothing. */ - public void characters (char ch[], int start, int length) - throws SAXException { - return; - } - - /** The SAX ignorableWhitespace method does nothing. */ - public void ignorableWhitespace (char ch[], int start, int length) - throws SAXException { - return; - } - - /** The SAX processingInstruction method does nothing. */ - public void processingInstruction (String target, String data) - throws SAXException { - return; - } - - /** The SAX skippedEntity method does nothing. */ - public void skippedEntity (String name) - throws SAXException { - return; - } - - /** The SAX startPrefixMapping method does nothing. */ - public void startPrefixMapping(String prefix, String uri) - throws SAXException { - return; - } - - /** The SAX endPrefixMapping method does nothing. */ - public void endPrefixMapping(String prefix) - throws SAXException { - return; - } - -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java deleted file mode 100644 index 10e49e7f247..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/CatalogResolver.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.tools; - -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.MalformedURLException; - -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.InputSource; -import org.xml.sax.EntityResolver; - -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.Source; -import javax.xml.transform.URIResolver; -import javax.xml.transform.TransformerException; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogManager; -import com.sun.org.apache.xml.internal.resolver.helpers.FileURL; - -/** - * A SAX EntityResolver/JAXP URIResolver that uses catalogs. - * - *

    This class implements both a SAX EntityResolver and a JAXP URIResolver. - *

    - * - *

    This resolver understands OASIS TR9401 catalogs, XCatalogs, and the - * current working draft of the OASIS Entity Resolution Technical - * Committee specification.

    - * - * @see Catalog - * @see org.xml.sax.EntityResolver - * @see javax.xml.transform.URIResolver - * @deprecated The JDK internal Catalog API in package - * {@code com.sun.org.apache.xml.internal.resolver} - * is encapsulated in JDK 9. The entire implementation under the package is now - * deprecated and subject to removal in a future release. Users of the API - * should migrate to the {@linkplain javax.xml.catalog new public API}. - *

    - * The new Catalog API is supported throughout the JDK XML Processors, which allows - * the use of Catalog by simply setting a path to a Catalog file as a property. - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -@Deprecated(since="9", forRemoval=true) -public class CatalogResolver implements EntityResolver, URIResolver { - /** Make the parser Namespace aware? */ - public boolean namespaceAware = true; - - /** Make the parser validating? */ - public boolean validating = false; - - /** The underlying catalog */ - private Catalog catalog = null; - - /** The catalog manager */ - private CatalogManager catalogManager = CatalogManager.getStaticManager(); - - /** Constructor */ - public CatalogResolver() { - initializeCatalogs(false); - } - - /** Constructor */ - public CatalogResolver(boolean privateCatalog) { - initializeCatalogs(privateCatalog); - } - - /** Constructor */ - public CatalogResolver(CatalogManager manager) { - catalogManager = manager; - initializeCatalogs(!catalogManager.getUseStaticCatalog()); - } - - /** Initialize catalog */ - private void initializeCatalogs(boolean privateCatalog) { - catalog = catalogManager.getCatalog(); - } - - /** Return the underlying catalog */ - public Catalog getCatalog() { - return catalog; - } - - /** - * Implements the guts of the resolveEntity method - * for the SAX interface. - * - *

    Presented with an optional public identifier and a system - * identifier, this function attempts to locate a mapping in the - * catalogs.

    - * - *

    If such a mapping is found, it is returned. If no mapping is - * found, null is returned.

    - * - * @param publicId The public identifier for the entity in question. - * This may be null. - * - * @param systemId The system identifier for the entity in question. - * XML requires a system identifier on all external entities, so this - * value is always specified. - * - * @return The resolved identifier (a URI reference). - */ - public String getResolvedEntity (String publicId, String systemId) { - String resolved = null; - - if (catalog == null) { - catalogManager.debug.message(1, "Catalog resolution attempted with null catalog; ignored"); - return null; - } - - if (systemId != null) { - try { - resolved = catalog.resolveSystem(systemId); - } catch (MalformedURLException me) { - catalogManager.debug.message(1, "Malformed URL exception trying to resolve", - publicId); - resolved = null; - } catch (IOException ie) { - catalogManager.debug.message(1, "I/O exception trying to resolve", publicId); - resolved = null; - } - } - - if (resolved == null) { - if (publicId != null) { - try { - resolved = catalog.resolvePublic(publicId, systemId); - } catch (MalformedURLException me) { - catalogManager.debug.message(1, "Malformed URL exception trying to resolve", - publicId); - } catch (IOException ie) { - catalogManager.debug.message(1, "I/O exception trying to resolve", publicId); - } - } - - if (resolved != null) { - catalogManager.debug.message(2, "Resolved public", publicId, resolved); - } - } else { - catalogManager.debug.message(2, "Resolved system", systemId, resolved); - } - - return resolved; - } - - /** - * Implements the resolveEntity method - * for the SAX interface. - * - *

    Presented with an optional public identifier and a system - * identifier, this function attempts to locate a mapping in the - * catalogs.

    - * - *

    If such a mapping is found, the resolver attempts to open - * the mapped value as an InputSource and return it. Exceptions are - * ignored and null is returned if the mapped value cannot be opened - * as an input source.

    - * - *

    If no mapping is found (or an error occurs attempting to open - * the mapped value as an input source), null is returned and the system - * will use the specified system identifier as if no entityResolver - * was specified.

    - * - * @param publicId The public identifier for the entity in question. - * This may be null. - * - * @param systemId The system identifier for the entity in question. - * XML requires a system identifier on all external entities, so this - * value is always specified. - * - * @return An InputSource for the mapped identifier, or null. - */ - public InputSource resolveEntity (String publicId, String systemId) { - String resolved = getResolvedEntity(publicId, systemId); - - if (resolved != null) { - try { - InputSource iSource = new InputSource(resolved); - iSource.setPublicId(publicId); - - // Ideally this method would not attempt to open the - // InputStream, but there is a bug (in Xerces, at least) - // that causes the parser to mistakenly open the wrong - // system identifier if the returned InputSource does - // not have a byteStream. - // - // It could be argued that we still shouldn't do this here, - // but since the purpose of calling the entityResolver is - // almost certainly to open the input stream, it seems to - // do little harm. - // - URL url = new URL(resolved); - InputStream iStream = url.openStream(); - iSource.setByteStream(iStream); - - return iSource; - } catch (Exception e) { - catalogManager.debug.message(1, - "Failed to create InputSource (" - + e.toString() - + ")", resolved); - return null; - } - } - - return null; - } - - /** JAXP URIResolver API */ - public Source resolve(String href, String base) - throws TransformerException { - - String uri = href; - String fragment = null; - int hashPos = href.indexOf("#"); - if (hashPos >= 0) { - uri = href.substring(0, hashPos); - fragment = href.substring(hashPos+1); - } - - String result = null; - - try { - result = catalog.resolveURI(href); - } catch (Exception e) { - // nop; - } - - if (result == null) { - try { - URL url = null; - - if (base==null) { - url = new URL(uri); - result = url.toString(); - } else { - URL baseURL = new URL(base); - url = (href.length()==0 ? baseURL : new URL(baseURL, uri)); - result = url.toString(); - } - } catch (java.net.MalformedURLException mue) { - // try to make an absolute URI from the current base - String absBase = makeAbsolute(base); - if (!absBase.equals(base)) { - // don't bother if the absBase isn't different! - return resolve(href, absBase); - } else { - throw new TransformerException("Malformed URL " - + href + "(base " + base + ")", - mue); - } - } - } - - catalogManager.debug.message(2, "Resolved URI", href, result); - - SAXSource source = new SAXSource(); - source.setInputSource(new InputSource(result)); - setEntityResolver(source); - return source; - } - - /** - *

    Establish an entityResolver for newly resolved URIs.

    - * - *

    This is called from the URIResolver to set an EntityResolver - * on the SAX parser to be used for new XML documents that are - * encountered as a result of the document() function, xsl:import, - * or xsl:include. This is done because the XSLT processor calls - * out to the SAXParserFactory itself to create a new SAXParser to - * parse the new document. The new parser does not automatically - * inherit the EntityResolver of the original (although arguably - * it should). See below:

    - * - * "If an application wants to set the ErrorHandler or - * EntityResolver for an XMLReader used during a transformation, - * it should use a URIResolver to return the SAXSource which - * provides (with getXMLReader) a reference to the XMLReader" - * - *

    ...quoted from page 118 of the Java API for XML - * Processing 1.1 specification

    - * - */ - private void setEntityResolver(SAXSource source) throws TransformerException { - XMLReader reader = source.getXMLReader(); - if (reader == null) { - SAXParserFactory spFactory = catalogManager.useServicesMechanism() ? - SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); - spFactory.setNamespaceAware(true); - try { - reader = spFactory.newSAXParser().getXMLReader(); - } - catch (ParserConfigurationException ex) { - throw new TransformerException(ex); - } - catch (SAXException ex) { - throw new TransformerException(ex); - } - } - reader.setEntityResolver(this); - source.setXMLReader(reader); - } - - /** Attempt to construct an absolute URI */ - private String makeAbsolute(String uri) { - if (uri == null) { - uri = ""; - } - - try { - URL url = new URL(uri); - return url.toString(); - } catch (MalformedURLException mue) { - try { - URL fileURL = FileURL.makeURL(uri); - return fileURL.toString(); - } catch (MalformedURLException mue2) { - // bail - return uri; - } - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingParser.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingParser.java deleted file mode 100644 index 354ac1e60c0..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingParser.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.tools; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.Locale; - -import org.xml.sax.Parser; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.ErrorHandler; -import org.xml.sax.DTDHandler; -import org.xml.sax.DocumentHandler; -import org.xml.sax.AttributeList; -import org.xml.sax.EntityResolver; -import org.xml.sax.SAXException; - -import javax.xml.parsers.SAXParserFactory; -import javax.xml.parsers.SAXParser; - -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogManager; -import com.sun.org.apache.xml.internal.resolver.helpers.FileURL; - -/** - * A SAX Parser that performs catalog-based entity resolution. - * - *

    This class implements a SAX Parser that performs entity resolution - * using the CatalogResolver. The actual, underlying parser is obtained - * from a SAXParserFactory.

    - *

    - * - * @deprecated This interface has been replaced by the - * {@link com.sun.org.apache.xml.internal.resolver.tools.ResolvingXMLReader} for SAX2. - * @see CatalogResolver - * @see org.xml.sax.Parser - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -public class ResolvingParser - implements Parser, DTDHandler, DocumentHandler, EntityResolver { - - /** Suppress explanatory message? - * - * @see #parse(InputSource) - */ - private static final boolean suppressExplanation = false; - - /** The underlying parser. */ - private SAXParser saxParser = null; - - /** The underlying reader. */ - private Parser parser = null; - - /** The underlying DocumentHandler. */ - private DocumentHandler documentHandler = null; - - /** The underlying DTDHandler. */ - private DTDHandler dtdHandler = null; - - /** The manager for the underlying resolver. */ - private CatalogManager catalogManager = CatalogManager.getStaticManager(); - - /** The underlying catalog resolver. */ - private CatalogResolver catalogResolver = null; - - /** A separate resolver for oasis-xml-pi catalogs. */ - private CatalogResolver piCatalogResolver = null; - - /** Are we in the prolog? Is an oasis-xml-catalog PI valid now? */ - private boolean allowXMLCatalogPI = false; - - /** The base URI of the input document, if known. */ - private URL baseURL = null; - - /** Constructor. */ - public ResolvingParser() { - initParser(); - } - - /** Constructor. */ - public ResolvingParser(CatalogManager manager) { - catalogManager = manager; - initParser(); - } - - /** Initialize the parser. */ - private void initParser() { - catalogResolver = new CatalogResolver(catalogManager); - SAXParserFactory spf = catalogManager.useServicesMechanism() ? - SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); - spf.setNamespaceAware(true); - spf.setValidating(false); - - try { - saxParser = spf.newSAXParser(); - parser = saxParser.getParser(); - documentHandler = null; - dtdHandler = null; - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - /** Return the Catalog being used. */ - public Catalog getCatalog() { - return catalogResolver.getCatalog(); - } - - /** - * SAX Parser API. - * - *

    Note that the JAXP 1.1ea2 parser crashes with an InternalError if - * it encounters a system identifier that appears to be a relative URI - * that begins with a slash. For example, the declaration:

    - * - *
    -   * <!DOCTYPE book SYSTEM "/path/to/dtd/on/my/system/docbookx.dtd">
    -   * 
    - * - *

    would cause such an error. As a convenience, this method catches - * that error and prints an explanation. (Unfortunately, it's not possible - * to identify the particular system identifier that causes the problem.) - *

    - * - *

    The underlying error is forwarded after printing the explanatory - * message. The message is only every printed once and if - * suppressExplanation is set to false before - * parsing, it will never be printed.

    - */ - public void parse(InputSource input) - throws IOException, - SAXException { - setupParse(input.getSystemId()); - try { - parser.parse(input); - } catch (InternalError ie) { - explain(input.getSystemId()); - throw ie; - } - } - - /** SAX Parser API. - * - * @see #parse(InputSource) - */ - public void parse(String systemId) - throws IOException, - SAXException { - setupParse(systemId); - try { - parser.parse(systemId); - } catch (InternalError ie) { - explain(systemId); - throw ie; - } - } - - /** SAX Parser API. */ - public void setDocumentHandler(DocumentHandler handler) { - documentHandler = handler; - } - - /** SAX Parser API. */ - public void setDTDHandler(DTDHandler handler) { - dtdHandler = handler; - } - - /** - * SAX Parser API. - * - *

    The purpose of this class is to implement an entity resolver. - * Attempting to set a different one is pointless (and ignored).

    - */ - public void setEntityResolver(EntityResolver resolver) { - // nop - } - - /** SAX Parser API. */ - public void setErrorHandler(ErrorHandler handler) { - parser.setErrorHandler(handler); - } - - /** SAX Parser API. */ - public void setLocale(Locale locale) throws SAXException { - parser.setLocale(locale); - } - - /** SAX DocumentHandler API. */ - public void characters(char[] ch, int start, int length) - throws SAXException { - if (documentHandler != null) { - documentHandler.characters(ch,start,length); - } - } - - /** SAX DocumentHandler API. */ - public void endDocument() throws SAXException { - if (documentHandler != null) { - documentHandler.endDocument(); - } - } - - /** SAX DocumentHandler API. */ - public void endElement(String name) throws SAXException { - if (documentHandler != null) { - documentHandler.endElement(name); - } - } - - /** SAX DocumentHandler API. */ - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException { - if (documentHandler != null) { - documentHandler.ignorableWhitespace(ch,start,length); - } - } - - /** SAX DocumentHandler API. */ - public void processingInstruction(String target, String pidata) - throws SAXException { - - if (target.equals("oasis-xml-catalog")) { - URL catalog = null; - String data = pidata; - - int pos = data.indexOf("catalog="); - if (pos >= 0) { - data = data.substring(pos+8); - if (data.length() > 1) { - String quote = data.substring(0,1); - data = data.substring(1); - pos = data.indexOf(quote); - if (pos >= 0) { - data = data.substring(0, pos); - try { - if (baseURL != null) { - catalog = new URL(baseURL, data); - } else { - catalog = new URL(data); - } - } catch (MalformedURLException mue) { - // nevermind - } - } - } - } - - if (allowXMLCatalogPI) { - if (catalogManager.getAllowOasisXMLCatalogPI()) { - catalogManager.debug.message(4,"oasis-xml-catalog PI", pidata); - - if (catalog != null) { - try { - catalogManager.debug.message(4,"oasis-xml-catalog", catalog.toString()); - - if (piCatalogResolver == null) { - piCatalogResolver = new CatalogResolver(true); - } - - piCatalogResolver.getCatalog().parseCatalog(catalog.toString()); - } catch (Exception e) { - catalogManager.debug.message(3, "Exception parsing oasis-xml-catalog: " - + catalog.toString()); - } - } else { - catalogManager.debug.message(3, "PI oasis-xml-catalog unparseable: " + pidata); - } - } else { - catalogManager.debug.message(4,"PI oasis-xml-catalog ignored: " + pidata); - } - } else { - catalogManager.debug.message(3, "PI oasis-xml-catalog occurred in an invalid place: " - + pidata); - } - } else { - if (documentHandler != null) { - documentHandler.processingInstruction(target, pidata); - } - } - } - - /** SAX DocumentHandler API. */ - public void setDocumentLocator(Locator locator) { - if (documentHandler != null) { - documentHandler.setDocumentLocator(locator); - } - } - - /** SAX DocumentHandler API. */ - public void startDocument() throws SAXException { - if (documentHandler != null) { - documentHandler.startDocument(); - } - } - - /** SAX DocumentHandler API. */ - public void startElement(String name, AttributeList atts) - throws SAXException { - allowXMLCatalogPI = false; - if (documentHandler != null) { - documentHandler.startElement(name,atts); - } - } - - /** SAX DTDHandler API. */ - public void notationDecl (String name, String publicId, String systemId) - throws SAXException { - allowXMLCatalogPI = false; - if (dtdHandler != null) { - dtdHandler.notationDecl(name,publicId,systemId); - } - } - - /** SAX DTDHandler API. */ - public void unparsedEntityDecl (String name, - String publicId, - String systemId, - String notationName) - throws SAXException { - allowXMLCatalogPI = false; - if (dtdHandler != null) { - dtdHandler.unparsedEntityDecl (name, publicId, systemId, notationName); - } - } - - /** - * Implements the resolveEntity method - * for the SAX interface, using an underlying CatalogResolver - * to do the real work. - */ - public InputSource resolveEntity (String publicId, String systemId) { - allowXMLCatalogPI = false; - String resolved = catalogResolver.getResolvedEntity(publicId, systemId); - - if (resolved == null && piCatalogResolver != null) { - resolved = piCatalogResolver.getResolvedEntity(publicId, systemId); - } - - if (resolved != null) { - try { - InputSource iSource = new InputSource(resolved); - iSource.setPublicId(publicId); - - // Ideally this method would not attempt to open the - // InputStream, but there is a bug (in Xerces, at least) - // that causes the parser to mistakenly open the wrong - // system identifier if the returned InputSource does - // not have a byteStream. - // - // It could be argued that we still shouldn't do this here, - // but since the purpose of calling the entityResolver is - // almost certainly to open the input stream, it seems to - // do little harm. - // - URL url = new URL(resolved); - InputStream iStream = url.openStream(); - iSource.setByteStream(iStream); - - return iSource; - } catch (Exception e) { - catalogManager.debug.message(1, - "Failed to create InputSource (" - + e.toString() - + ")", resolved); - return null; - } - } else { - return null; - } - } - - /** Setup for parsing. */ - private void setupParse(String systemId) { - allowXMLCatalogPI = true; - parser.setEntityResolver(this); - parser.setDocumentHandler(this); - parser.setDTDHandler(this); - - URL cwd = null; - - try { - cwd = FileURL.makeURL("basename"); - } catch (MalformedURLException mue) { - cwd = null; - } - - try { - baseURL = new URL(systemId); - } catch (MalformedURLException mue) { - if (cwd != null) { - try { - baseURL = new URL(cwd, systemId); - } catch (MalformedURLException mue2) { - // give up - baseURL = null; - } - } else { - // give up - baseURL = null; - } - } - } - - /** Provide one possible explanation for an InternalError. */ - private void explain(String systemId) { - if (!suppressExplanation) { - System.out.println("Parser probably encountered bad URI in " + systemId); - System.out.println("For example, replace '/some/uri' with 'file:/some/uri'."); - } - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLFilter.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLFilter.java deleted file mode 100644 index f196e3726fe..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLFilter.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.tools; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.Attributes; -import org.xml.sax.helpers.XMLFilterImpl; - -import com.sun.org.apache.xml.internal.resolver.Catalog; -import com.sun.org.apache.xml.internal.resolver.CatalogManager; - -import com.sun.org.apache.xml.internal.resolver.helpers.FileURL; - -/** - * A SAX XMLFilter that performs catalog-based entity resolution. - * - *

    This class implements a SAX XMLFilter that performs entity resolution - * using the CatalogResolver. The actual, underlying parser is obtained - * from a SAXParserFactory.

    - *

    - * - * @see CatalogResolver - * @see org.xml.sax.XMLFilter - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -public class ResolvingXMLFilter extends XMLFilterImpl { - /** - * Suppress explanatory message? - * - * @see #parse(InputSource) - */ - private static boolean suppressExplanation = false; - - /** The manager for the underlying resolver. */ - CatalogManager catalogManager = CatalogManager.getStaticManager(); - - /** The underlying catalog resolver. */ - private CatalogResolver catalogResolver = null; - - /** A separate resolver for oasis-xml-pi catalogs. */ - private CatalogResolver piCatalogResolver = null; - - /** Are we in the prolog? Is an oasis-xml-catalog PI valid now? */ - private boolean allowXMLCatalogPI = false; - - /** The base URI of the input document, if known. */ - private URL baseURL = null; - - /** Construct an empty XML Filter with no parent. */ - public ResolvingXMLFilter() { - super(); - catalogResolver = new CatalogResolver(catalogManager); - } - - /** Construct an XML filter with the specified parent. */ - public ResolvingXMLFilter(XMLReader parent) { - super(parent); - catalogResolver = new CatalogResolver(catalogManager); - } - - /** Construct an XML filter with the specified parent. */ - public ResolvingXMLFilter(CatalogManager manager) { - super(); - catalogManager = manager; - catalogResolver = new CatalogResolver(catalogManager); - } - - /** Construct an XML filter with the specified parent. */ - public ResolvingXMLFilter(XMLReader parent, CatalogManager manager) { - super(parent); - catalogManager = manager; - catalogResolver = new CatalogResolver(catalogManager); - } - - /** - * Provide accessto the underlying Catalog. - */ - public Catalog getCatalog() { - return catalogResolver.getCatalog(); - } - - /** - * SAX XMLReader API. - * - *

    Note that the JAXP 1.1ea2 parser crashes with an InternalError if - * it encounters a system identifier that appears to be a relative URI - * that begins with a slash. For example, the declaration:

    - * - *
    -   * <!DOCTYPE book SYSTEM "/path/to/dtd/on/my/system/docbookx.dtd">
    -   * 
    - * - *

    would cause such an error. As a convenience, this method catches - * that error and prints an explanation. (Unfortunately, it's not possible - * to identify the particular system identifier that causes the problem.) - *

    - * - *

    The underlying error is forwarded after printing the explanatory - * message. The message is only every printed once and if - * suppressExplanation is set to false before - * parsing, it will never be printed.

    - */ - public void parse(InputSource input) - throws IOException, SAXException { - allowXMLCatalogPI = true; - - setupBaseURI(input.getSystemId()); - - try { - super.parse(input); - } catch (InternalError ie) { - explain(input.getSystemId()); - throw ie; - } - } - - /** SAX XMLReader API. - * - * @see #parse(InputSource) - */ - public void parse(String systemId) - throws IOException, SAXException { - allowXMLCatalogPI = true; - - setupBaseURI(systemId); - - try { - super.parse(systemId); - } catch (InternalError ie) { - explain(systemId); - throw ie; - } - } - - /** - * Implements the resolveEntity method - * for the SAX interface, using an underlying CatalogResolver - * to do the real work. - */ - public InputSource resolveEntity (String publicId, String systemId) { - allowXMLCatalogPI = false; - String resolved = catalogResolver.getResolvedEntity(publicId, systemId); - - if (resolved == null && piCatalogResolver != null) { - resolved = piCatalogResolver.getResolvedEntity(publicId, systemId); - } - - if (resolved != null) { - try { - InputSource iSource = new InputSource(resolved); - iSource.setPublicId(publicId); - - // Ideally this method would not attempt to open the - // InputStream, but there is a bug (in Xerces, at least) - // that causes the parser to mistakenly open the wrong - // system identifier if the returned InputSource does - // not have a byteStream. - // - // It could be argued that we still shouldn't do this here, - // but since the purpose of calling the entityResolver is - // almost certainly to open the input stream, it seems to - // do little harm. - // - URL url = new URL(resolved); - InputStream iStream = url.openStream(); - iSource.setByteStream(iStream); - - return iSource; - } catch (Exception e) { - catalogManager.debug.message(1, - "Failed to create InputSource (" - + e.toString() - + ")", resolved); - return null; - } - } else { - return null; - } - } - - /** SAX DTDHandler API. - * - *

    Captured here only to detect the end of the prolog so that - * we can ignore subsequent oasis-xml-catalog PIs. Otherwise - * the events are just passed through.

    - */ - public void notationDecl (String name, String publicId, String systemId) - throws SAXException { - allowXMLCatalogPI = false; - super.notationDecl(name,publicId,systemId); - } - - /** SAX DTDHandler API. - * - *

    Captured here only to detect the end of the prolog so that - * we can ignore subsequent oasis-xml-catalog PIs. Otherwise - * the events are just passed through.

    - */ - public void unparsedEntityDecl (String name, - String publicId, - String systemId, - String notationName) - throws SAXException { - allowXMLCatalogPI = false; - super.unparsedEntityDecl (name, publicId, systemId, notationName); - } - - /** SAX ContentHandler API. - * - *

    Captured here only to detect the end of the prolog so that - * we can ignore subsequent oasis-xml-catalog PIs. Otherwise - * the events are just passed through.

    - */ - public void startElement (String uri, String localName, String qName, - Attributes atts) - throws SAXException { - allowXMLCatalogPI = false; - super.startElement(uri,localName,qName,atts); - } - - /** SAX ContentHandler API. - * - *

    Detect and use the oasis-xml-catalog PI if it occurs.

    - */ - public void processingInstruction(String target, String pidata) - throws SAXException { - if (target.equals("oasis-xml-catalog")) { - URL catalog = null; - String data = pidata; - - int pos = data.indexOf("catalog="); - if (pos >= 0) { - data = data.substring(pos+8); - if (data.length() > 1) { - String quote = data.substring(0,1); - data = data.substring(1); - pos = data.indexOf(quote); - if (pos >= 0) { - data = data.substring(0, pos); - try { - if (baseURL != null) { - catalog = new URL(baseURL, data); - } else { - catalog = new URL(data); - } - } catch (MalformedURLException mue) { - // nevermind - } - } - } - } - - if (allowXMLCatalogPI) { - if (catalogManager.getAllowOasisXMLCatalogPI()) { - catalogManager.debug.message(4,"oasis-xml-catalog PI", pidata); - - if (catalog != null) { - try { - catalogManager.debug.message(4,"oasis-xml-catalog", catalog.toString()); - - if (piCatalogResolver == null) { - piCatalogResolver = new CatalogResolver(true); - } - - piCatalogResolver.getCatalog().parseCatalog(catalog.toString()); - } catch (Exception e) { - catalogManager.debug.message(3, "Exception parsing oasis-xml-catalog: " - + catalog.toString()); - } - } else { - catalogManager.debug.message(3, "PI oasis-xml-catalog unparseable: " + pidata); - } - } else { - catalogManager.debug.message(4,"PI oasis-xml-catalog ignored: " + pidata); - } - } else { - catalogManager.debug.message(3, "PI oasis-xml-catalog occurred in an invalid place: " - + pidata); - } - } else { - super.processingInstruction(target, pidata); - } - } - - /** Save the base URI of the document being parsed. */ - private void setupBaseURI(String systemId) { - URL cwd = null; - - try { - cwd = FileURL.makeURL("basename"); - } catch (MalformedURLException mue) { - cwd = null; - } - - try { - baseURL = new URL(systemId); - } catch (MalformedURLException mue) { - if (cwd != null) { - try { - baseURL = new URL(cwd, systemId); - } catch (MalformedURLException mue2) { - // give up - baseURL = null; - } - } else { - // give up - baseURL = null; - } - } - } - - /** Provide one possible explanation for an InternalError. */ - private void explain(String systemId) { - if (!suppressExplanation) { - System.out.println("XMLReader probably encountered bad URI in " + systemId); - System.out.println("For example, replace '/some/uri' with 'file:/some/uri'."); - } - suppressExplanation = true; - } -} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLReader.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLReader.java deleted file mode 100644 index ad9bd7c6e19..00000000000 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/tools/ResolvingXMLReader.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.sun.org.apache.xml.internal.resolver.tools; - - -import javax.xml.parsers.*; - -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; -import com.sun.org.apache.xml.internal.resolver.*; - -/** - * A SAX XMLReader that performs catalog-based entity resolution. - * - *

    This class implements a SAX XMLReader that performs entity resolution - * using the CatalogResolver. The actual, underlying parser is obtained - * from a SAXParserFactory.

    - *

    - * - * @see CatalogResolver - * @see org.xml.sax.XMLReader - * - * @author Norman Walsh - * Norman.Walsh@Sun.COM - * - * @version 1.0 - */ -public class ResolvingXMLReader extends ResolvingXMLFilter { - /** Make the parser Namespace aware? */ - private static final boolean namespaceAware = true; - - /** Make the parser validating? */ - private static final boolean validating = false; - - /** - * Construct a new reader from the JAXP factory. - * - *

    In order to do its job, a ResolvingXMLReader must in fact be - * a filter. So the only difference between this code and the filter - * code is that the constructor builds a new reader.

    - */ - public ResolvingXMLReader() { - super(); - SAXParserFactory spf = catalogManager.useServicesMechanism() ? - SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); - spf.setNamespaceAware(namespaceAware); - spf.setValidating(validating); - try { - SAXParser parser = spf.newSAXParser(); - setParent(parser.getXMLReader()); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - /** - * Construct a new reader from the JAXP factory. - * - *

    In order to do its job, a ResolvingXMLReader must in fact be - * a filter. So the only difference between this code and the filter - * code is that the constructor builds a new reader.

    - */ - public ResolvingXMLReader(CatalogManager manager) { - super(manager); - SAXParserFactory spf = catalogManager.useServicesMechanism() ? - SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); - spf.setNamespaceAware(namespaceAware); - spf.setValidating(validating); - try { - SAXParser parser = spf.newSAXParser(); - setParent(parser.getXMLReader()); - } catch (Exception ex) { - ex.printStackTrace(); - } - } -} From 455b23176895d01b3f9a2e93b11e6f5ed4532ec7 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 21 Jun 2017 10:30:03 +0800 Subject: [PATCH 55/59] 8182376: Refactor shell test java/nio/file/Path/MacPathTest.sh to java Reviewed-by: alanb --- jdk/test/java/nio/file/Path/MacPath.java | 169 +++++++++++++++++++ jdk/test/java/nio/file/Path/MacPathTest.java | 164 +++--------------- jdk/test/java/nio/file/Path/MacPathTest.sh | 39 ----- 3 files changed, 188 insertions(+), 184 deletions(-) create mode 100644 jdk/test/java/nio/file/Path/MacPath.java delete mode 100644 jdk/test/java/nio/file/Path/MacPathTest.sh diff --git a/jdk/test/java/nio/file/Path/MacPath.java b/jdk/test/java/nio/file/Path/MacPath.java new file mode 100644 index 00000000000..344131e1897 --- /dev/null +++ b/jdk/test/java/nio/file/Path/MacPath.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.PosixFilePermission; +import java.text.Normalizer; +import java.util.Set; +import java.util.regex.Pattern; + +public class MacPath { + + public static void main(String args[]) throws Throwable { + System.out.printf("sun.jnu.encoding=%s, file.encoding=%s%n", + System.getProperty("file.encoding"), + System.getProperty("sun.jnu.encoding")); + // English + test("TestDir_apple", // test dir + "dir_macosx", // dir + "file_macosx"); // file + + // Japanese composite character + test("TestDir_\u30c8\u30a4\u30e4\u30cb\u30ca\u30eb/", + "dir_\u30a4\u30c1\u30b4\u306e\u30b1\u30fc\u30ad", + "file_\u30a4\u30c1\u30b4\u306e\u30b1\u30fc\u30ad"); + + // latin-1 supplementory + test("TestDir_K\u00f6rperlich\u00e4\u00df/", + "dir_Entt\u00e4uschung", + "file_Entt\u00e4uschung"); + + test("TestDir_K\u00f6rperlich\u00e4\u00df/", + "dir_Entt\u00c4uschung", + "file_Entt\u00c4uschung"); + + // Korean syblla + test("TestDir_\uac00\uac01\uac02", + "dir_\uac20\uac21\uac22", + "file_\uacc0\uacc1\uacc2"); + } + + private static boolean equal(Object x, Object y) { + return x == null ? y == null : x.equals(y); + } + + private static boolean match(Path target, Path src) { + String fname = target.toString(); + System.out.printf(" --> Trying [%s], length=%d...", fname, fname.length()); + if (target.equals(src)) { + System.out.println(" MATCHED!"); + return true; + } else { + System.out.println(" NOT MATCHED!"); + } + return false; + } + + private static void test(String testdir, String dname, String fname_nfc) + throws Throwable + { + String fname = null; + String dname_nfd = Normalizer.normalize(dname, Normalizer.Form.NFD); + String fname_nfd = Normalizer.normalize(fname_nfc, Normalizer.Form.NFD); + + System.out.printf("%n%n--------Testing...----------%n"); + Path bpath = Paths.get(testdir); + Path dpath = Paths.get(testdir, dname); + Path dpath_nfd = Paths.get(testdir, dname_nfd); + Path fpath_nfc = Paths.get(testdir, fname_nfc); + Path fpath_nfd = Paths.get(testdir, fname_nfd); + + if (Files.exists(bpath)) + TestUtil.removeAll(bpath); + Files.createDirectories(dpath); + + fname = dpath.toString(); + System.out.printf(":Directory [%s][len=%d] created%n", fname, fname.length()); + + ////////////////////////////////////////////////////////////// + if (!Files.isDirectory(dpath) || !Files.isDirectory(dpath_nfd)) { + throw new RuntimeException("Files.isDirectory(...) failed"); + } + + ////////////////////////////////////////////////////////////// + // write out with nfd, read in with nfc + case + Files.write(fpath_nfd, new byte[] { 'n', 'f', 'd'}); + System.out.println(" read in with nfc (from nfd):" + new String(Files.readAllBytes(fpath_nfc))); + + // check attrs with nfc + case + Set pfp = Files.getPosixFilePermissions(fpath_nfd); + if (!equal(pfp, Files.getPosixFilePermissions(fpath_nfc)) ) { + throw new RuntimeException("Files.getPosixfilePermission(...) failed"); + } + Files.delete(fpath_nfd); + + // write out with nfc, read in with nfd + case + Files.write(fpath_nfc, new byte[] { 'n', 'f', 'c'}); + System.out.println(" read in with nfd (from nfc):" + new String(Files.readAllBytes(fpath_nfd))); + + // check attrs with nfc + case + pfp = Files.getPosixFilePermissions(fpath_nfc); + if (!equal(pfp, Files.getPosixFilePermissions(fpath_nfd))) { + throw new RuntimeException("Files.getPosixfilePermission(...) failed"); + } + ////////////////////////////////////////////////////////////// + boolean found_dir = false; + boolean found_file_nfc = false; + boolean found_file_nfd = false; + try (DirectoryStream stream = Files.newDirectoryStream(bpath)) { + for (Path path: stream) { + fname = path.toString(); + System.out.printf("Found : [%s], length=%d%n", fname, fname.length()); + found_dir |= match(dpath, path); + found_file_nfc |= match(fpath_nfc, path); + found_file_nfd |= match(fpath_nfd, path); + } + } + if (!found_dir || !found_file_nfc || !found_file_nfd) { + throw new RuntimeException("File.equal() failed"); + } + // glob + String glob = "*" + fname_nfd.substring(2); // remove leading "FI" from "FILE..." + System.out.println("glob=" + glob); + boolean globmatched = false; + try (DirectoryStream stream = Files.newDirectoryStream(bpath, glob)) { + for (Path path: stream) { + fname = path.toString(); + System.out.printf("PathMatch : [%s], length=%d%n", fname, fname.length()); + globmatched |= match(fpath_nfc, path); + } + } + if (!globmatched) { + //throw new RuntimeException("path matcher failed"); + // it appears we have a regex.anon_eq bug in hangul syllable handling + System.out.printf("pathmatcher failed, glob=[%s]%n", glob); + System.out.printf(" -> fname_nfd.matches(fname_nfc)=%b%n", + Pattern.compile(fname_nfd, Pattern.CANON_EQ) + .matcher(fname_nfc) + .matches()); + System.out.printf(" -> fname_nfc.matches(fname_nfd)=%b%n", + Pattern.compile(fname_nfc, Pattern.CANON_EQ) + .matcher(fname_nfd) + .matches()); + } + TestUtil.removeAll(bpath); + } +} diff --git a/jdk/test/java/nio/file/Path/MacPathTest.java b/jdk/test/java/nio/file/Path/MacPathTest.java index 3bfa14a682c..00d5eddc045 100644 --- a/jdk/test/java/nio/file/Path/MacPathTest.java +++ b/jdk/test/java/nio/file/Path/MacPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,154 +24,28 @@ /* @test * @bug 7130915 * @summary Tests file path with nfc/nfd forms on MacOSX - * @library ../ - * @build MacPathTest - * @run shell MacPathTest.sh + * @requires (os.family == "mac") + * @library /test/lib .. + * @build jdk.test.lib.Utils + * jdk.test.lib.Asserts + * jdk.test.lib.JDKToolFinder + * jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Platform + * jdk.test.lib.process.* + * TestUtil MacPath + * @run main MacPathTest */ -import java.nio.file.*; -import java.nio.file.attribute.*; -import java.text.*; -import java.util.*; -import java.util.regex.*; +import jdk.test.lib.process.ProcessTools; public class MacPathTest { - public static void main(String args[]) throws Throwable { - String osname = System.getProperty("os.name"); - if (!osname.contains("OS X") && !osname.contains("Darwin")) - return; - System.out.printf("sun.jnu.encoding=%s, file.encoding=%s%n", - System.getProperty("file.encoding"), - System.getProperty("sun.jnu.encoding")); - // English - test("TestDir_apple", // test dir - "dir_macosx", // dir - "file_macosx"); // file - - // Japanese composite character - test("TestDir_\u30c8\u30a4\u30e4\u30cb\u30ca\u30eb/", - "dir_\u30a4\u30c1\u30b4\u306e\u30b1\u30fc\u30ad", - "file_\u30a4\u30c1\u30b4\u306e\u30b1\u30fc\u30ad"); - - // latin-1 supplementory - test("TestDir_K\u00f6rperlich\u00e4\u00df/", - "dir_Entt\u00e4uschung", - "file_Entt\u00e4uschung"); - - test("TestDir_K\u00f6rperlich\u00e4\u00df/", - "dir_Entt\u00c4uschung", - "file_Entt\u00c4uschung"); - - // Korean syblla - test("TestDir_\uac00\uac01\uac02", - "dir_\uac20\uac21\uac22", - "file_\uacc0\uacc1\uacc2"); - } - - private static boolean equal(Object x, Object y) { - return x == null ? y == null : x.equals(y); - } - - private static boolean match(Path target, Path src) { - String fname = target.toString(); - System.out.printf(" --> Trying [%s], length=%d...", fname, fname.length()); - if (target.equals(src)) { - System.out.println(" MATCHED!"); - return true; - } else { - System.out.println(" NOT MATCHED!"); - } - return false; - } - - private static void test(String testdir, String dname, String fname_nfc) - throws Throwable - { - String fname = null; - String dname_nfd = Normalizer.normalize(dname, Normalizer.Form.NFD); - String fname_nfd = Normalizer.normalize(fname_nfc, Normalizer.Form.NFD); - - System.out.printf("%n%n--------Testing...----------%n"); - Path bpath = Paths.get(testdir); - Path dpath = Paths.get(testdir, dname); - Path dpath_nfd = Paths.get(testdir, dname_nfd); - Path fpath_nfc = Paths.get(testdir, fname_nfc); - Path fpath_nfd = Paths.get(testdir, fname_nfd); - - if (Files.exists(bpath)) - TestUtil.removeAll(bpath); - Files.createDirectories(dpath); - - fname = dpath.toString(); - System.out.printf(":Directory [%s][len=%d] created%n", fname, fname.length()); - - ////////////////////////////////////////////////////////////// - if (!Files.isDirectory(dpath) || !Files.isDirectory(dpath_nfd)) { - throw new RuntimeException("Files.isDirectory(...) failed"); - } - - ////////////////////////////////////////////////////////////// - // write out with nfd, read in with nfc + case - Files.write(fpath_nfd, new byte[] { 'n', 'f', 'd'}); - System.out.println(" read in with nfc (from nfd):" + new String(Files.readAllBytes(fpath_nfc))); - - // check attrs with nfc + case - Set pfp = Files.getPosixFilePermissions(fpath_nfd); - if (!equal(pfp, Files.getPosixFilePermissions(fpath_nfc)) ) { - throw new RuntimeException("Files.getPosixfilePermission(...) failed"); - } - Files.delete(fpath_nfd); - - // write out with nfc, read in with nfd + case - Files.write(fpath_nfc, new byte[] { 'n', 'f', 'c'}); - System.out.println(" read in with nfd (from nfc):" + new String(Files.readAllBytes(fpath_nfd))); - - // check attrs with nfc + case - pfp = Files.getPosixFilePermissions(fpath_nfc); - if (!equal(pfp, Files.getPosixFilePermissions(fpath_nfd))) { - throw new RuntimeException("Files.getPosixfilePermission(...) failed"); - } - ////////////////////////////////////////////////////////////// - boolean found_dir = false; - boolean found_file_nfc = false; - boolean found_file_nfd = false; - try (DirectoryStream stream = Files.newDirectoryStream(bpath)) { - for (Path path: stream) { - fname = path.toString(); - System.out.printf("Found : [%s], length=%d%n", fname, fname.length()); - found_dir |= match(dpath, path); - found_file_nfc |= match(fpath_nfc, path); - found_file_nfd |= match(fpath_nfd, path); - } - } - if (!found_dir || !found_file_nfc || !found_file_nfd) { - throw new RuntimeException("File.equal() failed"); - } - // glob - String glob = "*" + fname_nfd.substring(2); // remove leading "FI" from "FILE..." - System.out.println("glob=" + glob); - boolean globmatched = false; - try (DirectoryStream stream = Files.newDirectoryStream(bpath, glob)) { - for (Path path: stream) { - fname = path.toString(); - System.out.printf("PathMatch : [%s], length=%d%n", fname, fname.length()); - globmatched |= match(fpath_nfc, path); - } - } - if (!globmatched) { - //throw new RuntimeException("path matcher failed"); - // it appears we have a regex.anon_eq bug in hangul syllable handling - System.out.printf("pathmatcher failed, glob=[%s]%n", glob); - System.out.printf(" -> fname_nfd.matches(fname_nfc)=%b%n", - Pattern.compile(fname_nfd, Pattern.CANON_EQ) - .matcher(fname_nfc) - .matches()); - System.out.printf(" -> fname_nfc.matches(fname_nfd)=%b%n", - Pattern.compile(fname_nfc, Pattern.CANON_EQ) - .matcher(fname_nfd) - .matches()); - } - TestUtil.removeAll(bpath); + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, MacPath.class.getName()); + pb.environment().put("LC_ALL", "en_US.UTF-8"); + ProcessTools.executeProcess(pb) + .outputTo(System.out) + .errorTo(System.err) + .shouldHaveExitValue(0); } } diff --git a/jdk/test/java/nio/file/Path/MacPathTest.sh b/jdk/test/java/nio/file/Path/MacPathTest.sh deleted file mode 100644 index e5d410bd112..00000000000 --- a/jdk/test/java/nio/file/Path/MacPathTest.sh +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -OS=`uname -s` -case "$OS" in - Darwin ) ;; - * ) - exit 0 - ;; -esac - -if [ "x$TESTJAVA" = x ]; then - TESTJAVA=$1; shift - TESTCLASSES=. -fi - -export LC_ALL=en_US.UTF-8; ${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} MacPathTest From c48a9a184a6ce982c4cca19d88e9bb0b06e21ea7 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 21 Jun 2017 12:09:25 +0800 Subject: [PATCH 56/59] 8181575: Refactor locale related shell test java/nio/charset/spi/basic.sh to java Reviewed-by: psandoz --- .../charset/spi/CharsetProviderBasicTest.java | 122 ++++++++++++++++ .../spi/{Test.java => CharsetTest.java} | 14 +- .../java/nio/charset/spi/FooProvider.java | 10 +- jdk/test/java/nio/charset/spi/SetupJar.java | 52 +++++++ jdk/test/java/nio/charset/spi/basic.sh | 130 ------------------ 5 files changed, 187 insertions(+), 141 deletions(-) create mode 100644 jdk/test/java/nio/charset/spi/CharsetProviderBasicTest.java rename jdk/test/java/nio/charset/spi/{Test.java => CharsetTest.java} (90%) create mode 100644 jdk/test/java/nio/charset/spi/SetupJar.java delete mode 100644 jdk/test/java/nio/charset/spi/basic.sh diff --git a/jdk/test/java/nio/charset/spi/CharsetProviderBasicTest.java b/jdk/test/java/nio/charset/spi/CharsetProviderBasicTest.java new file mode 100644 index 00000000000..f67b14cfb33 --- /dev/null +++ b/jdk/test/java/nio/charset/spi/CharsetProviderBasicTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 4429040 4591027 4814743 + * @summary Unit test for charset providers + * @library /test/lib + * /lib/testlibrary + * @build jdk.test.lib.Utils + * jdk.test.lib.Asserts + * jdk.test.lib.JDKToolFinder + * jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Platform + * jdk.test.lib.process.* + * JarUtils + * FooCharset FooProvider CharsetTest + * @run driver SetupJar + * @run testng CharsetProviderBasicTest + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Stream; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static java.util.Arrays.asList; + +public class CharsetProviderBasicTest { + + private static final String TEST_SRC = System.getProperty("test.src"); + + private static final List DEFAULT_CSS = List.of( + "US-ASCII", "8859_1", "iso-ir-6", "UTF-16", "windows-1252", "!BAR", "cp1252" + ); + + private static final List MINIMAL_POLICY = List.of( + "-Djava.security.manager", + "-Djava.security.policy=" + TEST_SRC + File.separator + "default-pol" + ); + + private static final List CP_POLICY = List.of( + "-Djava.security.manager", + "-Djava.security.policy=" + TEST_SRC + File.separator + "charsetProvider.sp" + ); + + private static boolean checkSupports(String locale) throws Throwable { + return ProcessTools.executeProcess("sh", "-c", "LC_ALL=" + locale + " && " + + "locale -a | grep " + locale) + .getStdout() + .replace(System.lineSeparator(), "") + .equals(locale); + } + + @DataProvider + public static Iterator testCases() { + return Stream.of("", "ja_JP.eucJP", "tr_TR") + .flatMap(locale -> Stream.of( + new Object[]{locale, List.of(""), "FOO"}, + new Object[]{locale, MINIMAL_POLICY, "!FOO"}, + new Object[]{locale, CP_POLICY, "FOO"} + )) + .iterator(); + } + + @Test(dataProvider = "testCases") + public void testDefaultCharset(String locale, List opts, String css) throws Throwable { + if ((System.getProperty("os.name").startsWith("Windows") || !checkSupports(locale)) + && (!locale.isEmpty())) { + System.out.println(locale + ": Locale not supported, skipping..."); + return; + } + + List args = new ArrayList<>(); + args.add(JDKToolFinder.getJDKTool("java")); + args.addAll(asList(Utils.getTestJavaOpts())); + args.add("-cp"); + args.add(System.getProperty("test.class.path") + File.pathSeparator + "test.jar"); + args.addAll(opts); + args.add(CharsetTest.class.getName()); + args.addAll(DEFAULT_CSS); + args.add(css); + args.removeIf(t -> t.isEmpty()); + + ProcessBuilder pb = new ProcessBuilder(args); + + if (!locale.isEmpty()) { + pb.environment().put("LC_ALL", locale); + } + + ProcessTools.executeCommand(pb) + .shouldHaveExitValue(0); + } +} diff --git a/jdk/test/java/nio/charset/spi/Test.java b/jdk/test/java/nio/charset/spi/CharsetTest.java similarity index 90% rename from jdk/test/java/nio/charset/spi/Test.java rename to jdk/test/java/nio/charset/spi/CharsetTest.java index 646e041dcbb..4ac3d14b1d3 100644 --- a/jdk/test/java/nio/charset/spi/Test.java +++ b/jdk/test/java/nio/charset/spi/CharsetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,12 +21,14 @@ * questions. */ -import java.io.*; -import java.nio.charset.*; -import java.util.*; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.Iterator; +import java.util.SortedMap; - -public class Test { +public class CharsetTest { private static PrintStream out = System.err; private static final SortedMap available = Charset.availableCharsets(); diff --git a/jdk/test/java/nio/charset/spi/FooProvider.java b/jdk/test/java/nio/charset/spi/FooProvider.java index 16bfb4f0308..31a321764c4 100644 --- a/jdk/test/java/nio/charset/spi/FooProvider.java +++ b/jdk/test/java/nio/charset/spi/FooProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,10 +21,10 @@ * questions. */ -import java.util.*; -import java.nio.charset.*; -import java.nio.charset.spi.*; - +import java.nio.charset.Charset; +import java.nio.charset.spi.CharsetProvider; +import java.util.Collections; +import java.util.Iterator; public class FooProvider extends CharsetProvider diff --git a/jdk/test/java/nio/charset/spi/SetupJar.java b/jdk/test/java/nio/charset/spi/SetupJar.java new file mode 100644 index 00000000000..73751f87133 --- /dev/null +++ b/jdk/test/java/nio/charset/spi/SetupJar.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.nio.file.StandardOpenOption.CREATE; + +public class SetupJar { + + private static final String PROVIDER + = "META-INF/services/java.nio.charset.spi.CharsetProvider"; + private static final String TEST_DIR = System.getProperty("test.dir", "."); + + public static void main(String args[]) throws Exception { + Path xdir = Files.createDirectories(Paths.get(TEST_DIR, "xdir")); + Path provider = xdir.resolve(PROVIDER); + Files.createDirectories(provider.getParent()); + Files.write(provider, "FooProvider".getBytes(), CREATE); + + String[] files = {"FooCharset.class", "FooProvider.class"}; + for (String f : files) { + Path source = Paths.get(System.getProperty("test.classes")).resolve(f); + Path target = xdir.resolve(source.getFileName()); + Files.copy(source, target, REPLACE_EXISTING); + } + + JarUtils.createJarFile(Paths.get("test.jar"), xdir); + } +} diff --git a/jdk/test/java/nio/charset/spi/basic.sh b/jdk/test/java/nio/charset/spi/basic.sh deleted file mode 100644 index 4e1c6df891b..00000000000 --- a/jdk/test/java/nio/charset/spi/basic.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4429040 4591027 4814743 -# @summary Unit test for charset providers -# -# @build Test FooCharset FooProvider -# @run shell basic.sh -# @run shell basic.sh ja_JP.eucJP -# @run shell basic.sh tr_TR -# - -# Command-line usage: sh basic.sh /path/to/build [locale] - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA=$1; shift - COMPILEJDK="${TESTJAVA}" - TESTSRC=`pwd` - TESTCLASSES=`pwd` -fi - -JAVA=$TESTJAVA/bin/java -JAR=$COMPILEJAVA/bin/jar - -DIR=`pwd` -case `uname` in - SunOS | Linux | Darwin | AIX ) CPS=':' ;; - Windows* ) CPS=';' ;; - CYGWIN* ) - DIR=`/usr/bin/cygpath -a -s -m $DIR` - CPS=";";; - *) echo "Unknown platform: `uname`"; exit 1 ;; -esac - -JARD=$DIR/x.jar -APPD=$DIR/x.ext -TESTD=$DIR/x.test - -CSS='US-ASCII 8859_1 iso-ir-6 UTF-16 windows-1252 !BAR cp1252' - - -if [ \! -d $APPD ]; then - # Initialize - echo Initializing... - rm -rf $JARD $APPD $TESTD - mkdir -p $JARD/META-INF/services x.ext - echo FooProvider \ - >$JARD/META-INF/services/java.nio.charset.spi.CharsetProvider - cp $TESTCLASSES/FooProvider.class $TESTCLASSES/FooCharset.class $JARD - mkdir $TESTD - cp $TESTCLASSES/Test.class $TESTD - (cd $JARD; $JAR ${TESTTOOLVMOPTS} -cf $APPD/test.jar *) -fi - -if [ $# -gt 0 ]; then - # Use locale specified on command line, if it's supported - L="$1" - shift - s=`uname -s` - if [ $s != Linux -a $s != SunOS -a $s != Darwin -a $s != AIX ]; then - echo "$L: Locales not supported on this system, skipping..." - exit 0 - fi - if [ "x`locale -a | grep $L`" != "x$L" ]; then - echo "$L: Locale not supported, skipping..." - exit 0 - fi - LC_ALL=$L; export LC_ALL -fi - -TMP=${TMP:-$TEMP}; TMP=${TMP:-/tmp} -cd $TMP - -failures=0 -for where in app; do - for security in none minimal-policy cp-policy; do - echo ''; - echo "LC_ALL=$LC_ALL where=$where security=$security" - av='' - if [ $where = app ]; then - av="$av -cp $TESTD$CPS$APPD/test.jar"; - fi - case $security in - none) css="$CSS FOO";; - # Minimal policy in this case is more or less carbon copy of jre default - # security policy and doesn't give explicit runtime permission - # for user provided runtime loadable charsets - minimal-policy) css="$CSS !FOO"; - av="$av -Djava.security.manager -Djava.security.policy==$TESTSRC/default-pol";; - cp-policy) css="$CSS FOO"; - av="$av -Djava.security.manager - -Djava.security.policy=$TESTSRC/charsetProvider.sp";; - esac - if (set -x; $JAVA ${TESTVMOPTS} $av Test $css) 2>&1; then - continue; - else - failures=`expr $failures + 1` - fi - done -done - -echo '' -if [ $failures -gt 0 ]; - then echo "$failures cases failed"; - else echo "All cases passed"; fi -exit $failures From 6fcedf51742e8c1a0112881a6cc4807bc92d2d40 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 21 Jun 2017 14:40:38 +0800 Subject: [PATCH 57/59] 8182465: Refactor shell test java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh to java Reviewed-by: alanb --- .../inheritedChannel/CloseTest.java | 6 +- .../inheritedChannel/EchoService.java | 13 +- .../inheritedChannel/EchoTest.java | 11 +- .../InheritedChannelTest.java | 125 ++++++++++++++++ .../inheritedChannel/Launcher.java | 9 +- .../inheritedChannel/StateTest.java | 12 +- .../inheritedChannel/StateTestService.java | 9 +- .../inheritedChannel/Util.java | 12 +- .../inheritedChannel/run_tests.sh | 135 ------------------ 9 files changed, 172 insertions(+), 160 deletions(-) create mode 100644 jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java delete mode 100644 jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/CloseTest.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/CloseTest.java index 2515c8def02..f85a045c86d 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/CloseTest.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/CloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,9 @@ * peer has closed the connection) in less than 15 seconds. */ import java.nio.ByteBuffer; -import java.nio.channels.*; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; public class CloseTest { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoService.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoService.java index d2ffd833a1a..a2c81a6d33a 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoService.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,10 +55,15 @@ * facilate testing that the channel is closed the "tcp nowait" service * can close the connection after a given number of bytes. */ -import java.nio.*; -import java.nio.channels.*; import java.io.IOException; -import java.net.*; +import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.Channel; +import java.nio.channels.DatagramChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; public class EchoService { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java index c47f1510644..d471cbaea83 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,13 @@ * the packet is correctly echoed. * */ -import java.net.*; -import java.io.*; +import java.io.IOException; +import java.net.DatagramPacket; import java.nio.ByteBuffer; -import java.nio.channels.*; +import java.nio.channels.DatagramChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; import java.util.Random; public class EchoTest { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java new file mode 100644 index 00000000000..326d8989eb0 --- /dev/null +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/InheritedChannelTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 4673940 4930794 + * @summary Unit tests for inetd feature + * @requires (os.family == "linux" | os.family == "solaris") + * @library /test/lib + * @build jdk.test.lib.Utils + * jdk.test.lib.Asserts + * jdk.test.lib.JDKToolFinder + * jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Platform + * jdk.test.lib.process.* + * StateTest StateTestService EchoTest EchoService CloseTest Launcher Util + * @run testng/othervm InheritedChannelTest + * @key intermittent + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static java.util.Arrays.asList; + +public class InheritedChannelTest { + + private static final String TEST_SRC = System.getProperty("test.src"); + private static final String TEST_CLASSES = System.getProperty("test.classes"); + private static final Path POLICY_PASS = Paths.get(TEST_SRC, "java.policy.pass"); + private static final Path POLICY_FAIL = Paths.get(TEST_SRC, "java.policy.fail"); + + private static final String OS = System.getProperty("os.name").toLowerCase(); + private static final String OS_NAME = OS.startsWith("sunos") ? "solaris" : OS; + + private static final String ARCH = System.getProperty("os.arch"); + private static final String OS_ARCH = ARCH.equals("i386") ? "i586" : ARCH; + + private static final Path LD_LIBRARY_PATH + = Paths.get(TEST_SRC, "lib", OS_NAME + "-" + OS_ARCH); + + private static final Path LAUNCHERLIB = LD_LIBRARY_PATH.resolve("libLauncher.so"); + + @DataProvider + public Object[][] testCases() { + return new Object[][]{ + { "StateTest", List.of(StateTest.class.getName()) }, + { "EchoTest", List.of(EchoTest.class.getName()) }, + { "CloseTest", List.of(CloseTest.class.getName()) }, + + // run StateTest with a SecurityManager set + // Note that the system properties are arguments to StateTest and not options. + // These system properties are passed to the launched service as options: + // java [-options] class [args...] + { "StateTest run with " + POLICY_PASS, List.of(StateTest.class.getName(), + "-Djava.security.manager", + "-Djava.security.policy=" + + POLICY_PASS) + }, + { "StateTest run with " + POLICY_FAIL, List.of(StateTest.class.getName(), + "-expectFail", + "-Djava.security.manager", + "-Djava.security.policy=" + + POLICY_FAIL) + } + }; + } + + @Test(dataProvider = "testCases") + public void test(String desc, List opts) throws Throwable { + if (!Files.exists(LAUNCHERLIB)) { + System.out.println("Cannot find " + LAUNCHERLIB + + " - library not available for this system"); + return; + } + System.out.println("LD_LIBRARY_PATH=" + LD_LIBRARY_PATH); + + List args = new ArrayList<>(); + args.add(JDKToolFinder.getJDKTool("java")); + args.addAll(asList(Utils.getTestJavaOpts())); + args.addAll(List.of("--add-opens", "java.base/java.io=ALL-UNNAMED", + "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED")); + args.addAll(opts); + + ProcessBuilder pb = new ProcessBuilder(args); + + Map env = pb.environment(); + env.put("CLASSPATH", TEST_CLASSES); + env.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH.toString()); + + ProcessTools.executeCommand(pb) + .shouldHaveExitValue(0); + } +} diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java index 366fb745fb0..0aae4520333 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,12 @@ * A Launcher to launch a java process with its standard input, output, * and error streams connected to a socket. */ -import java.net.*; -import java.nio.channels.*; import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.nio.channels.DatagramChannel; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; public class Launcher { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTest.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTest.java index 73e25044b5a..5a79f751768 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTest.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,10 +33,14 @@ * socket state and replies back to this class via an out-of-band * channel. */ -import java.io.*; -import java.net.*; +import java.io.IOException; +import java.net.InetSocketAddress; import java.nio.ByteBuffer; -import java.nio.channels.*; +import java.nio.channels.DatagramChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; public class StateTest { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTestService.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTestService.java index 61ce76a5d8c..cfc481b46a2 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTestService.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/StateTestService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,11 +37,14 @@ * establishes a TCP connection to the port and sends a PASSED/FAILED * message to indicate the test result. */ -import java.nio.*; -import java.nio.channels.*; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.Channel; +import java.nio.channels.DatagramChannel; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; public class StateTestService { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Util.java b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Util.java index 79653811f87..0802405cf9a 100644 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Util.java +++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,12 @@ * A collection of utility methods used by the SelectorProvider.inheritedChannel * unit tests. */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.lang.reflect.*; +import java.io.File; +import java.io.FileDescriptor; +import java.lang.reflect.Field; +import java.nio.channels.DatagramChannel; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; public class Util { diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh deleted file mode 100644 index cc227b02910..00000000000 --- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# 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 4673940 4930794 -# @summary Unit tests for inetd feature -# -# @build StateTest StateTestService EchoTest EchoService CloseTest Launcher Util -# @run shell run_tests.sh -# @key intermittent - -os=`uname -s` - -if [ "$os" != "Linux" -a "$os" != "SunOS" ]; then - echo "Test not designed to run on this operating system, skipping..." - exit 0 -fi - -# if TESTJAVA isn't set then we assume an interactive run. So that it's -# clear which version of 'java' is running we do a 'which java' and -# a 'java -version'. - -if [ -z "$TESTJAVA" ]; then - TESTSRC=`pwd` - TESTCLASSES=`pwd` - JAVA=java - which $JAVA - ${JAVA} -version -else - JAVA="${TESTJAVA}/bin/java" -fi - -CLASSPATH=${TESTCLASSES} -export CLASSPATH - - -# Check that we have libLauncher.so for the right platform. -# On Solaris we assume 64-bit - -DFLAG= -if [ "$os" = "SunOS" ]; then - PLATFORM=solaris - case "`uname -p`" in - i[3-9]86) - ARCH=amd64 - ;; - sparc) - ARCH=sparcv9 - ;; - esac -fi - -if [ "$os" = "Linux" ]; then - PLATFORM=linux - ARCH=unknown - case "`uname -m`" in - i[3-6]86) - ARCH=i586 - ;; - ia64) - ARCH=ia64 - ;; - x86_64) - ARCH=amd64 - ;; - esac -fi - -LIBDIR=lib/${PLATFORM}-${ARCH} -LAUNCHERLIB=${LIBDIR}/libLauncher.so -echo $LIBDIR - -if [ ! -f "${TESTSRC}/${LAUNCHERLIB}" ]; then - echo "Cannot find ${LAUNCHERLIB} - library not available for this system" - exit 0 -fi - -LD_LIBRARY_PATH=${TESTSRC}/${LIBDIR} -export LD_LIBRARY_PATH - -failures=0 - -go() { - echo '' - sh -xc "$JAVA ${TESTVMOPTS} --add-opens java.base/java.io=ALL-UNNAMED \ - --add-opens java.base/sun.nio.ch=ALL-UNNAMED $DFLAG \ - $1 $2 $3 $4 $5 $6 $7 $8" 2>&1 - if [ $? != 0 ]; then failures=`expr $failures + 1`; fi -} - -# Run the tests - -go StateTest -go EchoTest -go CloseTest - -# Re-run StateTest with a SecurityManager set -# Note that the system properties are arguments to StateTest and not options. -# These system properties are passed to the launched service as options: -# java [-options] class [args...] - -go StateTest -Djava.security.manager -Djava.security.policy=${TESTSRC}/java.policy.pass -go StateTest -expectFail -Djava.security.manager -Djava.security.policy=${TESTSRC}/java.policy.fail - - -# -# Results -# -echo '' -if [ $failures -gt 0 ]; - then echo "$failures test(s) failed"; - else echo "All test(s) passed"; fi -exit $failures From ed1cb7d1762cc6770f7eeec36932c5b46b55ae89 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Tue, 20 Jun 2017 23:27:28 -0700 Subject: [PATCH 58/59] 8182620: Problem list java/lang/String/nativeEncoding/StringPlatformChars.java for JDK-8182569 Reviewed-by: darcy --- jdk/test/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 7dedb691e33..c6240c84623 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -126,6 +126,8 @@ java/lang/StringCoding/CheckEncodings.sh 7008363 generic- jdk/internal/misc/JavaLangAccess/NewUnsafeString.java 8176188 generic-all +java/lang/String/nativeEncoding/StringPlatformChars.java 8182569 windows-all,solaris-all + ############################################################################ # jdk_instrument From 610a746e818ae822d3042198f3945376520773a6 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 21 Jun 2017 11:41:14 -0700 Subject: [PATCH 59/59] 8182565: remove jdk.testlibrary.Utils::tryFindJvmPid and waitForJvmPid methods Reviewed-by: rriggs --- .../testlibrary/jdk/testlibrary/Utils.java | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java index 31008f554f2..01bb8d05473 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -216,63 +216,6 @@ public final class Utils { return hostName; } - /** - * Uses "jcmd -l" to search for a jvm pid. This function will wait - * forever (until jtreg timeout) for the pid to be found. - * @param key Regular expression to search for - * @return The found pid. - */ - public static int waitForJvmPid(String key) throws Throwable { - final long iterationSleepMillis = 250; - System.out.println("waitForJvmPid: Waiting for key '" + key + "'"); - System.out.flush(); - while (true) { - int pid = tryFindJvmPid(key); - if (pid >= 0) { - return pid; - } - Thread.sleep(iterationSleepMillis); - } - } - - /** - * Searches for a jvm pid in the output from "jcmd -l". - * - * Example output from jcmd is: - * 12498 sun.tools.jcmd.JCmd -l - * 12254 /tmp/jdk8/tl/jdk/JTwork/classes/com/sun/tools/attach/Application.jar - * - * @param key A regular expression to search for. - * @return The found pid, or -1 if Enot found. - * @throws Exception If multiple matching jvms are found. - */ - public static int tryFindJvmPid(String key) throws Throwable { - OutputAnalyzer output = null; - try { - JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd"); - jcmdLauncher.addToolArg("-l"); - output = ProcessTools.executeProcess(jcmdLauncher.getCommand()); - output.shouldHaveExitValue(0); - - // Search for a line starting with numbers (pid), follwed by the key. - Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n"); - Matcher matcher = pattern.matcher(output.getStdout()); - - int pid = -1; - if (matcher.find()) { - pid = Integer.parseInt(matcher.group(1)); - System.out.println("findJvmPid.pid: " + pid); - if (matcher.find()) { - throw new Exception("Found multiple JVM pids for key: " + key); - } - } - return pid; - } catch (Throwable t) { - System.out.println(String.format("Utils.findJvmPid(%s) failed: %s", key, t)); - throw t; - } - } - /** * Adjusts the provided timeout value for the TIMEOUT_FACTOR * @param tOut the timeout value to be adjusted