Checking for ljapi_initialize

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Checking for ljapi_initialize

Jolle Carlestam-2
Is there a way to check if ljapi_initialize has been called already?

I have an LJAPI method implemented but if I don’t put ljapi_initialize in the type it will fail. But putting ljapi_initialize at the top of the Lasso type produces log warnings
Create JVM failed: -5 Unable to create JVM. Error: -5
on all subsequent calls to the type.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Checking for ljapi_initialize

Eric Knibbe-2
Try `tag_exists('java_jvm_getenv')`? It should return `void` if LJAPI isn't initialized.

1012-Sierra:~ serveradmin$ lasso9 -s "tag_exists('java_jvm_getenv')"

1012-Sierra:~ serveradmin$ lasso9 -s "database_initialize; tag_exists('java_jvm_getenv')"
Using ImageMagick 6.7.9-10 2016-06-15 Q16 http://www.imagemagick.org
MySQLConnector using MySQL client: 6.1.6
SQLAPIDS: Oracle datasource disabled due to missing DBMS client libraries.
SQLAPIDS: SQLServer datasource disabled due to missing DBMS client libraries.
SQLAPIDS: Using PostgreSQL client API version: 0.0
SQLAPIDS: Using ODBC client API version: 0.0
SQLAPIDS: Sybase datasource disabled due to missing DBMS client libraries.
SQLAPIDS: DB2 datasource disabled due to missing DBMS client libraries.
SQLiteConnector using SQLite: 3.8.6
java_jvm_getenv

‐‐‐‐‐‐‐‐‐‐✂‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
Eric3
 

> On Apr 21, 2017, at 1:33 PM, Jolle Carlestam <[hidden email]> wrote:
>
> Is there a way to check if ljapi_initialize has been called already?
>
> I have an LJAPI method implemented but if I don’t put ljapi_initialize in the type it will fail. But putting ljapi_initialize at the top of the Lasso type produces log warnings
> Create JVM failed: -5 Unable to create JVM. Error: -5
> on all subsequent calls to the type.
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Checking for ljapi_initialize

Jolle Carlestam-2
21 apr. 2017 kl. 19:52 skrev Eric Knibbe <[hidden email]>:
>
> Try `tag_exists('java_jvm_getenv')`? It should return `void` if LJAPI isn't initialized.


Nope, did not fix it.


I ended up tweaking the actual ljapi_initialize type instead.
And that also enabled me to remove the -Xcheck:jni option and thus supressing the pointless warnings I got in the logs.
A recommendation that you (Eric) make this part of the regular distribution. As far as I understand removing the -Xcheck:jni from JVM will improve Java performance.

Code found at the bottom.

HDB
Jolle

define ljapi_initialized => var(__ljapi_initialized) || $__ljapi_initialized := false
define ljapi_initialized(value::boolean) => {
        var(__ljapi_initialized) = #value
}

define ljapi_initialize() => {

        ljapi_initialized ? return

        admin_initialize // for admin_getPref

        protect => {
                handle_failure => {
                        stdoutnl('Create JVM failed: ' + error_code + ' ' + error_msg)
                }

                local(toTie = tie(
                                                dir(sys_homePath + 'JavaLibraries/')->create & eachPathRecursive,
                                                dir(sys_userCapiModulePath)->eachPathRecursive))

                if (sys_masterHomePath)
                        dir(sys_masterHomePath + 'JavaLibraries/')->exists?
                                #toTie = tie(dir(sys_masterHomePath + 'JavaLibraries/')->eachPathRecursive, #toTie)
                /if

                local(classes = with f in #toTie
                                                where (#f !>> '/-' && #f !>> '/.' && #f !>> '.bundle/') // not disabled or hidden or a bundle
                                                                && (#f->endsWith('.jar')
                                                                        || #f->endsWith('.zip')
                                                                        || #f->endsWith('/'))
                                                select #f->replace('//', '/')&)
                local(classPath = sys_getenv('CLASSPATH')||'')
                local(pathSeparator = sys_isWindows? ';' | ':')

                #classPath->size?
                        #classPath += #pathSeparator
                #classPath += #classes->join(#pathSeparator)
                stdoutnl('Creating JVM')// with classpath: ' + #classPath)

// local(options = array('-Xcheck:jni', '-Djava.awt.headless=true'))
                local(options = array('-Djava.awt.headless=true'))
                #classPath->size?
                        #options->insert('-Djava.class.path='+#classPath)

                local(furtherOptions = admin_getPref('jvm_options'))
                #furtherOptions->size?
                        stdoutnl('\tusing additional options: '+#furtherOptions)

                with o in #furtherOptions->split(' ')
                where #o->trim&size > 0
                do #options->insert(#o)

                java_jvm_create(: #options->asStaticArray )

                ljapi_initialized(true)
        }
}


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Loading...