<AWT Dev> [9] Review Request: 8076264 [macosx] Launching app on MacOSX requires enclosing class

Kumar Srinivasan kumar.x.srinivasan at oracle.com
Fri Apr 10 01:39:08 UTC 2015

Hi Sergey,

we need a comment here explaining why the Exception is cleared, 
basically what
you have explained below.

:) the test seems to be more complicated than the source changes,
the launcher tests have had their own test framework TestHelper, to
keep these tests  consistent,  I have enclosed a simpler test 
I have not tested this on MacOSX as I don't have one, however I have tested
on Windows,  I trust you will verify the test, with JPRT on all platforms.

Many thanks for looking into this!.
  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  * 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 
  * 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
  * @bug 8076264
  * @summary Launching app shouldn't require enclosing class for the 
main class.
  * @compile TestMainWithoutEnclosing.java
  * @run main TestMainWithoutEnclosing

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class TestMainWithoutEnclosing extends TestHelper {

     static final String EnclosingName = "Enclosing";

     static void createJarFile(File testJar) throws IOException {
         List<String> scratch = new ArrayList<>();
         scratch.add("public class Enclosing {");
         scratch.add("    public static final class Main {");
         scratch.add("        public static void main(String... args) {");
         scratch.add("            System.out.println(\"Hello World\");");
         scratch.add("        }");
         scratch.add("    }");
         File enclosingFile = new File(EnclosingName + ".java");
         createFile(enclosingFile, scratch);
         // avoid side effects remove the Enclosing class
         createJar("cvfe", testJar.getName(), EnclosingName + "$Main",
                 EnclosingName + "$Main" + ".class");
         // remove extraneous files in the current directory
         new File(EnclosingName + "$Main" + ".class").delete();

     public static void main(String... args) throws IOException {
         File testJarFile = new File("test.jar");
         TestResult tr = doExec(javaCmd, "-jar", testJarFile.getName());
         if (!tr.isOK()) {
             throw new RuntimeException("test returned non-positive value");
         if (!tr.contains("Hello World")) {
             throw new RuntimeException("expected output not found");
On 4/9/2015 3:06 PM, Sergey Bylokhov wrote:
> Hello,
> Can somebody from the core team take a look?
> Thanks.
> On 08.04.15 16:29, Sergey Bylokhov wrote:
>> Hello.
>> Please review the fix for jdk 9.
>> After the fix we clear all errors caused by getCanonicalName() on the 
>> mainclass and leave JAVA_MAIN_CLASS_ empty. This empty case will be 
>> handled in the NSApplicationAWT.m.
>> Plus small cleanup suggested in the bug report(jstring->jclass).
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8076264
>> Webrev can be found at: 
>> http://cr.openjdk.java.net/~serb/8076264/webrev.01

More information about the core-libs-dev mailing list