Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Byte Buddy is a Java library for creating Java classes at run time.
This artifact is a build of Byte Buddy with a remaining dependency onto ASM.
You should never depend on this module without repackaging Byte Buddy and ASM into your own namespace.
/*
* Copyright 2014 - Present Rafael Winterhalter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.bytebuddy.utility.visitor;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.build.AccessControllerPlugin;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.implementation.bytecode.StackSize;
import net.bytebuddy.utility.CompoundList;
import net.bytebuddy.utility.OpenedClassReader;
import net.bytebuddy.utility.nullability.MaybeNull;
import net.bytebuddy.utility.privilege.GetSystemPropertyAction;
import org.objectweb.asm.*;
import java.security.PrivilegedAction;
import java.util.*;
/**
*
* A method visitor that is aware of the current size of the operand stack at all times. Additionally, this method takes
* care of maintaining an index for the next currently unused index of the local variable array.
*
*
* Important: It is not always possible to apply this method visitor if it is applied to a class file compiled
* for Java 5 or earlier, or if frames are computed by ASM and not passed to this visitor, if a method also contains
* {@link Opcodes#GOTO} instructions. In the latter case, the stack is assumed empty after the instruction. If this
* is a problem, stack adjustment can be disabled by setting {@link StackAwareMethodVisitor#UNADJUSTED_PROPERTY} to
* {@code true}. With this setting, Byte Buddy does no longer attempt draining non-empty stacks and skips this visitor
* in all cases. This might however lead to verification problems if stacks are left non-empty. As the latter happens
* more common and since this visitor is applied defensively, using this wrapper is considered the more sensible default.
*
*/
public class StackAwareMethodVisitor extends MethodVisitor {
/**
* A property to disable stack adjustment. Stack adjustment is typically needed when instrumenting other
* generated code that leaves excess values on the stack. This is also often the case when byte code
* obfuscation is used.
*/
public static final String UNADJUSTED_PROPERTY = "net.bytebuddy.unadjusted";
/**
* {@code true} if stack adjustment is disabled.
*/
public static final boolean UNADJUSTED;
/*
* Reads the raw type property.
*/
static {
boolean disabled;
try {
disabled = Boolean.parseBoolean(doPrivileged(new GetSystemPropertyAction(UNADJUSTED_PROPERTY)));
} catch (Exception ignored) {
disabled = false;
}
UNADJUSTED = disabled;
}
/**
* An array mapping any opcode to its size impact onto the operand stack. This mapping is taken from
* {@link org.objectweb.asm.Frame} with the difference that the {@link Opcodes#JSR} instruction is
* mapped to a size of {@code 0} as it does not impact the stack after returning from the instruction.
*/
private static final int[] SIZE_CHANGE;
/*
* Computes a mapping of byte codes to their size impact onto the operand stack.
*/
static {
SIZE_CHANGE = new int[202];
String encoded = "EFFFFFFFFGGFFFGGFFFEEFGFGFEEEEEEEEEEEEEEEEEEEEDEDEDDDDDCD" +
"CDEEEEEEEEEEEEEEEEEEEEBABABBBBDCFFFGGGEDCDCDCDCDCDCDCDCDCDCEEEEDDD" +
"DDDDCDCDCEFEFDDEEFFDEDEEEBDDBBDDDDDDCCCCCCCCEEEDDDCDCDEEEEEEEEEEFE" +
"EEEEEDDEEDDEE";
for (int index = 0; index < SIZE_CHANGE.length; index++) {
SIZE_CHANGE[index] = encoded.charAt(index) - 'E';
}
}
/**
* A list of the current elements on the operand stack.
*/
private List current;
/**
* A mapping of labels to the operand stack size that is expected at this label. Lists stored in this
* map must not be mutated.
*/
private final Map