test/java/lang/invoke/LFCaching/LFCachingTestCase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff test/java/lang/invoke/LFCaching

test/java/lang/invoke/LFCaching/LFCachingTestCase.java

Print this page
rev 11011 : 8057020: LambdaForm caches should support eviction
Reviewed-by: psandoz, ?


  46      * and adapter2 are the same.
  47      *
  48      * @param adapter1 First method handle.
  49      * @param adapter2 Second method handle.
  50      */
  51     public void checkLFCaching(MethodHandle adapter1, MethodHandle adapter2) {
  52         try {
  53 
  54             if (!adapter1.type().equals(adapter2.type())) {
  55                 throw new Error("TESTBUG: Types of the two method handles are not the same");
  56             }
  57 
  58             Object lambdaForm0 = LambdaFormTestCase.INTERNAL_FORM.invoke(adapter1);
  59             Object lambdaForm1 = LambdaFormTestCase.INTERNAL_FORM.invoke(adapter2);
  60 
  61             if (lambdaForm0 == null || lambdaForm1 == null) {
  62                 throw new Error("Unexpected error: One or both lambda forms of the method handles are null");
  63             }
  64 
  65             if (lambdaForm0 != lambdaForm1) {


  66                 System.err.println("Lambda form 0 toString is:");
  67                 System.err.println(lambdaForm0);
  68                 System.err.println("Lambda form 1 toString is:");
  69                 System.err.println(lambdaForm1);
  70                 throw new AssertionError("Error: Lambda forms of the two method handles"
  71                         + " are not the same. LF cahing does not work");



  72             }
  73         } catch (IllegalAccessException | IllegalArgumentException |
  74                 SecurityException | InvocationTargetException ex) {
  75             throw new Error("Unexpected exception: ", ex);
  76         }
  77     }
  78 }


  46      * and adapter2 are the same.
  47      *
  48      * @param adapter1 First method handle.
  49      * @param adapter2 Second method handle.
  50      */
  51     public void checkLFCaching(MethodHandle adapter1, MethodHandle adapter2) {
  52         try {
  53 
  54             if (!adapter1.type().equals(adapter2.type())) {
  55                 throw new Error("TESTBUG: Types of the two method handles are not the same");
  56             }
  57 
  58             Object lambdaForm0 = LambdaFormTestCase.INTERNAL_FORM.invoke(adapter1);
  59             Object lambdaForm1 = LambdaFormTestCase.INTERNAL_FORM.invoke(adapter2);
  60 
  61             if (lambdaForm0 == null || lambdaForm1 == null) {
  62                 throw new Error("Unexpected error: One or both lambda forms of the method handles are null");
  63             }
  64 
  65             if (lambdaForm0 != lambdaForm1) {
  66                 // Since LambdaForm caches are based on SoftReferences, GC can cause element eviction.
  67                 if (noGCHappened()) {
  68                     System.err.println("Lambda form 0 toString is:");
  69                     System.err.println(lambdaForm0);
  70                     System.err.println("Lambda form 1 toString is:");
  71                     System.err.println(lambdaForm1);
  72                     throw new AssertionError("Error: Lambda forms of the two method handles"
  73                             + " are not the same. LF cahing does not work");
  74                 } else {
  75                     System.err.println("LambdaForms differ, but there was a GC in between. Ignore the failure.");
  76                 }
  77             }
  78         } catch (IllegalAccessException | IllegalArgumentException |
  79                 SecurityException | InvocationTargetException ex) {
  80             throw new Error("Unexpected exception: ", ex);
  81         }
  82     }
  83 }
test/java/lang/invoke/LFCaching/LFCachingTestCase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File