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

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Tue Apr 14 17:52:50 UTC 2015


Hello,
Can somebody from the awt team take a look?
Thanks.

On 14.04.15 20:05, Kumar Srinivasan wrote:
> Hi Sergey,
>
> looks good to me.
>
> Thanks
> Kumar
>
> On 4/14/2015 9:02 AM, Sergey Bylokhov wrote:
>> Hi, Kumar.
>> Thanks for your suggestions. Then new version of the fix:
>> http://cr.openjdk.java.net/~serb/8076264/webrev.02
>>
>> On 10.04.15 4:39, Kumar Srinivasan wrote:
>>> src/java.base/macosx/native/libjli/java_md_macosx.c
>>> we need a comment here explaining why the Exception is cleared, 
>>> basically what
>>> you have explained below.
>>>
>>> test/tools/launcher/MainClassWithoutEnclosingClass.java
>>> :) 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 
>>> implementation,
>>> 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!.
>>> Kumar
>>> -----------------------------------------------------------CUT------------------------------------------------------------ 
>>>
>>> /*
>>>  * Copyright (c) 2015, 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
>>>  * @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("    }");
>>>         scratch.add("}");
>>>         File enclosingFile = new File(EnclosingName + ".java");
>>>         createFile(enclosingFile, scratch);
>>>         compile(enclosingFile.getName());
>>>         // avoid side effects remove the Enclosing class
>>>         getClassFile(enclosingFile).delete();
>>>         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");
>>>         createJarFile(testJarFile);
>>>         TestResult tr = doExec(javaCmd, "-jar", testJarFile.getName());
>>>         if (!tr.isOK()) {
>>>             System.out.println(tr);
>>>             throw new RuntimeException("test returned non-positive 
>>> value");
>>>         }
>>>         if (!tr.contains("Hello World")) {
>>>             System.out.println(tr);
>>>             throw new RuntimeException("expected output not found");
>>>         }
>>>     }
>>> }
>>> -----------------------------------------------------------CUT------------------------------------------------------------ 
>>>
>>> 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
>>>>>
>>>>
>>>>
>>>
>>
>>
>


-- 
Best regards, Sergey.



More information about the awt-dev mailing list