hotspot/test/runtime/modules/JVMDefineModule.java
changeset 43446 4f9ac7ab99d9
parent 42630 ae91fbc4b59f
child 43665 4bb003cad9b9
equal deleted inserted replaced
43445:5d868b60af95 43446:4f9ac7ab99d9
     1 /*
     1 /*
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   125             if (!e.getMessage().contains("Invalid package name")) {
   125             if (!e.getMessage().contains("Invalid package name")) {
   126               throw new RuntimeException("Failed to get expected IAE message empty package entry: " + e.getMessage());
   126               throw new RuntimeException("Failed to get expected IAE message empty package entry: " + e.getMessage());
   127             }
   127             }
   128         }
   128         }
   129 
   129 
   130         // Duplicate module name, expect an IAE
   130         // Duplicate module name, expect an ISE
   131         m = ModuleHelper.ModuleObject("module.name", cl, new String[] { "mypackage6" });
   131         m = ModuleHelper.ModuleObject("Module_A", cl, new String[] { "mypackage6" });
   132         assertNotNull(m, "Module should not be null");
   132         assertNotNull(m, "Module should not be null");
   133         ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6" });
   133         ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6" });
   134         try {
   134         try {
   135             ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6a" });
   135             ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6a" });
   136             throw new RuntimeException("Failed to get IAE for duplicate module");
   136             throw new RuntimeException("Failed to get ISE for duplicate module");
   137         } catch(IllegalArgumentException e) {
   137         } catch(IllegalStateException e) {
   138             if (!e.getMessage().contains("Module module.name is already defined")) {
   138             if (!e.getMessage().contains("Module Module_A is already defined")) {
   139               throw new RuntimeException("Failed to get expected IAE message for duplicate module: " + e.getMessage());
   139               throw new RuntimeException("Failed to get expected ISE message for duplicate module: " + e.getMessage());
   140             }
   140             }
   141         }
   141         }
   142 
   142 
   143         // Package is already defined for class loader, expect an IAE
   143         // Package is already defined for class loader, expect an ISE
   144         m = ModuleHelper.ModuleObject("dupl.pkg.module", cl, new String[] { "mypackage6b" });
   144         m = ModuleHelper.ModuleObject("dupl.pkg.module", cl, new String[] { "mypackage6b" });
   145         try {
   145         try {
   146             ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6" });
   146             ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "mypackage6" });
   147             throw new RuntimeException("Failed to get IAE for existing package");
   147             throw new RuntimeException("Failed to get ISE for existing package");
   148         } catch(IllegalArgumentException e) {
   148         } catch(IllegalStateException e) {
   149             if (!e.getMessage().contains("Package mypackage6 for module dupl.pkg.module already exists for class loader")) {
   149             if (!e.getMessage().contains("Package mypackage6 for module dupl.pkg.module is already in another module, Module_A, defined to the class loader")) {
   150               throw new RuntimeException("Failed to get expected IAE message for duplicate package: " + e.getMessage());
   150               throw new RuntimeException("Failed to get expected ISE message for duplicate package: " + e.getMessage());
   151             }
   151             }
   152         }
   152         }
   153 
   153 
   154         // Empty module name, expect an IAE
   154         // Empty module name, expect an IAE
   155         try {
   155         try {