Questions tagged [javassist]

Javassist is a class library for editing bytecode in java.

Javassist is one of several tools that exist for manipulation of Java Bytecode but, it includes a simple Java Compiler for processing source text. It receives source text written in Java and compiles it into Java bytecode, which will be inlined into a method body.

This feature allows first comers to start modifying class' bytecode to some extent without deep knowledge regarding the class format or actual bytecode instruction set and OP Codes.

611 questions
0
votes
1 answer

javassist Field check initialization

I am currently implementing an Annotation that forces the fields to respect a condition through javassist. I would like to check if a field is initialized when it is being read... so, currently, I am getting the classes by loading them when they are…
0
votes
2 answers

Why the create method of Javassist ProxyFactory does not invoke the right constructor based on the args parameter?

Consider the following class declaration: class A{ private String x; public A(String x) { this.x = x; } } When I try to create a proxy for the class A with the javassist with the following code: ProxyFactory factory = new…
rollaeriu360
  • 305
  • 1
  • 11
0
votes
0 answers

Jackson JSON: dynamically change the view

Good time! Say there is such a class: public class Individual { @JsonProperty("passport") private Passport passport; // getters ans setters } There are two use cases. First, when an income/outgoing json must be in a short format: { …
Dmitry
  • 3,028
  • 6
  • 44
  • 66
0
votes
2 answers

Javaassists and Java Web Start: class sign doesn't match the others classes sign is the same package

i'm using javaassists to modify the behaviour of a class in runtime. When i run the app in my computer all works fine. But this app is launched by the users with Java Web Start, so that the .jar of the app must be signed. When the class is modified…
Telcontar
  • 4,794
  • 7
  • 31
  • 39
0
votes
1 answer

Javassist - is it possible to change class from private to public

Is it possible, using javassist apis, to change a class inside a jar from private to public. I already know how to unzip a jar, load ctclass, make change such as modify derived class name, then zip all to a new jar. Thanks a lot
brewphone
  • 1,316
  • 4
  • 24
  • 32
0
votes
0 answers

Custom serialization with Javassist-generated proxy class

I have a proxy class generated by Javassist's ProxyFactory for a serializable class. I need to send an instance of the target class represented by the proxy class over RMI, but the remote client does not have the proxy class code so that I can only…
Tom Tucker
  • 11,676
  • 22
  • 89
  • 130
0
votes
1 answer

Javassist in Android is missing class methods found by reflection

I am trying to use javassist to examine the contents of an Android class. The purpose of why I'm doing this is irrelevant, please explain to me why the following happens: When I examine the class com.android.Intent with reflection, I get a huge list…
seibelj
  • 890
  • 2
  • 10
  • 22
0
votes
2 answers

How to get a name of a class member?

I want to be able to do something like this: prepare form: val formDescription = formBuilder(_.textField[User](_.firstName) .textField[User](_.lastName) ).build showForm(formDescription) extract data from user filled…
mmmbell
  • 438
  • 2
  • 13
0
votes
2 answers

Javassist : Bytecode.get() is not working

import javassist.bytecode.Bytecode; import javassist.bytecode.ConstPool; public class Coverage { public static void main(String[] args) { ConstPool cp = new ConstPool("Hello"); byte[] b = new byte[100]; Bytecode bc =…
Daanish
  • 1,061
  • 7
  • 18
  • 29
0
votes
1 answer

Javassist: Generate "assert" statement

I try to add an "assert" statement to a method. But I get this exception: Caused by: compile error: assert(boolean) not found in mypackage.MyClassThatIsInstrumented at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:716) at…
cedarsoft
  • 11
  • 3
0
votes
1 answer

How to load a class dynamically using classLoader

I have a .class file in disc. I want to load it dynamically onto jvm using javaassist. but it throwing exception. The following is the code i wrote: ClassPath cp=new ClassClassPath(ExampleImpl.class); …
Lakshmi
  • 81
  • 2
  • 8
0
votes
1 answer

Javassist cast and concatenation issues

I need to instantiate a function passed as a string, and i wrote a wrapper for a "Function" object that let me execute the function after it's defined. The wrapper uses the JavaAssist library, using object and method as fields of the wrapper object…
alessiop86
  • 1,285
  • 2
  • 19
  • 38
0
votes
1 answer

How to get the synchronized block object parameter in Javassist

everybody, I want to get the synchronized block parameter, such as String obj; synchronized(obj){ ... } How can I get the parameter 'obj' at byte code level using Javassist? Any suggestions are welcome.
scala
  • 11
  • 3
-1
votes
1 answer

Add Object into array

I want to create a code which uses Javassist to add annotations into compiled Java classes. I tried this: ClassFile classFile = ClassPool.getDefault().get("org.poc.Hello").getClassFile(); ConstPool constPool =…
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
-1
votes
1 answer

Get the name of operands of a code from bytecode

I'm analyzing the bytecode of a class. I can detect the opcode and the operands of it. How can I get the the name of this (the name of the object) For istance the opcode is new and i have as operand an integer (think a the follow code: "new…
orsvon
  • 11
  • 3
1 2 3
40
41