Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 7
Registered: ‎01-17-2009
My Device: Not Specified

JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

Anyone out there that can help, we'd be very gratefull!

We need a deeper understanding of what defines a unique namespace in RIM’s JVM.

Scenario: We have two projects which are identical with exception of a single XML file. This single XML file defines the visual behaviour of the application. As such, both projects have the same classes defined. Being aware that you need to have unique object names in the name space we have changed several parameters in our project:

1. The Name of the Workspace and Project: APP1.jdw, APP2.jdp, etc.
2. The path names of all Objects:
a. src/com/skysoft/
b. src/comtwo/skysoftwo/object files and folders
3. We’ve changed all the .JAVA files to reference these new paths. So, in all of our .java files, declarations would look something like this:
a. Project a: package comtwo.skysoft.ui.controls
b. Project b: package com.skysofttwo.ui.controls

Note however, that the .JAVA files are still the same. For example, Button.JAVA

4. Both projects build identically, and we’ve got two different sets of output files:
a. Projecta.cod, Projecta.jad, Projecta.alx, Project name as defined in .jad is ‘project A’
b. Projectb.cod,Projectb.jad,Projectb.alx, Project name as defined in .jad is ‘project B’

5. Both projects will work on a given device when installed separately, however, when we try to install them on the same device, we get java.lang.ClassCastException when attempting to launch the applications. On the debugger, it shows ‘ Object ‘object A’ multiply defined where the object is a Checkbox or button for example.

In summary, if attempting to define the exact same objects in two different applications on a device, we would expect this ‘Multiply Defined’ issue as it’s an expected behaviour to get this JVM namespace collision.

However, after renaming all the paths and classes, and therefore corresponding objects, we would expect a Name Space collision to be resolved-but it's not....is there something else that we're missing?
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

Check language resource (rrc and rrh) package names.

 

Perhaps you left them intact in both projects. And it leads to name collision.

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

AFAIK, the Sun class files always reference fully qualified names,

 

http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html

 

and I guess you could consider the possibility that RIM has some relative names 

but you may want to look for stale files or a path you missed. You can look through your

class files ( in the jar, which presumably match the cod files) for an obvious wrong package name with grep ( should be able to  find matching binary files).  Before you get that far, just check the jar file for

picking up the wrong defs- same name, different dirs.

 

New Developer
Posts: 7
Registered: ‎01-17-2009
My Device: Not Specified

Re: JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

Thanks tbilisoft,

 

The .rrc and .rrh files are propertly named and the package name in .rrh was correct.  Also, there is no package name defined in .rrc, or at least ours. 

 

We did a very thorough job with grep, so I think the underlying problem here will be straight forward.......If we had missed something like this, our app 2 apps probably won't compile and run, but they are both running fine, just not on the same device.

 

We need to keep looking, thanks alot for your input!

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

The ClassCastException had and expected what exaactly? I think when I've run into

dup classes, usually the app won't load on the real phone.

A cast exception suggests you have hierarchies mixed up.

 

New Developer
Posts: 7
Registered: ‎01-17-2009
My Device: Not Specified

Re: JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

I'll have to go back and look at this.  The behaviour on the real device doesn't point to a hierachy problem though.  Both apps run on a real  device, no problems.  It is only when they are both on the same device and you try to launch them that get the erratic behaviour and the exception. 

 

What's more interesting, is that the first one loaded to the device will always work, regardless of it being A or B.

 

So, we know that there is some type of collision, we just can't isolate it.

 

We suspect RIM must use some relative paths, there seems to be something weird going on here.  I hope we are wrong.

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: JVM Namespace Collision Despite Renaming paths of all Objects - 'Multiply Defined' issue.

AFAIK, you get the cast problem once the app loads- it does in fact attempt to run. Again,

when I have seen this I get something like a multiply defined Error and the app never gets

control (again AFAIK) as it seems the loader has a problem.

Can you make a simple test case - is this your problem?

 

package a;

class foo {}

 

package b;

class foo{}

 

 

class someclass

{

 

public bar( Object c)

{      // this compiles but throws?                      

      (foo)  c

}

 

}