I was looking at the byteman implementation to understand how they work specifically for cases like tracking variables AT/AFTER nth read, AT/AFTER nth write etc. In their implementation they read a class two times once for checking if it matches with the Rule specified by the user using RuleCheckMethodAdapter and second time for actually injecting the bytecode (trigger) at the interested place in the class using RuleTriggerAdapter. What I failed to understand is why do we need 2 passes, Why can't in the first pass itself we could add the trigger if there is a match with the rule? Any insights on the same would be helpful.
Byteman Implementation Details
130 Views Asked by Sumit Maheshwari At
1
There are 1 best solutions below
Related Questions in BYTECODE-MANIPULATION
- Java bytecode not in .class file
- How to inject a method into a class at runtime without ASM?
- How is string concatenation handled in Java bytecode compilation?
- How to create a transforming class loader
- How to change class reference of a class in the constant pool using ASM library?
- Detect modified bytecode at runtime
- Use java agent with manipulated java bytecode (ASM)
- Java ASM bytecode manipulation - add code to constructor of a library class
- Java ASM ClassReader fails with java.io.IOException: Class not found
- Java ASM: Bad local variable type (dload) Type top (current frame, locals[5]) is not assignable to double
- Use proxies with Hibernate runtime bytecode enhancement
- Java Agent "java.lang.UnsupportedOperationException: class redefinition failed: attempted to change method modifiers"
- Encoding a .json file for a bytecode vm
- Exchange testInstrumentationRunner with a runner derived from class not available at compile time
- visitMethod in MethodVisitor ASM not visiting method in Scala
Related Questions in BYTEMAN
- Getting runtime exception with COMPILE option
- Byteman: Location Specifiers not working on APIs of List/Maps
- Importing multiple rules files
- org.jboss.byteman.agent.Transformer : invalid text outside of RULE/ENDRULE at line 1 in script
- Byteman on native methods
- byteman rule: return 10.001, got invalid expression error
- How to resovle this deadlock problem when i instrument some codes {sleep(10)} in java.util.ArrayList.size()?
- java.lang.Exception: BMUnit method configuration pushed without prior method configuration pop
- How to set environment setting?
- How to throw exception using Byteman Script , in a method?
- bmsubmit is not working due to Bad Request 400. Why?
- The remote byteman agent reported an error
- how to inject rule script into java.sql.Statement.executeQuery(String)?
- How to crash Jboss based on some condition
- Can byteman trigger a rule on a lambda?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
All the injection stages for all location types use two passes. The first pass is a verification step that ensures the location actually matches the code at a specific point in the method bytecode. It records information needed to allow injection to be performed appropriately for that location and saves it for use by the second pass. n.b. this first stage is invariably a very cheap and quick code scan.
The second stage tracks a lot more information about the code structure, abstract machine stack layouts and types, etc. This is partly to ensure that it does the injection correctly but it also has to do a lot of work to ensure that it can correctly route exceptions out of the injected regions. There is no point incurring this overhead until it is clear that the rule applies.