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

Hibernate Entities Creation using Javassist

Our requirement needs Pojos to be generated based on user inputs. So classes are created on run time based on the inputs provided by users. We have been creating object using Javassist and use annotations with it to create all the required mapping.…
Manny
  • 3
  • 3
0
votes
2 answers

Intercepting field access using Javassist or ASM

I'm familiar with various ways of intercepting method invocations using proxies, but I'm wondering if there's a way to detect field access / dereferences on some proxy using a library like Javassist or ASM? For example: void…
Josh Stone
  • 4,328
  • 7
  • 29
  • 37
0
votes
1 answer

Javassist: getFileName returns null

When I compile my project with Ant, the getFileName method of the MethodCall class of javassist returns null, but when I compile it with javac file by file it returns the file where the method is called. Why is this happening? Here is my…
0
votes
1 answer

call a customized classloader with javassist

I'm using javassist API to create a method : CtMethod newmethod = CtNewMethod.make("public boolean preRemove(){return size==getObjectSize();}",ctclass); this method calls an other method getObjectSize() that exist in that class in this case I get…
0
votes
2 answers

Java - How can I dynamically instantiate an abstract class from a JAR?

I'm trying to use Javassist to load an abstract method class that is dynamically loaded from a JAR file at runtime. For some reason, this code only runs on the Windows operating system. I get a ClassDefNotFoundException on any other platform. This…
user3435571
  • 11
  • 1
  • 2
0
votes
1 answer

java.lang.AbstractMethodError after upgrading to Hibernate 3.3.2

We have a legacy application that uses Hibernate 3.0.5 and we're trying to upgrade it to Hibernate 3.3.2 (the version that has less impact on the current code). After updating the dependencies in pom.xml, the application deploys correctly, but on…
Joaquim Oliveira
  • 1,208
  • 2
  • 16
  • 29
0
votes
1 answer

Spring webapp doesn't start after adding tests with PowerMock

I needed powermock with mockito api for some JUnit test. The tests are running fine, but now I cannot run the project. I don't understand it, because all new libraries are in the test scope: junit
NeplatnyUdaj
  • 6,052
  • 6
  • 43
  • 76
0
votes
1 answer

Dozer cannot get Map. Javassist fault, is UnmodifiedMap

I'm trying to copy an entitiy to create a new entity from Hibernate, with Dozer. So far, everything has gone good. But one field has lazy loading turned on. Dozer expects a Map but since it's lazy loaded, it gets an…
Robin Jonsson
  • 2,761
  • 3
  • 22
  • 42
0
votes
1 answer

Spring way of Javassist

What is the Spring way of code piece which is written in Javassist. I know that Spring is using CGLib but I am sure that there are some useful good practices to follow for spring world. ProxyFactory factory = new…
Cemo
  • 5,370
  • 10
  • 50
  • 82
0
votes
1 answer

How to remove a previously added code block in Javassist?

Is there a way to remove a previously added code block in Javassist? I'm working on a project which modifies .class files via Javassist. Among other things it adds some code into constructors. I want this process to be runnable on the same .class…
r a f t
  • 411
  • 3
  • 9
0
votes
0 answers

Javassist adding annotation to method argument

Read this answer on the jboss community regarding adding an annotation to a parameter in a method. Stuck at getting the parameter or in Javassist terms the attribute. Given class XYZ: public class XYZ { public void changes(String whatever,…
Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
0
votes
1 answer

Can BCEL generate LocalVariableTable?

I came across a boring error: Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method net.madz.lifecycle.demo.standalone.ServiceOrder.allocateResources(JJJ)V at offset 27 I don't quite understand the error…
Barry Zhong
  • 470
  • 3
  • 17
0
votes
1 answer

Mock Ajax calls to a service endpoint to load and save the JSON structure

i have a question about what is mock ajax calls to a service endpoint to load and save the JSON Structure. I have a html+ javascript file which act as a quiz maker, user can enter question and the question will be store into a javascript array of…
user1968057
  • 69
  • 2
  • 11
0
votes
1 answer

Using Javassist to modify code in other packages?

Is there a way to write a javassist program in a package other than the src folder that can modify other classes (either in the src folder or subfolders of the src folder). I have messed around with cp.addPath("/usr/local/javalib"); and I cannot…
mdoc-2011
  • 2,747
  • 4
  • 21
  • 43
0
votes
1 answer

Javassist's CtMethod.insertAt(line,src) instruments code at the wrong bytecode position

My goal is to insert a little bit of instrumentation code at the beginning of each basic block of code. It seems like a fairly simple task with Javaassist's ControlFlow.Block and CtMethod.insertAt(). Here's the relevant chunk of code so far (it's…
Suedocode
  • 2,504
  • 3
  • 23
  • 41