Questions tagged [java-bytecode-asm]

ASM is a Java library used for JVM bytecode manipulation and creation.

ASM is a Java bytecode manipulation and analysis framework. It provides a library to read, write, transform, and analyze compiled Java classes, directly in the binary form of byte arrays. Its API allows easy access to class items such as annotations, fields, and methods. Instructions in methods can be analyzed, removed, or inserted as necessary. Output classes can be saved into files, or loaded dynamically by a ClassLoader.

Website: http://asm.ow2.org/

Document: ASM 4.0 A Java bytecode engineering library

798 questions
0
votes
2 answers

Java asm get "this" object from method variables

I need to know the name of the object which called invokevirtual operation(in the following format - Objectname@object_id). Is it possible given only MethodInsnNode object? I know that it is stored with the index 0 in local variables but I don't…
Sergey
  • 11,548
  • 24
  • 76
  • 113
0
votes
1 answer

How can I copy opcodes from a method to another method in Java Class file using ASM?

Here are some code. static synchronized void q(ua paramua, int paramInt) { try { if (d) { if (paramInt > -16711936); return; } if (q * 514194583 > 0) { if (paramInt > -16711936); abf localabf = new abf(paramua); n.d(localabf,…
SkyDragon
  • 11
  • 1
0
votes
1 answer

adding extra codes at runtime in java

I am developing a library and I need to add extra codes to some of my methods of my objects at run time. there are two points here. first of all, the program I wanted to add extra code, is written before by some body else, and I don't wanted to edit…
saman
  • 199
  • 4
  • 17
0
votes
2 answers

ASM COMPUTE_MAXS not working for basic test case?

At the bottom of the post is the test case. It gives the following error. But I have set new ClassWriter(ClassWriter.COMPUTE_MAXS) so shouldn't it be automatically calculating the max stack and setting it properly? Exception in thread "main"…
mentics
  • 6,852
  • 5
  • 39
  • 93
-1
votes
1 answer

Is there any tool to generate the ASM ClassWriter code?

I want to create dynamic java classes, I use a template to generate the source code, and then use jasper jdt to compile. But now, I want to remove the dependency for jdt and create class bytecode with ASM directly. The source code is about 200…
-1
votes
1 answer

How can I load classes into an running Java Programm

This is the code of my Agent.jar public class Agent { public static void agentmain(String s, Instrumentation instrumentation) { try { ClassLoader classLoader = null; for (Class clazz :…
BlueCodeZ
  • 17
  • 2
-1
votes
2 answers

if local variables cant be tested then what other ways can the variable values be checked

This is going to be a long question, driven by the thirst of wanting to know how something is working against the conventional methodologies. I came across a very interesting application codeacademy, that was actually testing the local variables…
isnvi23h4
  • 1,910
  • 1
  • 27
  • 45
-1
votes
1 answer

ASM Bytecode to identify for / while loops

Using ASM Bytecode Can we identify for loops or while loops present in the method body?
Ramesh Subramanian
  • 944
  • 1
  • 12
  • 28
-1
votes
6 answers

How to replace a method return type?

This is just a learning experiment for fun. I'm toying with bytecode manipulation. I'm just messing around for learning with asm in java. I wonder if it is possible to replace the return type of a method from an interface. Let's say that I have an…
ssedano
  • 8,322
  • 9
  • 60
  • 98
-1
votes
1 answer

A java Agent to inspect all JVM running classes?

I am trying do an academic project on BCI and JavaAssist. I would be glad if anyone could help me with these: Is it possible to build a java agent which can inspect/control all classes running currently in the JVM? Is it possible to build a java…
-2
votes
1 answer

Int switch error when inject code generator with switch case in java code

Caused by: java.lang.AssertionError at com.android.tools.r8.ir.code.IntSwitch.valid(IntSwitch.java:67) at com.android.tools.r8.ir.code.IntSwitch.(IntSwitch.java:35) at…
-2
votes
1 answer

ASM Byte Code override method scoped var near end of method

I can't just replace the entire method. I have to just inject a reassignment of a local var after the last time it normally gets set but before it gets used near the end of the method. Here's some pseudocode void test() { /* stuff */ String thing…
vaps
  • 57
  • 5
-2
votes
2 answers

java 8 constant pool constant dependency

Let's say I defined a constant int in file A.java: public final static int CONSTAN_VALUE_IN_A = 0; when I use this value in another file B.java: int fooBValue = A.CONSTAN_VALUE_IN_A; after I compiled my project, in B.class,I have: fooBValue = 0 I…
-2
votes
1 answer

Java reverse all Strings in a Jar with ASM

I tried to make a program that reverse every string in a jar and then do the same again, to make it be like a string obfuscation. eg. Normal Code: new String("example"); After running: new String(new…
Aura Lee
  • 416
  • 3
  • 11
-3
votes
1 answer

Is it possible to fake missing classes using ClassLoader?

I'm loading in classes from a JAR that implement an interface from a public API. The interface itself will remain constant but other classes associated with the API may change over time. Clearly once the API changes we will no longer be able to…
1 2 3
53
54