< prev index next >

test/hotspot/jtreg/runtime/modules/CCE_module_msg.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 46,55 **** --- 46,57 ---- private static final Path CLASSES_DIR = Paths.get("classes"); public static void main(String[] args) throws Throwable { // Should not display version invalidObjectToDerived(); + invalidTimeToDerived(); + invalidHeadersToDerived(); // Should display version invalidClassToString(); // Should display customer class loader invalidClassToStringCustomLoader(); }
*** 69,78 **** --- 71,116 ---- throw new RuntimeException("Wrong message: " + cce.getMessage()); } } } + // Test with a non-upgradeable 'java.' module other than java.base. + public static void invalidTimeToDerived() { + java.sql.Time instance = new java.sql.Time(10000); + 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.getMessage()); + if (!cce.getMessage().contains("java.sql/java.sql.Time cannot be cast to Derived")) { + throw new RuntimeException("Wrong message: " + cce.getMessage()); + } + } + } + + // Test with a non-upgradeable 'jdk.' module. + public static void invalidHeadersToDerived() { + com.sun.net.httpserver.Headers instance = new com.sun.net.httpserver.Headers(); + 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.getMessage()); + if (!cce.getMessage().contains("jdk.httpserver/com.sun.net.httpserver.Headers cannot be cast to Derived")) { + throw new RuntimeException("Wrong message: " + cce.getMessage()); + } + } + } + public static void invalidClassToString() throws Throwable { // Get the java.lang.Module object for module java.base. Class jlObject = Class.forName("java.lang.Object"); Object jlObject_jlM = jlObject.getModule(); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
< prev index next >