using JavaArgs from JavaLauncher throws error

Grigory Ptashko grigory.ptashko at gmail.com
Fri Mar 11 16:28:05 UTC 2016


Bundling jdk worked but I get the exception. Does it mean that this is because we are not
allowed to exec a process from java on ios?

Exception in thread "Thread-0" java.lang.Error: iOS is not a supported OS platform.
	at java.lang.ProcessImpl$Platform.get(ProcessImpl.java:171)
	at java.lang.ProcessImpl.<clinit>(ProcessImpl.java:175)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1111)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1075)
	at java.lang.Runtime.exec(Runtime.java:624)
	at java.lang.Runtime.exec(Runtime.java:483)
	at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:180)
	at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:132)
	at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:223)
	at jdk.jshell.JDIConnection.launchTarget(JDIConnection.java:303)
	at jdk.jshell.JDIConnection.open(JDIConnection.java:121)
	at jdk.jshell.JDIEnv.init(JDIEnv.java:49)
	at jdk.jshell.ExecutionControl.jdiGo(ExecutionControl.java:269)
	at jdk.jshell.ExecutionControl.launch(ExecutionControl.java:71)
	at jdk.jshell.JShell.executionControl(JShell.java:613)
	at jdk.jshell.ClassTracker$ClassInfo.getReferenceTypeOrNull(ClassTracker.java:81)
	at jdk.jshell.Unit.lambda$classesToLoad$3(Unit.java:266)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1422)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:591)
	at jdk.jshell.Unit.classesToLoad(Unit.java:264)
	at jdk.jshell.Eval.lambda$compileAndLoad$13(Eval.java:559)
	at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1422)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:511)
	at jdk.jshell.Eval.compileAndLoad(Eval.java:560)
	at jdk.jshell.Eval.declare(Eval.java:462)
	at jdk.jshell.Eval.declare(Eval.java:448)
	at jdk.jshell.Eval.processExpression(Eval.java:291)
	at jdk.jshell.Eval.eval(Eval.java:118)
	at jdk.jshell.JShell.eval(JShell.java:350)
	at EvalJava.main(EvalJava.java:14)

