forked from raphw/byte-buddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved support for pre-Java 5 byte code.
- Loading branch information
Showing
24 changed files
with
400 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ep/src/main/java/net/bytebuddy/implementation/bytecode/constant/JavaInstanceConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package net.bytebuddy.implementation.bytecode.constant; | ||
|
||
import net.bytebuddy.implementation.Implementation; | ||
import net.bytebuddy.implementation.bytecode.StackManipulation; | ||
import net.bytebuddy.implementation.bytecode.StackSize; | ||
import net.bytebuddy.utility.JavaInstance; | ||
import org.objectweb.asm.MethodVisitor; | ||
|
||
/** | ||
* A constant representing a {@link JavaInstance}. | ||
*/ | ||
public class JavaInstanceConstant implements StackManipulation { | ||
|
||
/** | ||
* The instance to load onto the operand stack. | ||
*/ | ||
private final JavaInstance javaInstance; | ||
|
||
/** | ||
* Creates a constant pool value representing a {@link JavaInstance}. | ||
* | ||
* @param javaInstance The instance to load onto the operand stack. | ||
*/ | ||
public JavaInstanceConstant(JavaInstance javaInstance) { | ||
this.javaInstance = javaInstance; | ||
} | ||
|
||
@Override | ||
public boolean isValid() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { | ||
methodVisitor.visitLdcInsn(javaInstance.asConstantPoolValue()); | ||
return StackSize.SINGLE.toIncreasingSize(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return this == other || !(other == null || getClass() != other.getClass()) | ||
&& javaInstance.equals(((JavaInstanceConstant) other).javaInstance); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return javaInstance.hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "JavaInstanceConstant{javaInstance=" + javaInstance + '}'; | ||
} | ||
} |
Oops, something went wrong.