Passing a Class <?> Using Rhino

I am trying to call the constructor for a custom collection object. This user object accepts a parameter of type Class.

In java, this is done as follows:

ICollection col = new PersistentCollection(ContentX.class); 

This is my first diving in a rhino, and I could not determine exactly how to pass this parameter. I realized that “class” is a reserved word and therefore unusable.

I realized that I can get the class from Class.forName as follows:

 importPackage(Packages.something.collections); importPackage(Packages.something.content4); var col = new PersistentCollection(Class.forName(ContentX)); 

But it just throws a ClassNotFoundException - with something.content4.ContentX fully qualified! Thus, it is obvious that he found a class or he would not know the way to it.

Am I doing it wrong? Unfortunately, I am not able to change the java library right now, I need to fix the data without a new deployment.

Googling for the javascript class just gives problems with DOM / CSS.

+4
source share
1 answer

I think you just need to do:

 var col = new PersistentCollection(ContentX); 

Or if your class name is a string:

 var col = new PersistentCollection( java.lang.Class.forName('something.content4.ContentX')); 
+2
source

All Articles