JDK-8015302 : [macosx] Exception when app is opened via a custom URL scheme
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7u13
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • Submitted: 2013-04-04
  • Updated: 2014-11-14
  • Resolved: 2013-05-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_13 " 
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)



ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.8.2
Darwin 12.2.0

A DESCRIPTION OF THE PROBLEM :
If you create an app and add a custom URL scheme the OpenURIHandler will fail to get a callback when the app is opened by the launcher when the custom URL scheme is accessed.

If the app was already running then the OpenURIHandler callback works.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a bundled app that registers a OpenURIHandler using the Application.setOpenURIHandler.

Add a CFBundleURLTypes key and define a CFBundleURLSchemes with a custom URL like  " testscheme "  in the apps Info.plist

Open a browser and try to navitate to a URL like:  " testscheme://test " 



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception in console and a callback to the OpenURLHandler
ACTUAL -
Exception in console and no callback.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in console:

2/6/13 8:46:21.473 AM JavaAppLauncher[842]: (
0   CoreFoundation                      0x00007fff898200a6 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff840043f0 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8981fe7c +[NSException raise:format:] + 204
3   Foundation                          0x00007fff8c29f763 -[NSAppleEventDescriptor paramDescriptorForKeyword:] + 71
4   liblwawt.dylib                      0x0000000168fb2b77 -[ApplicationDelegate _handleOpenURLEvent:withReplyEvent:] + 137
5   libosxapp.dylib                     0x00000001690588b1 __-[QueuingApplicationDelegate _handleOpenURLEvent:withReplyEvent:]_block_invoke_1 + 135
6   libosxapp.dylib                     0x00000001690597bf -[QueuingApplicationDelegate processQueuedEventsWithTargetDelegate:] + 134
7   libosxapp.dylib                     0x0000000169057857 OSXAPP_SetApplicationDelegate + 153
8   liblwawt.dylib                      0x0000000168fb1899 __+[AWTStarter start:swtMode:swtModeForWebStart:]_block_invoke_1 + 111
9   Foundation                          0x00007fff8c2cf677 __NSThreadPerformPerform + 225
10  CoreFoundation                      0x00007fff8979f101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
11  CoreFoundation                      0x00007fff8979ea25 __CFRunLoopDoSources0 + 245
12  CoreFoundation                      0x00007fff897c1dc5 __CFRunLoopRun + 789
13  CoreFoundation                      0x00007fff897c16b2 CFRunLoopRunSpecific + 290
14  HIToolbox                           0x00007fff872880a4 RunCurrentEventLoopInMode + 209
15  HIToolbox                           0x00007fff87287d84 ReceiveNextEventCommon + 166
16  HIToolbox                           0x00007fff87287cd3 BlockUntilNextEventMatchingListInMode + 62
17  AppKit                              0x00007fff8e331613 _DPSNextEvent + 685
18  AppKit                              0x00007fff8e330ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
19  libosxapp.dylib                     0x0000000169057b56 -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124
20  AppKit                              0x00007fff8e328283 -[NSApplication run] + 517
21  libosxapp.dylib                     0x00000001690579b9 +[NSApplicationAWT runAWTLoopWithApp:] + 156
22  liblwawt.dylib                      0x0000000168fb181a -[AWTStarter starter:] + 1591
23  Foundation                          0x00007fff8c2cf677 __NSThreadPerformPerform + 225
24  CoreFoundation                      0x00007fff8979f101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
25  CoreFoundation                      0x00007fff8979ea25 __CFRunLoopDoSources0 + 245
26  CoreFoundation                      0x00007fff897c1dc5 __CFRunLoopRun + 789
27  CoreFoundation                      0x00007fff897c16b2 CFRunLoopRunSpecific + 290
28  libjli.dylib                        0x00000001001cb88d CreateExecutionEnvironment + 871
29  libjli.dylib                        0x00000001001c603c JLI_Launch + 1952
30  JavaAppLauncher                     0x00000001000629cb launch + 5035
31  JavaAppLauncher                     0x00000001000614f6 main + 102
32  JavaAppLauncher                     0x0000000100061484 start + 52
33  ???                                 0x0000000000000002 0x0 + 2
)



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
-------  Example test class for app:

import com.apple.eawt.AppEvent;
import com.apple.eawt.Application;
import com.apple.eawt.OpenURIHandler;

import java.net.URI;

public class TestMacUrlHandler {
    public static void main(String[] args) {
        Application.getApplication().setOpenURIHandler(new OpenURIHandler() {
            public void openURI(AppEvent.OpenURIEvent openURIEvent) {
                URI uri = openURIEvent.getURI();
            }
        });
    }
}

----- Make sure to define a custom URL scheme in app's Info.plist

<key>CFBundleURLTypes</key>
        <array>
                <dict>
                        <key>CFBundleURLSchemes</key>
                        <array>
                                <string>testscheme</string>
                        </array>
                        <key>CFBundleURLName</key>
                        <string>TestScheme</string>
                </dict>
        </array>


---------- END SOURCE ----------