Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have found need to do pretty much the exact same thing on a project of mine. You might want to take a look at the source code <a href="http://code.google.com/p/mutability-detector/source/browse/trunk/MutabilityDetector/trunk/MutabilityDetector/src/main/java/org/mutabilitydetector/checkers/FieldAssignmentVisitor.java" rel="nofollow noreferrer">here</a> (in the <code>visitEnd()</code> method). It uses an <code>Analyzer</code> from the ASM project to take a 'snapshot' of the stack frame at the time of a <code>PUTFIELD</code> instruction. Those snapshots are then stored, and can be retrieved once the visitor has finished, part of the information contained in the snapshot is the type of reference at the top of the stack.</p> <p>The particular class linked to above is designed to be subclassed, an example of a subclass is <a href="http://code.google.com/p/mutability-detector/source/browse/trunk/MutabilityDetector/trunk/MutabilityDetector/src/main/java/org/mutabilitydetector/checkers/MutableTypeToFieldChecker.java" rel="nofollow noreferrer">here</a> (check out <code>visitMethod()</code>). At the time I needed to do this, I turned to StackOverflow too, you may want to check out <a href="https://stackoverflow.com/questions/1852758/how-to-inspect-the-stack-using-an-asm-visitor">the question I asked at the time</a>, particularly the link <a href="http://www.jroller.com/eu/entry/method_code_analyzis_with_asm" rel="nofollow noreferrer">provided in the accepted answer</a>, which provided the basis of the code I eventually used.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload