Coder Social home page Coder Social logo

Instrumenting constructors fails with VerificationError when interacting with classes that lack stack map frames about allocation-instrumenter HOT 10 CLOSED

kyle-cackett avatar kyle-cackett commented on June 25, 2024
Instrumenting constructors fails with VerificationError when interacting with classes that lack stack map frames

from allocation-instrumenter.

Comments (10)

jhmanson avatar jhmanson commented on June 25, 2024 2

Yeah, I think that was just a mistake - we do the right thing in the AllocationInstrumenter class. I'll push a fix. Thanks for reporting it.

from allocation-instrumenter.

kyle-cackett avatar kyle-cackett commented on June 25, 2024

Minimal reproducible example can be found here: https://github.com/kyle-cackett/class-instrumentation

from allocation-instrumenter.

kyle-cackett avatar kyle-cackett commented on June 25, 2024

@jhmanson do you have an idea of when you think this fix will be pushed? This issue is keeping us from moving to Java 8 so we're trying to decide whether to wait for a fix upstream or fork the library and apply the patch below:

a/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java b/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java
index 933d4c4..e53ed5a 100644
--- a/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java
+++ b/src/main/java/com/google/monitoring/runtime/instrumentation/ConstructorInstrumenter.java
@@ -116,7 +116,7 @@ public class ConstructorInstrumenter implements ClassFileTransformer {
   public static byte[] instrument(byte[] originalBytes, Class<?> classBeingRedefined) {
     try {
       ClassReader cr = new ClassReader(originalBytes);
-      ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
+      ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES);
       VerifyingClassAdapter vcw = new VerifyingClassAdapter(cw, originalBytes, cr.getClassName());
       ClassVisitor adapter = new ConstructorClassAdapter(vcw, classBeingRedefined);

from allocation-instrumenter.

jhmanson avatar jhmanson commented on June 25, 2024

Sorry about that. I pushed the patch internally, and then my machine died, so it fell off my radar. I can push it tomorrow morning.

from allocation-instrumenter.

jhmanson avatar jhmanson commented on June 25, 2024

All done!

from allocation-instrumenter.

kyle-cackett avatar kyle-cackett commented on June 25, 2024

Thank you!

from allocation-instrumenter.

kyle-cackett avatar kyle-cackett commented on June 25, 2024

@jhmanson Do you have any plans for an upcoming release which will contain this fix? We'd like to depend on an official version if possible.

from allocation-instrumenter.

jhmanson avatar jhmanson commented on June 25, 2024

Hm... I think I don't have the right permissions to release to sonatype etc. Maybe @cushon or @cgdecker can help?

from allocation-instrumenter.

kyle-cackett avatar kyle-cackett commented on June 25, 2024

@cushon @cgdecker Do you have a sense for when we might expect a new release of the allocation instrumenter containing this fix?

from allocation-instrumenter.

cgdecker avatar cgdecker commented on June 25, 2024

Sorry for the long delay... I've released java-allocation-instrumenter 3.3.0 to Maven Central with this fix.

from allocation-instrumenter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.