hotspot/test/runtime/lambda-features/InterfaceInitializationStates.java
changeset 42031 55dc92f033b9
parent 41293 871b2f487dc0
equal deleted inserted replaced
42029:73e8eed6e85d 42031:55dc92f033b9
    86     }
    86     }
    87 
    87 
    88     // Iunlinked is testing initialization like interface I, except interface I is linked when
    88     // Iunlinked is testing initialization like interface I, except interface I is linked when
    89     // ClassLIM is linked.
    89     // ClassLIM is linked.
    90     // Iunlinked is not linked already when K gets an initialization error.  Linking Iunlinked
    90     // Iunlinked is not linked already when K gets an initialization error.  Linking Iunlinked
    91     // should succeed and not get NoClassDefFoundError because it does not depend on the
    91     // should succeed because it does not depend on the initialization state of K for linking.
    92     // initialization state of K for linking.  There's bug now where it gets this error.
       
    93     // See: https://bugs.openjdk.java.net/browse/JDK-8166203.
       
    94     interface Iunlinked extends K {
    92     interface Iunlinked extends K {
    95         boolean v = InterfaceInitializationStates.out(Iunlinked.class);
    93         boolean v = InterfaceInitializationStates.out(Iunlinked.class);
    96     }
    94     }
    97 
    95 
    98     // More tests.  What happens if we use K for parameters and return types?
    96     // More tests.  What happens if we use K for parameters and return types?
   155             throw new RuntimeException("FAIL exception not thrown for I's initialization");
   153             throw new RuntimeException("FAIL exception not thrown for I's initialization");
   156         } catch (ExceptionInInitializerError e) {
   154         } catch (ExceptionInInitializerError e) {
   157             System.out.println("ExceptionInInitializerError as expected");
   155             System.out.println("ExceptionInInitializerError as expected");
   158         }
   156         }
   159 
   157 
   160         // Initialize Iunlinked. This should not get NoClassDefFoundError because K
   158         // Initialize Iunlinked. No exception should be thrown even if K
   161         // (its super interface) is in initialization_error state.
   159         // (its super interface) is in initialization_error state.
   162         // This is a bug.  It does now.
   160         boolean bb = Iunlinked.v;
   163         try {
       
   164             boolean bb = Iunlinked.v;
       
   165             throw new RuntimeException("FAIL exception not thrown for Iunlinked initialization");
       
   166         } catch(NoClassDefFoundError e) {
       
   167             System.out.println("NoClassDefFoundError thrown because of bug");
       
   168         }
       
   169 
   161 
   170         // This should be okay
   162         // This should be okay
   171         boolean value = Iparams.v;
   163         boolean value = Iparams.v;
   172         System.out.println("value is " + value);
   164         System.out.println("value is " + value);
   173 
   165 
   180             System.out.println("NoClassDefFoundError thrown as expected");
   172             System.out.println("NoClassDefFoundError thrown as expected");
   181         }
   173         }
   182 
   174 
   183          // Check expected class initialization order
   175          // Check expected class initialization order
   184         List<Class<?>> expectedCInitOrder = Arrays.asList(L.class, K.class, M.class, ClassM.class,
   176         List<Class<?>> expectedCInitOrder = Arrays.asList(L.class, K.class, M.class, ClassM.class,
   185                                                           I.class, Iparams.class,
   177                                                           I.class, Iunlinked.class, Iparams.class,
   186                                                           ClassIparams.class);
   178                                                           ClassIparams.class);
   187         if (!cInitOrder.equals(expectedCInitOrder)) {
   179         if (!cInitOrder.equals(expectedCInitOrder)) {
   188             throw new RuntimeException(
   180             throw new RuntimeException(
   189                 String.format("Class initialization array %s not equal to expected array %s",
   181                 String.format("Class initialization array %s not equal to expected array %s",
   190                               cInitOrder, expectedCInitOrder));
   182                               cInitOrder, expectedCInitOrder));