< prev index next >

test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java

Print this page

        

@@ -27,16 +27,25 @@
 /**
  * Helper class used to catch and process VirtualMachineError with message "Out
  * of space in CodeCache". Some JSR292 tests run out of code cache size, so code
  * cache overflows and VME is thrown. This VME is considered as non-critical in
  * some JSR292 tests, so it should be processed to prevent test failure.
+ * <p>
+ * The result of a VirtualMachineError being thrown at class initialization time
+ * is an unusable class, which when tried to be used again, triggers a secondary
+ * NoClassDefFoundError with message "Could not initialize class ClassName" and
+ * no cause. This NCDFE is also considered non-critical because it is a consequence
+ * of the VME (or any other exception) being thrown from {@code &lt;clinit&gt;}.
+ * If the cause for secondary exception is not VME, then the test should fail
+ * because of the primary exception anyway.
  */
 public class CodeCacheOverflowProcessor {
 
     /**
      * Checks if an instance of Throwable is caused by VirtualMachineError with
-     * message "Out of space in CodeCache". May be used as filter in method
+     * message "Out of space in CodeCache" or by NoClassDefFoundError with message
+     * "Could not initialize class ClassName". May be used as filter in method
      * {@code jdk.testlibrary.Utils.filterException}.
      *
      * @param t - Throwable to check.
      * @return true if Throwable is caused by VME, false otherwise.
      */

@@ -46,21 +55,27 @@
             if (causeOfT instanceof VirtualMachineError
                     && causeOfT.getMessage().matches(".*[Oo]ut of space"
                             + " in CodeCache.*")) {
                 return true;
             }
+            if (causeOfT instanceof NoClassDefFoundError
+                    && causeOfT.getMessage().matches("Could not initialize class.*")
+                    && causeOfT.getCause() == null) {
+                return true;
+            }
             causeOfT = causeOfT != null ? causeOfT.getCause() : null;
         } while (causeOfT != null && causeOfT != t);
         return false;
     }
 
     /**
      * Checks if the given test throws an exception caused by
-     * VirtualMachineError with message "Out of space in CodeCache", and, if VME
-     * takes place, processes it so that no exception is thrown, and prints its
-     * stack trace. If test throws exception not caused by VME, this method just
-     * re-throws this exception.
+     * VirtualMachineError with message "Out of space in CodeCache" or by
+     * NoClassDefFoundError with message "Could not initialize class ClassName",
+     * and, if this is the case, processes it so that no exception is thrown,
+     * and prints its stack trace. If test throws any other exception,
+     * this method just re-throws this exception.
      *
      * @param test - test to check for and process VirtualMachineError.
      * @return - an exception caused by VME or null
      *           if test has thrown no exception.
      * @throws Throwable - if test has thrown an exception
< prev index next >