< prev index next >
test/hotspot/jtreg/runtime/modules/CCE_module_msg.java
Print this page
*** 46,55 ****
--- 46,56 ----
private static final Path CLASSES_DIR = Paths.get("classes");
public static void main(String[] args) throws Throwable {
// Should not display version
invalidObjectToDerived();
+ invalidOriginalInnerToDerived();
invalidTimeToDerived();
invalidHeadersToDerived();
// Should display version
invalidClassToString();
// Should display customer class loader
*** 64,75 ****
for (int i = 0; i < 1; i += 1) {
left = ((Derived) instance).method(left, right);
}
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
! System.out.println(cce.getMessage());
! if (!cce.getMessage().contains("java.base/java.lang.Object cannot be cast to Derived")) {
throw new RuntimeException("Wrong message: " + cce.getMessage());
}
}
}
--- 65,93 ----
for (int i = 0; i < 1; i += 1) {
left = ((Derived) instance).method(left, right);
}
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
! System.out.println(cce.toString());
! if (!cce.getMessage().contains("class java.lang.Object cannot be cast to class Derived (java.lang.Object is in module java.base of loader 'bootstrap'; Derived is in unnamed module of loader 'app')")) {
! throw new RuntimeException("Wrong message: " + cce.getMessage());
! }
! }
! }
!
! public static void invalidOriginalInnerToDerived() {
! OriginalInner instance = new OriginalInner();
! int left = 23;
! int right = 42;
! try {
! for (int i = 0; i < 1; i += 1) {
! left = ((Derived) (java.lang.Object)instance).method(left, right);
! }
! throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
! } catch (ClassCastException cce) {
! System.out.println(cce.toString());
! if (!cce.getMessage().contains("class OriginalInner cannot be cast to class Derived (OriginalInner and Derived are in unnamed module of loader 'app')")) {
throw new RuntimeException("Wrong message: " + cce.getMessage());
}
}
}
*** 82,93 ****
for (int i = 0; i < 1; i += 1) {
left = ((Derived) (java.lang.Object)instance).method(left, right);
}
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
! System.out.println(cce.getMessage());
! if (!cce.getMessage().contains("java.sql/java.sql.Time cannot be cast to Derived")) {
throw new RuntimeException("Wrong message: " + cce.getMessage());
}
}
}
--- 100,111 ----
for (int i = 0; i < 1; i += 1) {
left = ((Derived) (java.lang.Object)instance).method(left, right);
}
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
! System.out.println(cce.toString());
! if (!cce.getMessage().contains("class java.sql.Time cannot be cast to class Derived (java.sql.Time is in module java.sql of loader 'platform'; Derived is in unnamed module of loader 'app')")) {
throw new RuntimeException("Wrong message: " + cce.getMessage());
}
}
}
*** 100,111 ****
for (int i = 0; i < 1; i += 1) {
left = ((Derived) (java.lang.Object)instance).method(left, right);
}
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
! System.out.println(cce.getMessage());
! if (!cce.getMessage().contains("jdk.httpserver/com.sun.net.httpserver.Headers cannot be cast to Derived")) {
throw new RuntimeException("Wrong message: " + cce.getMessage());
}
}
}
--- 118,129 ----
for (int i = 0; i < 1; i += 1) {
left = ((Derived) (java.lang.Object)instance).method(left, right);
}
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
! System.out.println(cce.toString());
! if (!cce.getMessage().contains("class com.sun.net.httpserver.Headers cannot be cast to class Derived (com.sun.net.httpserver.Headers is in module jdk.httpserver of loader 'platform'; Derived is in unnamed module of loader 'app')")) {
throw new RuntimeException("Wrong message: " + cce.getMessage());
}
}
}
*** 130,143 ****
Object p2Obj = new p2.c2();
System.out.println((String)p2Obj);
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
String exception = cce.getMessage();
! System.out.println(exception);
! if (exception.contains("module_two/p2.c2") ||
! !(exception.contains("module_two@") &&
! exception.contains("/p2.c2 cannot be cast to java.base/java.lang.String"))) {
throw new RuntimeException("Wrong message: " + exception);
}
}
}
--- 148,160 ----
Object p2Obj = new p2.c2();
System.out.println((String)p2Obj);
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
String exception = cce.getMessage();
! System.out.println(cce.toString());
! if (!exception.contains("class p2.c2 cannot be cast to class java.lang.String (p2.c2 is in module module_two@") ||
! !exception.contains(" of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')")) {
throw new RuntimeException("Wrong message: " + exception);
}
}
}
*** 158,175 ****
Object c4Obj = p4_c4_class.newInstance();
System.out.println((String)c4Obj);
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
String exception = cce.getMessage();
! System.out.println(exception);
! if (!exception.contains("MyClassLoader//p4.c4 cannot be cast to java.base/java.lang.String")) {
throw new RuntimeException("Wrong message: " + exception);
}
}
}
}
class Derived extends java.lang.Object {
public int method(int left, int right) {
return right;
}
}
--- 175,199 ----
Object c4Obj = p4_c4_class.newInstance();
System.out.println((String)c4Obj);
throw new RuntimeException("ClassCastException wasn't thrown, test failed.");
} catch (ClassCastException cce) {
String exception = cce.getMessage();
! System.out.println(cce.toString());
! if (!exception.contains("class p4.c4 cannot be cast to class java.lang.String (p4.c4 is in unnamed module of loader 'MyClassLoader' @") ||
! !exception.contains("; java.lang.String is in module java.base of loader 'bootstrap')")) {
throw new RuntimeException("Wrong message: " + exception);
}
}
}
}
+ class OriginalInner extends java.lang.Object {
+ public int method(int left, int right) {
+ return right;
+ }
+ }
+
class Derived extends java.lang.Object {
public int method(int left, int right) {
return right;
}
}
< prev index next >