> On 11 марта 2016 г., at 19:21, Bob Vandette <bob.vandette at oracle.com> wrote:
> 
> 
> The jdk.jshell module is being built on iOS but this module is only included in the jdk image.
> jdk.shell is not available in a jre.
> 
> You could try adding the full jdk to your iOS app to see if you can access these classes.
> 
> Bob.
> 
>> On Mar 11, 2016, at 10:30 AM, Grigory Ptashko <grigory.ptashko at gmail.com> wrote:
>> 
>> I mean I can do this on my machine
>> 
>> JShell jshell = JShell.create();
>> List<SnippetEvent> events = jshell.eval("2+2");
>> System.out.println(events.get(0).value());
>> 
>> That looks pretty simple and not requiring any terminal capabilities for execution on an ios device.
>> 
>>> On 11 марта 2016 г., at 18:24, Grigory Ptashko <grigory.ptashko at gmail.com> wrote:
>>> 
>>> Yes, I want to wrap the jshell inside an ios app. But I don’t want to get input from termial.
>>> 
>>> JShell.eval() takes String so there’s no need to use console as the input.
>>> 
>>> The same way the output must not necessarily be on the console. I can grab the evaluation result
>>> from the SnippetEvent.
>>> The only thing that I don’t understand how to do is redirect evaluation of calls like System.out.printl(“some stuff”)
>>> to a string result. But this also don’t look like a problem to me since calling System.out.printl(“some stuff”);
>>> directly from the source code outputs “some stuff” in console.
>>> 
>>> So, imho there must be a way to compile jdk.jshell into the jdk9 without terminal support.
>>> 
>>> Future users of jshell API will definitely want to use the API inside non-terminal third party apps.
>>> For example, in IDE plugins.
>>> 
>>> So.. May be I can just try to build ios openjdk9 with jdk.jshell included? How can I do that?
>>> 
>>>> On 11 марта 2016 г., at 18:15, Bob Vandette <bob.vandette at oracle.com> wrote:
>>>> 
>>>> I haven’t worked with jshell yet, but it’s my understanding that it requires a terminal window
>>>> and has dependency on platform features such as ioctls for controlling the terminal window.    
>>>> Unless you wrap jshell inside of an iOS app, and port the required native features, I suspect
>>>> that it wont work even if you have a jdk.jshell module.
>>>> 
>>>> Bob.
>>>> 
>>>> 
>>>>> On Mar 11, 2016, at 9:49 AM, Grigory Ptashko <grigory.ptashko at gmail.com> wrote:
>>>>> 
>>>>> Indeed I get the NoClassDefFound if I try JShell on ios openjdk9.
>>>>> 
>>>>> It might be a silly question but may be there is a somwhat simple
>>>>> way to include the building of the jdk.jshell in the ios openjdk9 build?
>>>>> Some switches in the makefiles maybe?
>>>>> I’d like to try it if it’s possible.
>>>>> 
>>>>> Thank you.
>>>>> 
>>>>>> On 11 марта 2016 г., at 15:58, Gary Adams <gary.adams at oracle.com> wrote:
>>>>>> 
>>>>>> That's good news.
>>>>>> 
>>>>>> I haven't looked at the jdk9 docs, but you should be able to generate your own,
>>>>>> see make/{Maiin.gmk,JavaDoc.gmk}
>>>>>> 
>>>>>> make docs-image
>>>>>> 
>>>>>> The mobile project has only ported up to compact2 profile functionality.
>>>>>> If higher level modules have additional native functionality that needs to be
>>>>>> ported it may be a larger effort.
>>>>>> 
>>>>>> On 03/11/16 04:44, Grigory Ptashko wrote:
>>>>>>> Gary, thank you.
>>>>>>> 
>>>>>>> I’ve managed to launch java both on the simulator and on the iphone 6s (arm64).
>>>>>>> 
>>>>>>> 
>>>>>>> One more question. Is there a javadoc on the for openjdk9?
>>>>>>> Especially, I’m interested in the documentation on jshell API.
>>>>>>> 
>>>>>>> I googled but did not find it. I alse looked at the jdk9 source tree but there
>>>>>>> are no javadoc after building the jdk.
>>>>>>> 
>>>>>>> Thank you!
>>>>>>> 
>>>>>>>> On 10 марта 2016 г., at 16:19, Gary Adams <gary.adams at oracle.com> wrote:
>>>>>>>> 
>>>>>>>> If you look in jdk/src/java.base/ios/native/JavaLauncher/JavaArgs.m
>>>>>>>> source file you'll see several init functions that are layered.
>>>>>>>> It was originally designed to be able to swap between different properties.
>>>>>>>> e.g. initWithDebug could take release or debug property files, which calls
>>>>>>>> into initWithProperties.
>>>>>>>> 
>>>>>>>> If you add JavaLauncherArgs.properties file to your xcode project and
>>>>>>>> deploy it into your bundle it will be read & parsed when you call init. e.g.
>>>>>>>> 
>>>>>>>> JavaLauncherArgs.properties:
>>>>>>>> appArgs= ...
>>>>>>>> mainClass= ...
>>>>>>>> jvmArgs= ...
>>>>>>>> 
>>>>>>>> If you bypass the init calls you can use the explicit calls to addJavaArg and
>>>>>>>> addAppArg. See the JavaArgs.h for some additional information. There
>>>>>>>> are some doxygen comments in the header files.
>>>>>>>> 
>>>>>>>> There are some tools and template projects with some better use cases, but
>>>>>>>> they still need to be updated for jdk9 before they are ready to be pushed.
>>>>>>>> 
>>>>>>>> On 03/09/16 14:29, Grigory Ptashko wrote:
>>>>>>>>> I see.
>>>>>>>>> So how exactly should I initialize the JavaArgs when I bundle
>>>>>>>>> the JavaLauncherArgs.properties file inside my app?
>>>>>>>>> 
>>>>>>>>> with -init or with -initWithProperties: ?
>>>>>>>>> 
>>>>>>>>>> On 9 марта 2016 г., at 19:12, Gary Adams <gary.adams at oracle.com> wrote:
>>>>>>>>>> 
>>>>>>>>>> There's an old RFE about using JavaArgs without a properties file.
>>>>>>>>>> 
>>>>>>>>>> You should be OK with just
>>>>>>>>>> JavaArgs * javaArgs = [JavaArgs alloc] ;
>>>>>>>>>> 
>>>>>>>>>> if you intend to populate it directly.
>>>>>>>>>> 
>>>>>>>>>> On 03/09/16 10:02, Grigory Ptashko wrote:
>>>>>>>>>>> Hello.
>>>>>>>>>>> 
>>>>>>>>>>> I’m starting to use openjdk9 on ios.
>>>>>>>>>>> I’ve managed to compile it for use on a simulator.
>>>>>>>>>>> 
>>>>>>>>>>> My goal is to create an empty JavaArgs object.
>>>>>>>>>>> I did not create JavaLauncherArgs.properties file.
>>>>>>>>>>> 
>>>>>>>>>>> So I’m doing just this:
>>>>>>>>>>> 
>>>>>>>>>>> _javaArgs = [[JavaArgs alloc] init];
>>>>>>>>>>> 
>>>>>>>>>>> And I get the following error thrown:
>>>>>>>>>>> 
>>>>>>>>>>> -[NSPathStore2 pathForResource:ofType:]: unrecognized selector sent to instance 0x7a643040
>>>>>>>>>>> 
>>>>>>>>>>> I debugged and saw that the exception occurs in the JavaArgs.m here:
>>>>>>>>>>> 
>>>>>>>>>>>  propfile = [[JavaArgs documentsDirectory]
>>>>>>>>>>> 		   pathForResource:propertiesfile ofType:@"properties”];
>>>>>>>>>>> 
>>>>>>>>>>> In my source tree it is line 592.
>>>>>>>>>>> 
>>>>>>>>>>> Am I doing something wrong?
>>>>>>>>>>> Maybe I’m using the JavaArgs in the wrong way?
>>>>>>>>>>> 
>>>>>>>>>>> Thank you.
>>>>>>>>>>> 
>>>>>>>>>>> --
>>>>>>>>>>> Best regards,
>>>>>>>>>>> Grigory Ptashko
>>>>>>>>>>> 
>>>>>>>>>>> +7 (916) 1489766
>>>>>>>>>>> grigory.ptashko at gmail.com
>>>>>>>>>>> facebook.com/GrigoryPtashko
>>>>>>>>>>> 
>>>>>>>>> --
>>>>>>>>> Best regards,
>>>>>>>>> Grigory Ptashko
>>>>>>>>> 
>>>>>>>>> +7 (916) 1489766
>>>>>>>>> grigory.ptashko at gmail.com
>>>>>>>>> facebook.com/GrigoryPtashko
>>>>>>>>> 
>>>>>>> 
>>>>>>> --
>>>>>>> Best regards,
>>>>>>> Grigory Ptashko
>>>>>>> 
>>>>>>> +7 (916) 1489766
>>>>>>> grigory.ptashko at gmail.com
>>>>>>> facebook.com/GrigoryPtashko
>>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Best regards,
>>>>> Grigory Ptashko
>>>>> 
>>>>> +7 (916) 1489766
>>>>> grigory.ptashko at gmail.com
>>>>> facebook.com/GrigoryPtashko
>>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> Best regards,
>>> Grigory Ptashko
>>> 
>>> +7 (916) 1489766
>>> grigory.ptashko at gmail.com
>>> facebook.com/GrigoryPtashko
>>> 
>> 
>> 
>> --
>> Best regards,
>> Grigory Ptashko
>> 
>> +7 (916) 1489766
>> grigory.ptashko at gmail.com
>> facebook.com/GrigoryPtashko
>> 
> 


--
Best regards,
Grigory Ptashko

+7 (916) 1489766
grigory.ptashko at gmail.com
facebook.com/GrigoryPtashko



More information about the mobile-dev mailing list