Hi all,
in the case you are interested in a prototype for dynamic role injection into
java agents:
http://fluca1978.blogspot.com/2008/10/whitecat-injecting-roles-into-java.html
The work has been done, of course, using the Javassist library and is based on
my previous experience in agents and rol
After a lot I found that the following is the code that works for me:
| ClassFile classFile = newProxyClass.getClassFile();
| ConstPool constantPool = classFile.getConstPool();
| AnnotationsAttribute attr = new AnnotationsAttribute(constantPool,
AnnotationsAttribute.visibleTag)
Hi,
I'm still fighting with the annotation problem. I've made a code clean up, and
now I've got the following piece of code:
| // make a new class
| CtClass newProxyClass = pool.makeClass( subProxyClassName );
| newProxyClass.setSuperclass(
I'm going mad, anyone with a suggestion?
I've found that the following piece of code:
| ByteArrayOutputStream aos = new ByteArrayOutputStream();
| AnnotationsWriter aw = new AnnotationsWriter(aos,
constantPool);
| aw.numAnnotations(1);
|
I've made another experiment: using an AnnotationsWriter as follows does not
work too:
|
| ByteArrayOutputStream aos = new ByteArrayOutputStream();
| AnnotationsWriter aw = new AnnotationsWriter(aos,
constantPool);
| aw.nu
I've found how to make the ClassFile working for defining my new class, but I'm
still unable to add the annotation. Now I work as follows:
1) I create a CtClass object and set the inheritance chain on that;
2) I get the byte[] from the CtClass and place them into a
ByteArrayInputStream, used to c
I've made another try: I've tried to get the classfile from a CtClass object
instantied with the class name of the base class:
| // make a new class and prepare the annotation
| CtClass newProxyClass = pool.makeClass(subProxyClassName);
| Cla
I've tried to define the class within the class loader, introspecting it in
place to see what happens. In other words, I added the following code:
| subProxyClassName += this.getSubClassNameSuffix();
|
| // make a new class and prepare the
This is what I've tried to do in my class loader:
| subProxyClassName += this.getSubClassNameSuffix();
|
| // make a new class and prepare the annotation
| ClassFile classFile = new ClassFile( false,
subProxyClassName, base
Just to make it more clear: I've got a special class loader that is going to
subclass a class that it must load to add specific behaviours, one of such
behaviour should be an annotation. That is why I'm searching to do them thru
Javassist.
Any suggestion?
View the original post :
http://www.jb
I'm not sure about the use of an agent, because it will perform the annotation
addition at the program load time, while I have to perform it depending on
run-time conditions at class loading time, and most important I could have
separate class loaders that add or not the annotations to the class
Hi,
thanks for your reply, I was having a look at annotation_attribute,
annotationwriter and annotationattribute, and now I've got a doubt: is the
annotation only stored in the class file? Because what I'd like to obtain is to
"inject" an annotation into a class (Runtime retention) when the clas
Hi,
can anybody point me to a simple example of how to add an annotation to a class
thru javassist?
Thanks,
Luca
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4130370#4130370
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=repl
Just to make it clearer:
* the interface I'm going to apply will remain the same during the whole
program, and so I guess it can be loaded by a parent (even root) loader;
* the class to which the interface will be applied can change during the
program execution, and so should be loaded by a custo
Hi all,
I'm writing a custom class loader that exploits Javassist to manipulate classes
on the fly. This is what I'd like to do:
1) start with a clear class (not manipulated) loaded from the root custom
classloader
2) manipulate the class inserting an interface on it, load the class with a
custo
Well, I guess Javassist is still active, since on Janauary 2008 it has been
released the 3.6 release, but the JBoss page seems not up to date.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128160#4128160
Reply to the post :
http://www.jboss.com/index.html?m
You are not trying to duplicate, rather to overload the method. I usually do
this:
1) create a StringBuffer where I place the java source code for the new method;
2) use CtNewMethod.make() to obtain a new CtMethod for the source code;
3) add the method to the CtClass.
View the original post :
ht
You can refer to method arguments using the special $n variables, for instance
if your argument is the third, than in the method code you can refer to it as
$3. Similarly, $$ is substituted to the full list of arguments.
View the original post :
http://www.jboss.com/index.html?module=bb&op=view
Hi,
is it possible using Javassist to understand if a specified instance has a
monitor active? I know this is not a problem of reflection, but given an
instance CI of class C, if I need to load a modified version of class C to
produce CI2 that substitutes CI I should bother with any possible thr
19 matches
Mail list logo