Merge

Thu, 15 Aug 2013 21:33:37 +0100

author
chegar
date
Thu, 15 Aug 2013 21:33:37 +0100
changeset 5876
8f3c59225a5c
parent 5875
ee7a7aa7c6bb
parent 5494
0bbd1c775bef
child 5877
7638e35cabc6

Merge

test/runtime/7196045/Test7196045.java file | annotate | diff | comparison | revisions
test/runtime/8000968/Test8000968.sh file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Fri Aug 09 14:30:08 2013 +0100
     1.2 +++ b/.hgtags	Thu Aug 15 21:33:37 2013 +0100
     1.3 @@ -366,3 +366,5 @@
     1.4  f6921c876db192bba389cec062855a66372da01c jdk8-b101
     1.5  530fe88b3b2c710f42810b3580d86a0d83ad6c1c hs25-b44
     1.6  c4697c1c448416108743b59118b4a2498b339d0c jdk8-b102
     1.7 +7f55137d6aa81efc6eb0035813709f2cb6a26b8b hs25-b45
     1.8 +6f9be7f87b9653e94fd8fb3070891a0cc91b15bf jdk8-b103
     2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java	Fri Aug 09 14:30:08 2013 +0100
     2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java	Thu Aug 15 21:33:37 2013 +0100
     2.3 @@ -29,11 +29,10 @@
     2.4      public static final int JVMTI_THREAD_STATE_ALIVE = 0x0001;
     2.5      public static final int JVMTI_THREAD_STATE_TERMINATED = 0x0002;
     2.6      public static final int JVMTI_THREAD_STATE_RUNNABLE = 0x0004;
     2.7 -    public static final int JVMTI_THREAD_STATE_WAITING = 0x0008;
     2.8 +    public static final int JVMTI_THREAD_STATE_WAITING = 0x0080;
     2.9      public static final int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
    2.10      public static final int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
    2.11      public static final int JVMTI_THREAD_STATE_SLEEPING = 0x0040;
    2.12 -    public static final int JVMTI_THREAD_STATE_WAITING_FOR_NOTIFICATION = 0x0080;
    2.13      public static final int JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100;
    2.14      public static final int JVMTI_THREAD_STATE_PARKED = 0x0200;
    2.15      public static final int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400;
     3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/OSThread.java	Fri Aug 09 14:30:08 2013 +0100
     3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/OSThread.java	Thu Aug 15 21:33:37 2013 +0100
     3.3 @@ -32,7 +32,7 @@
     3.4  // to the sys_thread_t structure of the classic JVM implementation.
     3.5  public class OSThread extends VMObject {
     3.6      private static JIntField interruptedField;
     3.7 -    private static JIntField threadIdField;
     3.8 +    private static Field threadIdField;
     3.9      static {
    3.10          VM.registerVMInitializedObserver(new Observer() {
    3.11              public void update(Observable o, Object data) {
    3.12 @@ -44,7 +44,7 @@
    3.13      private static synchronized void initialize(TypeDataBase db) {
    3.14          Type type = db.lookupType("OSThread");
    3.15          interruptedField = type.getJIntField("_interrupted");
    3.16 -        threadIdField = type.getJIntField("_thread_id");
    3.17 +        threadIdField = type.getField("_thread_id");
    3.18      }
    3.19  
    3.20      public OSThread(Address addr) {
    3.21 @@ -56,7 +56,7 @@
    3.22      }
    3.23  
    3.24      public int threadId() {
    3.25 -        return (int)threadIdField.getValue(addr);
    3.26 +        return threadIdField.getJInt(addr);
    3.27      }
    3.28  
    3.29  }
     4.1 --- a/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java	Fri Aug 09 14:30:08 2013 +0100
     4.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java	Thu Aug 15 21:33:37 2013 +0100
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -74,23 +74,24 @@
    4.11      public void run() {
    4.12          // Ready to go with the database...
    4.13          try {
    4.14 -            // The name of the filter always comes from a System property.
    4.15 -            // If we have a pkgList, pass it, otherwise let the filter read
    4.16 -            // its own System property for the list of classes.
    4.17 -            String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter",
    4.18 -                                                        "sun.jvm.hotspot.tools.jcore.PackageNameFilter");
    4.19 -            try {
    4.20 -                Class filterClass = Class.forName(filterClassName);
    4.21 -                if (pkgList == null) {
    4.22 -                    classFilter = (ClassFilter) filterClass.newInstance();
    4.23 -                } else {
    4.24 -                    Constructor con = filterClass.getConstructor(String.class);
    4.25 -                    classFilter = (ClassFilter) con.newInstance(pkgList);
    4.26 +            if (classFilter == null) {
    4.27 +                // If not already set, the name of the filter comes from a System property.
    4.28 +                // If we have a pkgList, pass it, otherwise let the filter read
    4.29 +                // its own System property for the list of classes.
    4.30 +                String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter",
    4.31 +                                                            "sun.jvm.hotspot.tools.jcore.PackageNameFilter");
    4.32 +                try {
    4.33 +                    Class filterClass = Class.forName(filterClassName);
    4.34 +                    if (pkgList == null) {
    4.35 +                        classFilter = (ClassFilter) filterClass.newInstance();
    4.36 +                    } else {
    4.37 +                        Constructor con = filterClass.getConstructor(String.class);
    4.38 +                        classFilter = (ClassFilter) con.newInstance(pkgList);
    4.39 +                    }
    4.40 +                } catch(Exception exp) {
    4.41 +                    System.err.println("Warning: Can not create class filter!");
    4.42                  }
    4.43 -            } catch(Exception exp) {
    4.44 -                System.err.println("Warning: Can not create class filter!");
    4.45              }
    4.46 -
    4.47              String outputDirectory = System.getProperty("sun.jvm.hotspot.tools.jcore.outputDir", ".");
    4.48              setOutputDirectory(outputDirectory);
    4.49  
     5.1 --- a/make/hotspot_version	Fri Aug 09 14:30:08 2013 +0100
     5.2 +++ b/make/hotspot_version	Thu Aug 15 21:33:37 2013 +0100
     5.3 @@ -35,7 +35,7 @@
     5.4  
     5.5  HS_MAJOR_VER=25
     5.6  HS_MINOR_VER=0
     5.7 -HS_BUILD_NUMBER=44
     5.8 +HS_BUILD_NUMBER=45
     5.9  
    5.10  JDK_MAJOR_VER=1
    5.11  JDK_MINOR_VER=8
     6.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Aug 09 14:30:08 2013 +0100
     6.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Aug 15 21:33:37 2013 +0100
     6.3 @@ -2295,7 +2295,7 @@
     6.4        if (gen_type_check) {
     6.5          // We have determined that offset == referent_offset && src != null.
     6.6          // if (src->_klass->_reference_type == REF_NONE) -> continue
     6.7 -        __ move(new LIR_Address(src.result(), oopDesc::klass_offset_in_bytes(), UseCompressedKlassPointers ? T_OBJECT : T_ADDRESS), src_klass);
     6.8 +        __ move(new LIR_Address(src.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), src_klass);
     6.9          LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
    6.10          LIR_Opr reference_type = new_register(T_INT);
    6.11          __ move(reference_type_addr, reference_type);
     7.1 --- a/src/share/vm/classfile/classLoader.cpp	Fri Aug 09 14:30:08 2013 +0100
     7.2 +++ b/src/share/vm/classfile/classLoader.cpp	Thu Aug 15 21:33:37 2013 +0100
     7.3 @@ -878,7 +878,7 @@
     7.4  
     7.5  instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
     7.6    ResourceMark rm(THREAD);
     7.7 -  EventMark m("loading class " INTPTR_FORMAT, (address)h_name);
     7.8 +  EventMark m("loading class %s", h_name->as_C_string());
     7.9    ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
    7.10  
    7.11    stringStream st;
     8.1 --- a/src/share/vm/runtime/arguments.cpp	Fri Aug 09 14:30:08 2013 +0100
     8.2 +++ b/src/share/vm/runtime/arguments.cpp	Thu Aug 15 21:33:37 2013 +0100
     8.3 @@ -60,6 +60,28 @@
     8.4  #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
     8.5  #define DEFAULT_JAVA_LAUNCHER  "generic"
     8.6  
     8.7 +// Disable options not supported in this release, with a warning if they
     8.8 +// were explicitly requested on the command-line
     8.9 +#define UNSUPPORTED_OPTION(opt, description)                    \
    8.10 +do {                                                            \
    8.11 +  if (opt) {                                                    \
    8.12 +    if (FLAG_IS_CMDLINE(opt)) {                                 \
    8.13 +      warning(description " is disabled in this release.");     \
    8.14 +    }                                                           \
    8.15 +    FLAG_SET_DEFAULT(opt, false);                               \
    8.16 +  }                                                             \
    8.17 +} while(0)
    8.18 +
    8.19 +#define UNSUPPORTED_GC_OPTION(gc)                                     \
    8.20 +do {                                                                  \
    8.21 +  if (gc) {                                                           \
    8.22 +    if (FLAG_IS_CMDLINE(gc)) {                                        \
    8.23 +      warning(#gc " is not supported in this VM.  Using Serial GC."); \
    8.24 +    }                                                                 \
    8.25 +    FLAG_SET_DEFAULT(gc, false);                                      \
    8.26 +  }                                                                   \
    8.27 +} while(0)
    8.28 +
    8.29  char**  Arguments::_jvm_flags_array             = NULL;
    8.30  int     Arguments::_num_jvm_flags               = 0;
    8.31  char**  Arguments::_jvm_args_array              = NULL;
    8.32 @@ -3128,14 +3150,17 @@
    8.33      FLAG_SET_DEFAULT(UseLargePages, false);
    8.34    }
    8.35  
    8.36 -  // Tiered compilation is undefined with C1.
    8.37 -  TieredCompilation = false;
    8.38  #else
    8.39    if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
    8.40      FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
    8.41    }
    8.42  #endif
    8.43  
    8.44 +#ifndef TIERED
    8.45 +  // Tiered compilation is undefined.
    8.46 +  UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
    8.47 +#endif
    8.48 +
    8.49    // If we are running in a headless jre, force java.awt.headless property
    8.50    // to be true unless the property has already been set.
    8.51    // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
    8.52 @@ -3278,29 +3303,6 @@
    8.53    }
    8.54  }
    8.55  
    8.56 -// Disable options not supported in this release, with a warning if they
    8.57 -// were explicitly requested on the command-line
    8.58 -#define UNSUPPORTED_OPTION(opt, description)                    \
    8.59 -do {                                                            \
    8.60 -  if (opt) {                                                    \
    8.61 -    if (FLAG_IS_CMDLINE(opt)) {                                 \
    8.62 -      warning(description " is disabled in this release.");     \
    8.63 -    }                                                           \
    8.64 -    FLAG_SET_DEFAULT(opt, false);                               \
    8.65 -  }                                                             \
    8.66 -} while(0)
    8.67 -
    8.68 -
    8.69 -#define UNSUPPORTED_GC_OPTION(gc)                                     \
    8.70 -do {                                                                  \
    8.71 -  if (gc) {                                                           \
    8.72 -    if (FLAG_IS_CMDLINE(gc)) {                                        \
    8.73 -      warning(#gc " is not supported in this VM.  Using Serial GC."); \
    8.74 -    }                                                                 \
    8.75 -    FLAG_SET_DEFAULT(gc, false);                                      \
    8.76 -  }                                                                   \
    8.77 -} while(0)
    8.78 -
    8.79  #if !INCLUDE_ALL_GCS
    8.80  static void force_serial_gc() {
    8.81    FLAG_SET_DEFAULT(UseSerialGC, true);
     9.1 --- a/src/share/vm/services/gcNotifier.cpp	Fri Aug 09 14:30:08 2013 +0100
     9.2 +++ b/src/share/vm/services/gcNotifier.cpp	Thu Aug 15 21:33:37 2013 +0100
     9.3 @@ -1,5 +1,5 @@
     9.4  /*
     9.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     9.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     9.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.8   *
     9.9   * This code is free software; you can redistribute it and/or modify it
    9.10 @@ -211,9 +211,9 @@
    9.11      NotificationMark nm(request);
    9.12      Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
    9.13  
    9.14 -    Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
    9.15 -    Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
    9.16 -    Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
    9.17 +    Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
    9.18 +    Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
    9.19 +    Handle objCause = java_lang_String::create_from_str(request->gcCause, CHECK);
    9.20  
    9.21      Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
    9.22      instanceKlassHandle gc_mbean_klass(THREAD, k);
    10.1 --- a/src/share/vm/services/management.cpp	Fri Aug 09 14:30:08 2013 +0100
    10.2 +++ b/src/share/vm/services/management.cpp	Thu Aug 15 21:33:37 2013 +0100
    10.3 @@ -1831,13 +1831,13 @@
    10.4   private:
    10.5    objArrayHandle _names_strings;
    10.6    char **_names_chars;
    10.7 -  typeArrayOop _times;
    10.8 +  typeArrayHandle _times;
    10.9    int _names_len;
   10.10    int _times_len;
   10.11    int _count;
   10.12  
   10.13   public:
   10.14 -  ThreadTimesClosure(objArrayHandle names, typeArrayOop times);
   10.15 +  ThreadTimesClosure(objArrayHandle names, typeArrayHandle times);
   10.16    ~ThreadTimesClosure();
   10.17    virtual void do_thread(Thread* thread);
   10.18    void do_unlocked();
   10.19 @@ -1845,9 +1845,9 @@
   10.20  };
   10.21  
   10.22  ThreadTimesClosure::ThreadTimesClosure(objArrayHandle names,
   10.23 -                                       typeArrayOop times) {
   10.24 +                                       typeArrayHandle times) {
   10.25    assert(names() != NULL, "names was NULL");
   10.26 -  assert(times != NULL, "times was NULL");
   10.27 +  assert(times() != NULL, "times was NULL");
   10.28    _names_strings = names;
   10.29    _names_len = names->length();
   10.30    _names_chars = NEW_C_HEAP_ARRAY(char*, _names_len, mtInternal);
   10.31 @@ -1925,7 +1925,7 @@
   10.32    typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(times));
   10.33    typeArrayHandle times_ah(THREAD, ta);
   10.34  
   10.35 -  ThreadTimesClosure ttc(names_ah, times_ah());
   10.36 +  ThreadTimesClosure ttc(names_ah, times_ah);
   10.37    {
   10.38      MutexLockerEx ml(Threads_lock);
   10.39      Threads::threads_do(&ttc);
    11.1 --- a/src/share/vm/utilities/exceptions.cpp	Fri Aug 09 14:30:08 2013 +0100
    11.2 +++ b/src/share/vm/utilities/exceptions.cpp	Thu Aug 15 21:33:37 2013 +0100
    11.3 @@ -125,13 +125,13 @@
    11.4  }
    11.5  
    11.6  void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) {
    11.7 +  ResourceMark rm;
    11.8    assert(h_exception() != NULL, "exception should not be NULL");
    11.9  
   11.10    // tracing (do this up front - so it works during boot strapping)
   11.11    if (TraceExceptions) {
   11.12      ttyLocker ttyl;
   11.13 -    ResourceMark rm;
   11.14 -    tty->print_cr("Exception <%s>%s%s (" INTPTR_FORMAT " ) \n"
   11.15 +    tty->print_cr("Exception <%s%s%s> (" INTPTR_FORMAT ") \n"
   11.16                    "thrown [%s, line %d]\nfor thread " INTPTR_FORMAT,
   11.17                    h_exception->print_value_string(),
   11.18                    message ? ": " : "", message ? message : "",
   11.19 @@ -141,7 +141,9 @@
   11.20    NOT_PRODUCT(Exceptions::debug_check_abort(h_exception, message));
   11.21  
   11.22    // Check for special boot-strapping/vm-thread handling
   11.23 -  if (special_exception(thread, file, line, h_exception)) return;
   11.24 +  if (special_exception(thread, file, line, h_exception)) {
   11.25 +    return;
   11.26 +  }
   11.27  
   11.28    assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable");
   11.29  
   11.30 @@ -149,7 +151,9 @@
   11.31    thread->set_pending_exception(h_exception(), file, line);
   11.32  
   11.33    // vm log
   11.34 -  Events::log_exception(thread, "Threw " INTPTR_FORMAT " at %s:%d", (address)h_exception(), file, line);
   11.35 +  Events::log_exception(thread, "Exception <%s%s%s> (" INTPTR_FORMAT ") thrown at [%s, line %d]",
   11.36 +                        h_exception->print_value_string(), message ? ": " : "", message ? message : "",
   11.37 +                        (address)h_exception(), file, line);
   11.38  }
   11.39  
   11.40  
    12.1 --- a/src/share/vm/utilities/taskqueue.hpp	Fri Aug 09 14:30:08 2013 +0100
    12.2 +++ b/src/share/vm/utilities/taskqueue.hpp	Thu Aug 15 21:33:37 2013 +0100
    12.3 @@ -395,7 +395,13 @@
    12.4  template<class E, MEMFLAGS F, unsigned int N>
    12.5  bool GenericTaskQueue<E, F, N>::pop_global(E& t) {
    12.6    Age oldAge = _age.get();
    12.7 -  uint localBot = _bottom;
    12.8 +  // Architectures with weak memory model require a barrier here
    12.9 +  // to guarantee that bottom is not older than age,
   12.10 +  // which is crucial for the correctness of the algorithm.
   12.11 +#if !(defined SPARC || defined IA32 || defined AMD64)
   12.12 +  OrderAccess::fence();
   12.13 +#endif
   12.14 +  uint localBot = OrderAccess::load_acquire((volatile juint*)&_bottom);
   12.15    uint n_elems = size(localBot, oldAge.top());
   12.16    if (n_elems == 0) {
   12.17      return false;
   12.18 @@ -644,7 +650,7 @@
   12.19  template<class E, MEMFLAGS F, unsigned int N> inline bool
   12.20  GenericTaskQueue<E, F, N>::push(E t) {
   12.21    uint localBot = _bottom;
   12.22 -  assert((localBot >= 0) && (localBot < N), "_bottom out of range.");
   12.23 +  assert(localBot < N, "_bottom out of range.");
   12.24    idx_t top = _age.top();
   12.25    uint dirty_n_elems = dirty_size(localBot, top);
   12.26    assert(dirty_n_elems < N, "n_elems out of range.");
    13.1 --- a/test/compiler/codecache/CheckUpperLimit.java	Fri Aug 09 14:30:08 2013 +0100
    13.2 +++ b/test/compiler/codecache/CheckUpperLimit.java	Thu Aug 15 21:33:37 2013 +0100
    13.3 @@ -35,10 +35,6 @@
    13.4      ProcessBuilder pb;
    13.5      OutputAnalyzer out;
    13.6  
    13.7 -    pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=2048m", "-version");
    13.8 -    out = new OutputAnalyzer(pb.start());
    13.9 -    out.shouldHaveExitValue(0);
   13.10 -
   13.11      pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=2049m", "-version");
   13.12      out = new OutputAnalyzer(pb.start());
   13.13      out.shouldContain("Invalid ReservedCodeCacheSize=");
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java	Thu Aug 15 21:33:37 2013 +0100
    14.3 @@ -0,0 +1,71 @@
    14.4 +/*
    14.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +
   14.27 +/*
   14.28 + * @test
   14.29 + * @bug 8016474
   14.30 + * @summary The bug only happens with C1 and G1 using a different ObjectAlignmentInBytes than KlassAlignmentInBytes (which is 8)
   14.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 GetUnsafeObjectG1PreBarrier
   14.32 + */
   14.33 +
   14.34 +import java.lang.reflect.Field;
   14.35 +
   14.36 +import sun.misc.Unsafe;
   14.37 +
   14.38 +public class GetUnsafeObjectG1PreBarrier {
   14.39 +    private static final Unsafe unsafe;
   14.40 +    private static final int N = 100_000;
   14.41 +
   14.42 +    static {
   14.43 +        try {
   14.44 +            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
   14.45 +            theUnsafe.setAccessible(true);
   14.46 +            unsafe = (Unsafe) theUnsafe.get(null);
   14.47 +        } catch (NoSuchFieldException | IllegalAccessException e) {
   14.48 +            throw new IllegalStateException(e);
   14.49 +        }
   14.50 +    }
   14.51 +
   14.52 +    public Object a;
   14.53 +
   14.54 +    public static void main(String[] args) throws Throwable {
   14.55 +        new GetUnsafeObjectG1PreBarrier();
   14.56 +    }
   14.57 +
   14.58 +    public GetUnsafeObjectG1PreBarrier() throws Throwable {
   14.59 +        doit();
   14.60 +    }
   14.61 +
   14.62 +    private void doit() throws Throwable {
   14.63 +        Field field = GetUnsafeObjectG1PreBarrier.class.getField("a");
   14.64 +        long fieldOffset = unsafe.objectFieldOffset(field);
   14.65 +
   14.66 +        for (int i = 0; i < N; i++) {
   14.67 +            readField(this, fieldOffset);
   14.68 +        }
   14.69 +    }
   14.70 +
   14.71 +    private void readField(Object o, long fieldOffset) {
   14.72 +        unsafe.getObject(o, fieldOffset);
   14.73 +    }
   14.74 +}
    15.1 --- a/test/runtime/7196045/Test7196045.java	Fri Aug 09 14:30:08 2013 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,78 +0,0 @@
    15.4 -/*
    15.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    15.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 - *
    15.8 - * This code is free software; you can redistribute it and/or modify it
    15.9 - * under the terms of the GNU General Public License version 2 only, as
   15.10 - * published by the Free Software Foundation.
   15.11 - *
   15.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 - * version 2 for more details (a copy is included in the LICENSE file that
   15.16 - * accompanied this code).
   15.17 - *
   15.18 - * You should have received a copy of the GNU General Public License version
   15.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 - *
   15.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 - * or visit www.oracle.com if you need additional information or have any
   15.24 - * questions.
   15.25 - *
   15.26 - */
   15.27 -
   15.28 -/*
   15.29 - * @test
   15.30 - * @bug 7196045
   15.31 - * @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
   15.32 - * @run main/othervm -XX:+UsePerfData Test7196045
   15.33 - */
   15.34 -
   15.35 -import java.lang.management.ManagementFactory;
   15.36 -import javax.management.JMException;
   15.37 -import javax.management.MBeanServer;
   15.38 -import javax.management.MalformedObjectNameException;
   15.39 -import javax.management.ObjectName;
   15.40 -
   15.41 -public class Test7196045 {
   15.42 -
   15.43 -    public static long duration = 1000 * 60 * 2;
   15.44 -    private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal";
   15.45 -
   15.46 -    public static void main(String[] args) {
   15.47 -
   15.48 -        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
   15.49 -        ObjectName objName= null;
   15.50 -        try {
   15.51 -            ObjectName hotspotInternal = new ObjectName(HOTSPOT_INTERNAL);
   15.52 -            try {
   15.53 -                server.registerMBean(new sun.management.HotspotInternal(), hotspotInternal);
   15.54 -            } catch (JMException e) {
   15.55 -                throw new RuntimeException("HotSpotWatcher: Failed to register the HotspotInternal MBean" + e);
   15.56 -            }
   15.57 -            objName= new ObjectName("sun.management:type=HotspotThreading");
   15.58 -
   15.59 -        } catch (MalformedObjectNameException e1) {
   15.60 -            throw new RuntimeException("Bad object name" + e1);
   15.61 -        }
   15.62 -
   15.63 -        long endTime = System.currentTimeMillis() + duration;
   15.64 -        long i = 0;
   15.65 -        while (true) {
   15.66 -            try {
   15.67 -                server.getAttribute(objName, "InternalThreadCpuTimes");
   15.68 -            } catch (Exception ex) {
   15.69 -                System.err.println("Exception while getting attribute: " + ex);
   15.70 -            }
   15.71 -            i++;
   15.72 -            if (i % 10000 == 0) {
   15.73 -                System.out.println("Successful iterations: " + i);
   15.74 -            }
   15.75 -            if (System.currentTimeMillis() > endTime) {
   15.76 -                break;
   15.77 -            }
   15.78 -        }
   15.79 -        System.out.println("PASSED.");
   15.80 -    }
   15.81 -}
    16.1 --- a/test/runtime/8000968/Test8000968.sh	Fri Aug 09 14:30:08 2013 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,99 +0,0 @@
    16.4 -#
    16.5 -#  Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    16.6 -#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 -#
    16.8 -#  This code is free software; you can redistribute it and/or modify it
    16.9 -#  under the terms of the GNU General Public License version 2 only, as
   16.10 -#  published by the Free Software Foundation.
   16.11 -#
   16.12 -#  This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 -#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 -#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 -#  version 2 for more details (a copy is included in the LICENSE file that
   16.16 -#  accompanied this code).
   16.17 -#
   16.18 -#  You should have received a copy of the GNU General Public License version
   16.19 -#  2 along with this work; if not, write to the Free Software Foundation,
   16.20 -#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 -#
   16.22 -#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 -#  or visit www.oracle.com if you need additional information or have any
   16.24 -#  questions.
   16.25 -#
   16.26 -
   16.27 -
   16.28 -# @test Test8000968.sh
   16.29 -# @bug 8000968
   16.30 -# @summary NPG: UseCompressedKlassPointers asserts with ObjectAlignmentInBytes=32
   16.31 -# @run shell Test8000968.sh
   16.32 -#
   16.33 -
   16.34 -if [ "${TESTJAVA}" = "" ]
   16.35 -then
   16.36 -  PARENT=`dirname \`which java\``
   16.37 -  TESTJAVA=`dirname ${PARENT}`
   16.38 -  printf "TESTJAVA not set, selecting " ${TESTJAVA}
   16.39 -  printf "  If this is incorrect, try setting the variable manually.\n"
   16.40 -fi
   16.41 -
   16.42 -
   16.43 -# set platform-dependent variables
   16.44 -OS=`uname -s`
   16.45 -case "$OS" in
   16.46 -  Windows_* )
   16.47 -    FS="\\"
   16.48 -    NULL=NUL
   16.49 -    ;;
   16.50 -  * )
   16.51 -    FS="/"
   16.52 -    NULL=/dev/null
   16.53 -    ;;
   16.54 -esac
   16.55 -
   16.56 -JAVA=${TESTJAVA}${FS}bin${FS}java
   16.57 -
   16.58 -#
   16.59 -# See if platform has 64 bit java.
   16.60 -#
   16.61 -${JAVA} ${TESTVMOPTS} -d64 -version 2>&1 | grep -i "does not support" > ${NULL}
   16.62 -if [ "$?" != "1" ]
   16.63 -then
   16.64 -  printf "Platform is 32 bit, does not support -XX:ObjectAlignmentInBytes= option.\n"
   16.65 -  printf "Passed.\n"
   16.66 -  exit 0
   16.67 -fi
   16.68 -
   16.69 -#
   16.70 -# Test -XX:ObjectAlignmentInBytes with -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops.
   16.71 -#
   16.72 -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=16 -version 2>&1 > ${NULL}
   16.73 -if [ "$?" != "0" ]
   16.74 -then
   16.75 -  printf "FAILED: -XX:ObjectAlignmentInBytes=16 option did not work.\n"
   16.76 -  exit 1
   16.77 -fi
   16.78 -
   16.79 -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=32 -version 2>&1 > ${NULL}
   16.80 -if [ "$?" != "0" ]
   16.81 -then
   16.82 -  printf "FAILED: -XX:ObjectAlignmentInBytes=32 option did not work.\n"
   16.83 -  exit 1
   16.84 -fi
   16.85 -
   16.86 -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=64 -version 2>&1 > ${NULL}
   16.87 -if [ "$?" != "0" ]
   16.88 -then
   16.89 -  printf "FAILED: -XX:ObjectAlignmentInBytes=64 option did not work.\n"
   16.90 -  exit 1
   16.91 -fi
   16.92 -
   16.93 -${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=128 -version 2>&1 > ${NULL}
   16.94 -if [ "$?" != "0" ]
   16.95 -then
   16.96 -  printf "FAILED: -XX:ObjectAlignmentInBytes=128 option did not work.\n"
   16.97 -  exit 1
   16.98 -fi
   16.99 -
  16.100 -
  16.101 -printf "Passed.\n"
  16.102 -exit 0
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java	Thu Aug 15 21:33:37 2013 +0100
    17.3 @@ -0,0 +1,63 @@
    17.4 +/*
    17.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.23 + * or visit www.oracle.com if you need additional information or have any
   17.24 + * questions.
   17.25 + */
   17.26 +
   17.27 +/*
   17.28 + * @test
   17.29 + * @bug 8000968
   17.30 + * @key regression
   17.31 + * @summary NPG: UseCompressedKlassPointers asserts with ObjectAlignmentInBytes=32
   17.32 + * @library /testlibrary
   17.33 + */
   17.34 +
   17.35 +import com.oracle.java.testlibrary.*;
   17.36 +
   17.37 +public class CompressedKlassPointerAndOops {
   17.38 +
   17.39 +    public static void main(String[] args) throws Exception {
   17.40 +
   17.41 +        if (!Platform.is64bit()) {
   17.42 +            // Can't test this on 32 bit, just pass
   17.43 +            System.out.println("Skipping test on 32bit");
   17.44 +            return;
   17.45 +        }
   17.46 +
   17.47 +        runWithAlignment(16);
   17.48 +        runWithAlignment(32);
   17.49 +        runWithAlignment(64);
   17.50 +        runWithAlignment(128);
   17.51 +    }
   17.52 +
   17.53 +    private static void runWithAlignment(int alignment) throws Exception {
   17.54 +        ProcessBuilder pb;
   17.55 +        OutputAnalyzer output;
   17.56 +
   17.57 +        pb = ProcessTools.createJavaProcessBuilder(
   17.58 +            "-XX:+UseCompressedKlassPointers",
   17.59 +            "-XX:+UseCompressedOops",
   17.60 +            "-XX:ObjectAlignmentInBytes=" + alignment,
   17.61 +            "-version");
   17.62 +
   17.63 +        output = new OutputAnalyzer(pb.start());
   17.64 +        output.shouldHaveExitValue(0);
   17.65 +    }
   17.66 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java	Thu Aug 15 21:33:37 2013 +0100
    18.3 @@ -0,0 +1,92 @@
    18.4 +/*
    18.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + *
   18.26 + */
   18.27 +
   18.28 +/*
   18.29 + * @test
   18.30 + * @bug 7196045
   18.31 + * @bug 8014294
   18.32 + * @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
   18.33 + * @run main/othervm -XX:+UsePerfData -Xmx32m ThreadCpuTimesDeadlock
   18.34 + */
   18.35 +
   18.36 +import java.lang.management.ManagementFactory;
   18.37 +import javax.management.JMException;
   18.38 +import javax.management.MBeanServer;
   18.39 +import javax.management.MalformedObjectNameException;
   18.40 +import javax.management.ObjectName;
   18.41 +
   18.42 +public class ThreadCpuTimesDeadlock {
   18.43 +
   18.44 +    public static byte[] dummy;
   18.45 +    public static long duration = 10 * 1000;
   18.46 +    private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal";
   18.47 +
   18.48 +    public static void main(String[] args) {
   18.49 +
   18.50 +        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
   18.51 +        ObjectName objName= null;
   18.52 +        try {
   18.53 +            ObjectName hotspotInternal = new ObjectName(HOTSPOT_INTERNAL);
   18.54 +            try {
   18.55 +                server.registerMBean(new sun.management.HotspotInternal(), hotspotInternal);
   18.56 +            } catch (JMException e) {
   18.57 +                throw new RuntimeException("HotSpotWatcher: Failed to register the HotspotInternal MBean" + e);
   18.58 +            }
   18.59 +            objName= new ObjectName("sun.management:type=HotspotThreading");
   18.60 +
   18.61 +        } catch (MalformedObjectNameException e1) {
   18.62 +            throw new RuntimeException("Bad object name" + e1);
   18.63 +        }
   18.64 +
   18.65 +        // Thread that allocs memory to generate GC's
   18.66 +        Thread allocThread = new Thread() {
   18.67 +          public void run() {
   18.68 +            while (true) {
   18.69 +              dummy = new byte[4096];
   18.70 +            }
   18.71 +          }
   18.72 +        };
   18.73 +
   18.74 +        allocThread.setDaemon(true);
   18.75 +        allocThread.start();
   18.76 +
   18.77 +        long endTime = System.currentTimeMillis() + duration;
   18.78 +        long i = 0;
   18.79 +        while (true) {
   18.80 +            try {
   18.81 +                server.getAttribute(objName, "InternalThreadCpuTimes");
   18.82 +            } catch (Exception ex) {
   18.83 +                System.err.println("Exception while getting attribute: " + ex);
   18.84 +            }
   18.85 +            i++;
   18.86 +            if (i % 10000 == 0) {
   18.87 +                System.out.println("Successful iterations: " + i);
   18.88 +            }
   18.89 +            if (System.currentTimeMillis() > endTime) {
   18.90 +                break;
   18.91 +            }
   18.92 +        }
   18.93 +        System.out.println("PASSED.");
   18.94 +    }
   18.95 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/testlibrary/OutputAnalyzerReportingTest.java	Thu Aug 15 21:33:37 2013 +0100
    19.3 @@ -0,0 +1,124 @@
    19.4 +/*
    19.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +
   19.28 +/*
   19.29 + * @test
   19.30 + * @summary Test the OutputAnalyzer reporting functionality,
   19.31 + *     such as printing additional diagnostic info
   19.32 + *     (exit code, stdout, stderr, command line, etc.)
   19.33 + * @library /testlibrary
   19.34 + */
   19.35 +
   19.36 +import java.io.ByteArrayOutputStream;
   19.37 +import java.io.PrintStream;
   19.38 +
   19.39 +import com.oracle.java.testlibrary.OutputAnalyzer;
   19.40 +import com.oracle.java.testlibrary.ProcessTools;
   19.41 +
   19.42 +
   19.43 +public class OutputAnalyzerReportingTest {
   19.44 +
   19.45 +    public static void main(String[] args) throws Exception {
   19.46 +        // Create the output analyzer under test
   19.47 +        String stdout = "aaaaaa";
   19.48 +        String stderr = "bbbbbb";
   19.49 +        OutputAnalyzer output = new OutputAnalyzer(stdout, stderr);
   19.50 +
   19.51 +        // Expected summary values should be the same for all cases,
   19.52 +        // since the outputAnalyzer object is the same
   19.53 +        String expectedExitValue = "-1";
   19.54 +        String expectedSummary =
   19.55 +                " stdout: [" + stdout + "];\n" +
   19.56 +                " stderr: [" + stderr + "]\n" +
   19.57 +                " exitValue = " + expectedExitValue + "\n";
   19.58 +
   19.59 +
   19.60 +        DiagnosticSummaryTestRunner testRunner =
   19.61 +                new DiagnosticSummaryTestRunner();
   19.62 +
   19.63 +        // should have exit value
   19.64 +        testRunner.init(expectedSummary);
   19.65 +        int unexpectedExitValue = 2;
   19.66 +        try {
   19.67 +            output.shouldHaveExitValue(unexpectedExitValue);
   19.68 +        } catch (RuntimeException e) { }
   19.69 +        testRunner.closeAndCheckResults();
   19.70 +
   19.71 +        // should not contain
   19.72 +        testRunner.init(expectedSummary);
   19.73 +        try {
   19.74 +            output.shouldNotContain(stdout);
   19.75 +        } catch (RuntimeException e) { }
   19.76 +        testRunner.closeAndCheckResults();
   19.77 +
   19.78 +        // should contain
   19.79 +        testRunner.init(expectedSummary);
   19.80 +        try {
   19.81 +            output.shouldContain("unexpected-stuff");
   19.82 +        } catch (RuntimeException e) { }
   19.83 +        testRunner.closeAndCheckResults();
   19.84 +
   19.85 +        // should not match
   19.86 +        testRunner.init(expectedSummary);
   19.87 +        try {
   19.88 +            output.shouldNotMatch("[a]");
   19.89 +        } catch (RuntimeException e) { }
   19.90 +        testRunner.closeAndCheckResults();
   19.91 +
   19.92 +        // should match
   19.93 +        testRunner.init(expectedSummary);
   19.94 +        try {
   19.95 +            output.shouldMatch("[qwerty]");
   19.96 +        } catch (RuntimeException e) { }
   19.97 +        testRunner.closeAndCheckResults();
   19.98 +
   19.99 +    }
  19.100 +
  19.101 +    private static class DiagnosticSummaryTestRunner {
  19.102 +        private ByteArrayOutputStream byteStream =
  19.103 +                new ByteArrayOutputStream(10000);
  19.104 +
  19.105 +        private String expectedSummary = "";
  19.106 +        private PrintStream errStream;
  19.107 +
  19.108 +
  19.109 +        public void init(String expectedSummary) {
  19.110 +            this.expectedSummary = expectedSummary;
  19.111 +            byteStream.reset();
  19.112 +            errStream = new PrintStream(byteStream);
  19.113 +            System.setErr(errStream);
  19.114 +        }
  19.115 +
  19.116 +        public void closeAndCheckResults() {
  19.117 +            // check results
  19.118 +            errStream.close();
  19.119 +            String stdErrStr = byteStream.toString();
  19.120 +            if (!stdErrStr.contains(expectedSummary)) {
  19.121 +                throw new RuntimeException("The output does not contain "
  19.122 +                    + "the diagnostic message, or the message is incorrect");
  19.123 +            }
  19.124 +        }
  19.125 +    }
  19.126 +
  19.127 +}
    20.1 --- a/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java	Fri Aug 09 14:30:08 2013 +0100
    20.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java	Thu Aug 15 21:33:37 2013 +0100
    20.3 @@ -76,7 +76,8 @@
    20.4     */
    20.5    public void shouldContain(String expectedString) {
    20.6      if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) {
    20.7 -      throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr: [" + stdout + stderr + "]\n");
    20.8 +        reportDiagnosticSummary();
    20.9 +        throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n");
   20.10      }
   20.11    }
   20.12  
   20.13 @@ -88,7 +89,8 @@
   20.14     */
   20.15    public void stdoutShouldContain(String expectedString) {
   20.16      if (!stdout.contains(expectedString)) {
   20.17 -      throw new RuntimeException("'" + expectedString + "' missing from stdout: [" + stdout + "]\n");
   20.18 +        reportDiagnosticSummary();
   20.19 +        throw new RuntimeException("'" + expectedString + "' missing from stdout \n");
   20.20      }
   20.21    }
   20.22  
   20.23 @@ -100,7 +102,8 @@
   20.24     */
   20.25    public void stderrShouldContain(String expectedString) {
   20.26      if (!stderr.contains(expectedString)) {
   20.27 -      throw new RuntimeException("'" + expectedString + "' missing from stderr: [" + stderr + "]\n");
   20.28 +        reportDiagnosticSummary();
   20.29 +        throw new RuntimeException("'" + expectedString + "' missing from stderr \n");
   20.30      }
   20.31    }
   20.32  
   20.33 @@ -112,10 +115,12 @@
   20.34     */
   20.35    public void shouldNotContain(String notExpectedString) {
   20.36      if (stdout.contains(notExpectedString)) {
   20.37 -      throw new RuntimeException("'" + notExpectedString + "' found in stdout: [" + stdout + "]\n");
   20.38 +        reportDiagnosticSummary();
   20.39 +        throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
   20.40      }
   20.41      if (stderr.contains(notExpectedString)) {
   20.42 -      throw new RuntimeException("'" + notExpectedString + "' found in stderr: [" + stderr + "]\n");
   20.43 +        reportDiagnosticSummary();
   20.44 +        throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
   20.45      }
   20.46    }
   20.47  
   20.48 @@ -127,7 +132,8 @@
   20.49     */
   20.50    public void stdoutShouldNotContain(String notExpectedString) {
   20.51      if (stdout.contains(notExpectedString)) {
   20.52 -      throw new RuntimeException("'" + notExpectedString + "' found in stdout: [" + stdout + "]\n");
   20.53 +        reportDiagnosticSummary();
   20.54 +        throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
   20.55      }
   20.56    }
   20.57  
   20.58 @@ -139,7 +145,8 @@
   20.59     */
   20.60    public void stderrShouldNotContain(String notExpectedString) {
   20.61      if (stderr.contains(notExpectedString)) {
   20.62 -      throw new RuntimeException("'" + notExpectedString + "' found in stderr: [" + stderr + "]\n");
   20.63 +        reportDiagnosticSummary();
   20.64 +        throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
   20.65      }
   20.66    }
   20.67  
   20.68 @@ -154,9 +161,9 @@
   20.69        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
   20.70        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
   20.71        if (!stdoutMatcher.find() && !stderrMatcher.find()) {
   20.72 +          reportDiagnosticSummary();
   20.73            throw new RuntimeException("'" + pattern
   20.74 -                  + "' missing from stdout/stderr: [" + stdout + stderr
   20.75 -                  + "]\n");
   20.76 +                + "' missing from stdout/stderr \n");
   20.77        }
   20.78    }
   20.79  
   20.80 @@ -170,8 +177,9 @@
   20.81    public void stdoutShouldMatch(String pattern) {
   20.82        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
   20.83        if (!matcher.find()) {
   20.84 +          reportDiagnosticSummary();
   20.85            throw new RuntimeException("'" + pattern
   20.86 -                  + "' missing from stdout: [" + stdout + "]\n");
   20.87 +                + "' missing from stdout \n");
   20.88        }
   20.89    }
   20.90  
   20.91 @@ -185,8 +193,9 @@
   20.92    public void stderrShouldMatch(String pattern) {
   20.93        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
   20.94        if (!matcher.find()) {
   20.95 +          reportDiagnosticSummary();
   20.96            throw new RuntimeException("'" + pattern
   20.97 -                  + "' missing from stderr: [" + stderr + "]\n");
   20.98 +                + "' missing from stderr \n");
   20.99        }
  20.100    }
  20.101  
  20.102 @@ -200,13 +209,15 @@
  20.103    public void shouldNotMatch(String pattern) {
  20.104        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
  20.105        if (matcher.find()) {
  20.106 +          reportDiagnosticSummary();
  20.107            throw new RuntimeException("'" + pattern
  20.108 -                  + "' found in stdout: [" + stdout + "]\n");
  20.109 +                  + "' found in stdout \n");
  20.110        }
  20.111        matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
  20.112        if (matcher.find()) {
  20.113 +          reportDiagnosticSummary();
  20.114            throw new RuntimeException("'" + pattern
  20.115 -                  + "' found in stderr: [" + stderr + "]\n");
  20.116 +                  + "' found in stderr \n");
  20.117        }
  20.118    }
  20.119  
  20.120 @@ -220,8 +231,9 @@
  20.121    public void stdoutShouldNotMatch(String pattern) {
  20.122        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
  20.123        if (matcher.find()) {
  20.124 +          reportDiagnosticSummary();
  20.125            throw new RuntimeException("'" + pattern
  20.126 -                  + "' found in stdout: [" + stdout + "]\n");
  20.127 +                  + "' found in stdout \n");
  20.128        }
  20.129    }
  20.130  
  20.131 @@ -235,23 +247,45 @@
  20.132    public void stderrShouldNotMatch(String pattern) {
  20.133        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
  20.134        if (matcher.find()) {
  20.135 +          reportDiagnosticSummary();
  20.136            throw new RuntimeException("'" + pattern
  20.137 -                  + "' found in stderr: [" + stderr + "]\n");
  20.138 +                  + "' found in stderr \n");
  20.139        }
  20.140    }
  20.141  
  20.142    /**
  20.143 -   * Verifiy the exit value of the process
  20.144 +   * Verify the exit value of the process
  20.145     *
  20.146     * @param expectedExitValue Expected exit value from process
  20.147     * @throws RuntimeException If the exit value from the process did not match the expected value
  20.148     */
  20.149    public void shouldHaveExitValue(int expectedExitValue) {
  20.150        if (getExitValue() != expectedExitValue) {
  20.151 -          throw new RuntimeException("Exit value " + getExitValue() + " , expected to get " + expectedExitValue);
  20.152 +          reportDiagnosticSummary();
  20.153 +          throw new RuntimeException("Expected to get exit value of ["
  20.154 +                  + expectedExitValue + "]\n");
  20.155        }
  20.156    }
  20.157  
  20.158 +
  20.159 +  /**
  20.160 +   * Report summary that will help to diagnose the problem
  20.161 +   * Currently includes:
  20.162 +   *  - standard input produced by the process under test
  20.163 +   *  - standard output
  20.164 +   *  - exit code
  20.165 +   *  Note: the command line is printed by the ProcessTools
  20.166 +   */
  20.167 +    private void reportDiagnosticSummary() {
  20.168 +        String msg =
  20.169 +            " stdout: [" + stdout + "];\n" +
  20.170 +            " stderr: [" + stderr + "]\n" +
  20.171 +            " exitValue = " + getExitValue() + "\n";
  20.172 +
  20.173 +        System.err.println(msg);
  20.174 +    }
  20.175 +
  20.176 +
  20.177    /**
  20.178     * Get the contents of the output buffer (stdout and stderr)
  20.179     *
    21.1 --- a/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Fri Aug 09 14:30:08 2013 +0100
    21.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/Platform.java	Thu Aug 15 21:33:37 2013 +0100
    21.3 @@ -27,6 +27,7 @@
    21.4    private static final String osName = System.getProperty("os.name");
    21.5    private static final String dataModel = System.getProperty("sun.arch.data.model");
    21.6    private static final String vmVersion = System.getProperty("java.vm.version");
    21.7 +  private static final String osArch = System.getProperty("os.arch");
    21.8  
    21.9    public static boolean is64bit() {
   21.10      return dataModel.equals("64");
   21.11 @@ -59,4 +60,14 @@
   21.12    public static String getVMVersion() {
   21.13      return vmVersion;
   21.14    }
   21.15 +
   21.16 +  // Returns true for sparc and sparcv9.
   21.17 +  public static boolean isSparc() {
   21.18 +    return osArch.toLowerCase().startsWith("sparc");
   21.19 +  }
   21.20 +
   21.21 +  public static String getOsArch() {
   21.22 +    return osArch;
   21.23 +  }
   21.24 +
   21.25  }
    22.1 --- a/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java	Fri Aug 09 14:30:08 2013 +0100
    22.2 +++ b/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java	Thu Aug 15 21:33:37 2013 +0100
    22.3 @@ -31,6 +31,7 @@
    22.4  import java.lang.reflect.Method;
    22.5  import java.util.ArrayList;
    22.6  import java.util.Collections;
    22.7 +import java.util.List;
    22.8  
    22.9  import sun.management.VMManagement;
   22.10  
   22.11 @@ -107,6 +108,22 @@
   22.12    }
   22.13  
   22.14    /**
   22.15 +   * Get the string containing input arguments passed to the VM
   22.16 +   *
   22.17 +   * @return arguments
   22.18 +   */
   22.19 +  public static String getVmInputArguments() {
   22.20 +    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
   22.21 +
   22.22 +    List<String> args = runtime.getInputArguments();
   22.23 +    StringBuilder result = new StringBuilder();
   22.24 +    for (String arg : args)
   22.25 +        result.append(arg).append(' ');
   22.26 +
   22.27 +    return result.toString();
   22.28 +  }
   22.29 +
   22.30 +  /**
   22.31     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
   22.32     *
   22.33     * @return String[] with platform specific arguments, empty if there are none
   22.34 @@ -132,8 +149,13 @@
   22.35      Collections.addAll(args, getPlatformSpecificVMArgs());
   22.36      Collections.addAll(args, command);
   22.37  
   22.38 +    // Reporting
   22.39 +    StringBuilder cmdLine = new StringBuilder();
   22.40 +    for (String cmd : args)
   22.41 +        cmdLine.append(cmd).append(' ');
   22.42 +    System.out.println("Command line: [" + cmdLine.toString() + "]");
   22.43 +
   22.44      return new ProcessBuilder(args.toArray(new String[args.size()]));
   22.45 -
   22.46    }
   22.47  
   22.48  }

mercurial