/* * Copyright (c) 2016, 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * @test * @modules java.base/jdk.internal.misc * java.desktop * @run main/othervm --add-exports=java.desktop/sun.awt=java.base AddExportsTest * @run main/othervm --add-exports=java.desktop/sun.awt=ALL-UNNAMED AddExportsTest * @summary Test Module isExported methods with exports changed by -AddExportsTest
*/
publicclass AddExportsTest { /* * jtreg sets -Dtest.modules system property to the internal APIs * specified at @modules tag. The test will exclude --add-exports set * for @modules.
*/ privatestaticfinal String TEST_MODULES = System.getProperty("test.modules");
// source module
Module source;
Optional<Module> om = bootLayer.findModule(mn);
assertTrue(om.isPresent(), mn + " not in boot layer");
source = om.get();
// package should not be exported unconditionally
assertFalse(source.isExported(pn),
pn + " should not be exported unconditionally");
// $TARGET
String tn = s[1]; if ("ALL-UNNAMED".equals(tn)) {
// package is exported to all unnamed modules
assertTrue(source.isExported(pn, unnamedModule),
pn + " should be exported to all unnamed modules");
} else {
om = bootLayer.findModule(tn);
assertTrue(om.isPresent());
Module target = om.get();
// package should be exported to target module
assertTrue(source.isExported(pn, target),
pn + " should be exported to " + target);
// package should not be exported to unnamed modules
assertFalse(source.isExported(pn, unnamedModule),
pn + " should not be exported to unnamed modules");
}
}
}
staticvoid assertTrue(boolean cond) { if (!cond) thrownew RuntimeException();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.