using JavaArgs from JavaLauncher throws error

Grigory Ptashko grigory.ptashko at gmail.com
Fri Mar 11 15:30:27 UTC 2016


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



More information about the mobile-dev mailing list