I'm continuing here a discussion I started with Brian in case
anyone has some ideas...


>From: Brian Ingerson <[EMAIL PROTECTED]>
>To: Patrick LeBoutillier <[EMAIL PROTECTED]>,   
>[EMAIL PROTECTED]
>Subject: Re: Inline::Java needs help!
>Date: Fri, 04 May 2001 14:38:24 -0700
>
> > Patrick LeBoutillier wrote:
> >
> > Hi Brian,
> >
> > I'm having trouble using Inline::Java in many different Inline
> > sections (it doesn't work at all actually).
>
>What do you mean by this? Could you send me an example?
>

Here's what's happening. I've optimized Inline::Java so that it only loads 
one JVM for all of the sections:

use Inline (Java => 'DATA') ;
use Inline (Java => 'DATA') ;

__END__

__Java__
class a{
  public a(){
  }
}

__Java__
class b{
  public b(){
  }
}

When you run this you'll an error like:
    Can't find class b

The goal is to have the same JVM contain the objects for both the sections. 
One reason for this is performance, the other one is that using JNI you can 
only create one JVM (one per thread I think).

The problem is that the JVM must know in advance where the class
files will be (using CLASSPATH). This cannot be changed at run time.
So when comes the time to load the second section, the JVM is already
running and doesn't know where to look for class "b". It knows for class "a" 
since I set the CLASSPATH just before launching the JVM.

The only way to overcome this is to write your own ClassLoader. Then you can 
load classes from anywhere, but they can only interact in a limited way with 
the other classes unless they are public.

But with Inline::Java you can't presently write public classes. The reason 
for this is that in Java public classes must be in a .java file with the 
same name as the class, i.e

class a -> a.java
class b -> b.java

To do this with Inline::Java I would need parse the user code, split up the 
classes, save them in different files with the proper name, and then compile 
the whole batch. This is considerably more complex
then what I do presently. But maybe I won't have a choice...

The other nasty thing I could try to do (I don't know if it's possible), is 
to try and post process the .class files to flip the bit
that says if they're public or not... but that would be cheating, right?

Anyways all this to say that I'm a bit stumped. Maybe some of you have 
ideas... Anything is welcome
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Reply via email to