Home | About | Sematext search-lucene.com search-hadoop.com
 Search Lucene and all its subprojects:

Switch to Plain View
PyLucene, mail # dev - jcc dll loading error


+
Mark Finkelstein 2012-05-26, 05:57
+
Andi Vajda 2012-05-26, 07:59
+
Mark Finkelstein 2012-05-26, 08:09
+
Mark Finkelstein 2012-05-26, 08:30
+
Andi Vajda 2012-05-26, 16:24
+
Mark Finkelstein 2012-05-26, 19:20
+
Andi Vajda 2012-05-26, 19:48
+
Bill Janssen 2012-05-26, 23:42
+
Mark Finkelstein 2012-05-27, 13:30
+
Andi Vajda 2012-05-27, 18:18
+
Mark Finkelstein 2012-05-28, 09:02
Copy link to this message
-
Re: jcc dll loading error
Andi Vajda 2012-05-28, 17:10

On Mon, 28 May 2012, Mark Finkelstein wrote:

> Thank you, the examples work great! I was able to get basic functionality
> going, but when I tried to wrap a different jar file I got the following
> exception:
>
> jcc.cpp.JavaError: java.lang.ExceptionInInitializerError
> Java stacktrace:
> java.lang.ExceptionInInitializerError
> Caused by: java.lang.NullPointerException
>        at org.micromanager.utils.ImageUtils.<clinit>(ImageUtils.java:23)

JCC uses Java's reflection API to determine the signatures of methods to
wrap. Thus, it needs to load all classes it processes.

This particular class has a static initializer that is failing. You need to
look at that static initializer's code and modify it so that plainly loading
the class can work. Currently, something else is needed by this class at
load time that JCC cannot provide. Maybe it's possible to pass some extra
command line arguments, maybe you need to change its code to let that null
pointer pass for the sake of being able to plainly load this class like JCC
is trying to to.

For example, wrapping AWT classes fails in a similar way and there is a
command line flag to work that around (and it is passed to the JVM by JCC by
default, -Djava.awt.headless=true).

> There's actually one class that I really want to wrap, it's located in a
> jar file that I have in my classpath. I have also tried using --package
> org.micromanager, since this is the package the class resides in, but it
> seems as if this gets ignored.

Having a class on your classpath is not enough to have it wrapped by JCC.
You need to put its classname onto the JCC command line or pass its jar file
with --jar.
--package is different. It is used to wrap dependent classes found in the
signatures of methods of classes you explicitely asked to have wrapped.
Without --package, these methods would be skipped instead.

Run the command below to get more details about all of JCC's command line
arguments:

  $ python -m jcc.__main__

> Right now the command I'm using is:
>
> C:\Users\avastmatey>python -m jcc.__main__ --find-jvm-dll --package
> java.lang --package java.util --package java.io --jar "C:\Program
> Files\Micro-Manager-1.4\plugins\Micro-Manager\MMCoreJ.jar" --jar
> "C:\Program
> Files\Micro-Manager-1.4\plugins\Micro-Manager\MMJ_.jar" --classpath
> %CLASSPATH% --python CMMCore3 --version 2.6 --build --compiler msvc
> --install
>
> where MMJ_ is the jar which contains the class I would like to wrap. I
> think that the other classes in this jar are perhaps stopping this from
> happening? I tried to extract this jar, but got a bunch of classes with
> $1.class at the end, which I dont think represent the class I would like to
> wrap.

So you are explicitely requesting with via --jar. Good. Thus it must be
wrapped. How do you determine that it's not being wrapped ?
Because of missing methods ? Look at their signatures and be sure that all
classes they mention at least be listed via their package with --package.

$1.class class names are due to anonymous inner classes in your classes.
This is a normal Java thing, nothing to do with JCC.

Andi..

>
> Many thanks!
>
> Mark.
>
> On Sun, May 27, 2012 at 8:18 PM, Andi Vajda <[EMAIL PROTECTED]> wrote:
>
>>
>> On May 27, 2012, at 6:30, Mark Finkelstein <[EMAIL PROTECTED]> wrote:
>>
>>> That solved it; I worked through and set up everything to work
>> consistently
>>> with msvc. It now compiles, but I'm having trouble finding any good jcc
>>> examples. I tried the following:
>>
>> Take a look at PyLucene test cases and examples.
>>
>>> import jcc
>>
>> Not necessary. Only used for building your extension. Especially if you
>> didn't build your extension with --shared mode.
>>
>>> import CMMCore3
>>>
>>> vm=jcc.initVM()
>>
>> Use CMMCore3.initVM() instead.
>>
>>> vm.attachCurrentThread()
>>
>> Not necessary from main thread.
>>
>>> print vm.isCurrentThreadAttached()
>>>
>>> core=CMMCore3.CMMCore() # this is the jcc wrapped class
>>>
>>>
>>> It prints out True, but immediately afterwards gives out the
+
Mark Finkelstein 2012-05-28, 17:29
+
Andi Vajda 2012-05-28, 19:24