Skip to content
Prev 30452 / 63421 Next

problem packaging S4 class that contains a slot of jobjRef class

Adrian,

my guess would be that you're trying to crate some Java objects at the  
top level of your package. That won't work, because R stores a  
serialized image of created objects for efficiency and hence the  
reference to any Java objects that you create will disappear as soon  
as you're done installing the package. When you try to load the  
package you'll end up with null references for all objects you have  
attempted to create that way. You have two options to avoid that:

1) create objects at load time - i.e. in the initialization function  
after you have called .jpackage. Only then is Java up and running so  
you can safely create Java objects

2) [not recommended] use .jcache to serialize objects you want to keep  
at the top level after creating them. They will be then lazily  
deserialized after the package has been loaded. However, this requires  
all such classes to implement Serializable interface on the Java side  
and is conceptually not clean, because you have to be careful when  
your cached serialization goes out of sync with the actual object (see  
details in the documentation of .jcache).

This is just my guess based on the symptoms since I think you actually  
failed to send us the part of code that triggers the problem.

Cheers,
Simon
On Nov 6, 2008, at 10:04 , Adrian Dragulescu wrote: