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
7
votes
3 answers

Attach proxy to an existing object?

My plan is to write a annotation based caching framework which caches the return values of methods. When a method gets called the first time with a specific parameter, then the cache should store the methods return value. When the same method gets…
eztam
  • 3,443
  • 7
  • 36
  • 54
7
votes
2 answers

Play 1.2.x UnexpectedException ContinuationEnhancer on helpers.CheatSheetHelper$2 invalid constant type: 15

Play framework 1.2.x starts with the following error: Oops: UnexpectedException An unexpected error occured caused by exception UnexpectedException: While applying class play.classloading.enhancers.ContinuationEnhancer on…
user1563700
7
votes
2 answers

Javassist add method and invoke

I'm stuck with javassist. I've added a new method to my object class on runtime. My object class: package tmp3; public class Car { public Car(){} } My test class: package tmp3; import java.lang.reflect.Method; import…
Korki Korkig
  • 2,736
  • 9
  • 34
  • 51
7
votes
1 answer

custom class loader for android?

I'm writing an instrumentation library that I'd like to work on both desktop and mobile (Android). It functions by: Exposing a main which takes a single parameter, the main of the target class Installing a class loader which intercepts all classes…
amirpc
  • 1,638
  • 3
  • 19
  • 24
6
votes
3 answers

Getting Javassist types instead of actual Hibernate entity types

I have stumbled upon a really annoying situation: I am using Hibernate & Spring as backend for my app and it seems that in some cases, the entities that are in a relationship with a particular entity are not fetched as normal entity objects from the…
AndaP
  • 1,308
  • 8
  • 23
  • 40
6
votes
1 answer

Adding a class to the class path with a Java Agent

I'm using a Java Agent and Javassist to add some logging to some JDK classes. Essentially when the system loads some TLS classes, Javassist will add some additional bytecode to them to help me debug some connection problems. Here's the problem,…
Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84
6
votes
1 answer

Is bytecode manipulation safe

Performing bytecode manipulation using APIs like javaassist modify class files after compilation. But, if the java code is optimized can't the modifications be performed in the wrong place? Are there ways to avoid this problem? Is the story any…
6
votes
1 answer

How to remove a method using Javassist?

I am trying to delete a method from a class file using Javassist. Target class:"RemoveMethod". Target method:"DoubleCheck". My codes: package javassist; import java.io.IOException; import java.lang.reflect.Method; import…
Delibz
  • 99
  • 2
  • 9
6
votes
1 answer

Javassist failure in hibernate: invalid constant type: 60

I'm creating a cli tool to manage an existing application. Both the application and the tests build fine and run fine but despite that I receive a javassist failure when running my cli tool that exists within the jar: INFO: Bytecode provider name :…
Kaleb Pederson
  • 45,767
  • 19
  • 102
  • 147
6
votes
1 answer

renaming a field using javassist at runtime in the pre-main method (java instrumentation)

I want to rename a field inside a java class at runtime. In addition, Any method that access that field ;wether it's read or write; I need it to be modified to use the new name instead of the old name.... All this will be done inside the pre-main…
ManKeer
  • 543
  • 2
  • 6
  • 27
6
votes
7 answers

ClassCastExceptions due to upgrade to hibernate 4.2.8 in WebSphere 8.5.5 application container

We recently upgraded hibernate from 4.0.1 to 4.2.8.Final. Hibernate.4.2.8.Final is depending on javassist-3.18.1-GA. Unfortunately websphere is 8.5.5 is not shipped with latest javassist but it is not my issue. I tried to force websphere to take my…
6
votes
1 answer

Force all Java arithmetic to strictfp at runtime, using javassist?

Given a Java application which was written with performance in mind (i.e. methods are deliberately not declared 'strictfp' in the source code), is it possible to allow users to run the entire application in strictfp mode? It looks like a crude…
6
votes
3 answers

Editing a native method class with javassist?

With Javassist, is there any way to inject code into a native method? In this case, I'm trying to make the OpenGL calls in my game print out their names and values when called, but all my attempts have hit errors when I assume the openGL dll code is…
Felix
  • 113
  • 1
  • 6
6
votes
1 answer

Integrating javassist byte code manipulation with maven compilation

I have a maven project which compiles with javac / aspectj compiler. I want to run on classes which were compiled a javassist program which manipulate the compiled classes and add stuff to them. I thought using the "process-classes" phase to run my…
6
votes
2 answers

Replace java operators by methods in bytecode using javassist

My Goal To be able to detect when, at runtime, a comparison is made (or any other operation like, *, - , /, >, < ,... This should be achieved to edit the bytecode of a class using Javassist or ow2 ASM What must be achieved This code public class…
tgoossens
  • 9,676
  • 2
  • 18
  • 23
1 2
3
40 41