当前位置: 首页>>代码示例>>Java>>正文


Java Opcodes.GETSTATIC属性代码示例

本文整理汇总了Java中org.objectweb.asm.Opcodes.GETSTATIC属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.GETSTATIC属性的具体用法?Java Opcodes.GETSTATIC怎么用?Java Opcodes.GETSTATIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.objectweb.asm.Opcodes的用法示例。


在下文中一共展示了Opcodes.GETSTATIC属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMethod

@Override
public MethodVisitor visitMethod(int access, String name, String desc,
                                 String signature, String[] exceptions) {
    if (attemptToVisitR) return null;
    return new MethodVisitor(Opcodes.ASM5, null) {

        @Override
        public void visitFieldInsn(int opcode, String owner, String fieldName,
                                   String fieldDesc) {

            if (attemptToVisitR
                    || opcode != Opcodes.GETSTATIC
                    || owner.startsWith("java/lang/")) {
                return;
            }

            attemptToVisitR = isRClass(owner);
        }
    };
}
 
开发者ID:yrom,项目名称:shrinker,代码行数:20,代码来源:PredicateClassVisitor.java

示例2: visitFieldInsn

@Override
public void visitFieldInsn(final int opcode, final String owner,
        final String name, final String desc) {
    switch (opcode) {
    case Opcodes.GETSTATIC:
        getstatic(owner, name, desc);
        break;
    case Opcodes.PUTSTATIC:
        putstatic(owner, name, desc);
        break;
    case Opcodes.GETFIELD:
        getfield(owner, name, desc);
        break;
    case Opcodes.PUTFIELD:
        putfield(owner, name, desc);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:20,代码来源:InstructionAdapter.java

示例3: visitFieldInsn

@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
  DexField field = application.getField(owner, name, desc);
  switch (opcode) {
    case Opcodes.GETFIELD:
      registry.registerInstanceFieldRead(field);
      break;
    case Opcodes.PUTFIELD:
      registry.registerInstanceFieldWrite(field);
      break;
    case Opcodes.GETSTATIC:
      registry.registerStaticFieldRead(field);
      break;
    case Opcodes.PUTSTATIC:
      registry.registerStaticFieldWrite(field);
      break;
    default:
      throw new Unreachable("Unexpected opcode " + opcode);
  }
}
 
开发者ID:inferjay,项目名称:r8,代码行数:20,代码来源:JarRegisterEffectsVisitor.java

示例4: updateState

private void updateState(FieldInsnNode insn) {
  Type type = Type.getType(insn.desc);
  switch (insn.getOpcode()) {
    case Opcodes.GETSTATIC:
      state.push(type);
      break;
    case Opcodes.PUTSTATIC:
      state.pop();
      break;
    case Opcodes.GETFIELD: {
      state.pop(JarState.OBJECT_TYPE);
      state.push(type);
      break;
    }
    case Opcodes.PUTFIELD: {
      state.pop();
      state.pop(JarState.OBJECT_TYPE);
      break;
    }
    default:
      throw new Unreachable("Unexpected FieldInsn opcode: " + insn.getOpcode());
  }
}
 
开发者ID:inferjay,项目名称:r8,代码行数:23,代码来源:JarSourceCode.java

示例5: SkillsHook

public SkillsHook() {
	super(new Regex(
			new Instruction(Opcodes.GETSTATIC, true),
			new Instruction(Opcodes.ALOAD, false),
			new Instruction(Opcodes.ILOAD, false),
			new Instruction(Opcodes.IINC, false),
			new Instruction(Opcodes.IALOAD, false),
			new Instruction(Opcodes.IALOAD, false),
			new Instruction(Opcodes.ISTORE, false),
			new Instruction(Opcodes.ILOAD, false),
			new Or(new Instruction(Opcodes.ICONST_2, false), new Instruction(Opcodes.IF_ICMPNE, false), false),
			new Or(new Instruction(Opcodes.ICONST_2, false), new Instruction(Opcodes.IF_ICMPNE, false), false),
			new Instruction(Opcodes.GETSTATIC, true),
			new Instruction(Opcodes.ALOAD, false),
			new Instruction(Opcodes.ILOAD, false),
			new Instruction(Opcodes.IINC, false),
			new Instruction(Opcodes.IALOAD, false),
			new Instruction(Opcodes.IALOAD, false),
			new Instruction(Opcodes.ISTORE, false),
			new Or(new Instruction(Opcodes.ILOAD, false), new Instruction(Opcodes.ICONST_3, false), false),
			new Or(new Instruction(Opcodes.ILOAD, false), new Instruction(Opcodes.ICONST_3, false), false),
			new Instruction(Opcodes.IF_ICMPNE, false),
			new Instruction(Opcodes.GETSTATIC, true)
		));
}
 
开发者ID:jonathanedgecombe,项目名称:mithril,代码行数:25,代码来源:SkillsHook.java

示例6: visitFieldInsn

/**
 * Imports field instructions (put and get), both for static and instance
 * fields.
 *
 * @param opcode Opcode.
 * @param owner  Class containing the field.
 * @param name   Name of field.
 * @param desc   Type descriptor of field.
 */
@Override
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
  Field f = ClassNode.getClass(owner).getField(name, desc);

  if(((opcode == Opcodes.GETSTATIC) || (opcode == Opcodes.PUTSTATIC)) !=
          f.getModifiers().contains(Modifier.STATIC)) {
    throw new RuntimeException("Field staticness conflicts with instruction");
  }

  switch(opcode) {
    // Loads
    case Opcodes.GETSTATIC:
    case Opcodes.GETFIELD:  createFieldRead(f);  break;
    // Stores
    case Opcodes.PUTSTATIC:
    case Opcodes.PUTFIELD:  createFieldWrite(f); break;
  }
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:27,代码来源:MethodImporter.java

示例7: onMethodEnter

@SuppressWarnings("unused")
protected void onMethodEnter() {
	if (done) return;

	overridden = true;
	Label start  = new Label();
	Label normal = new Label();
	super.visitLabel(start);
	super.visitFieldInsn(Opcodes.GETSTATIC, CONFIGURATION, CONFIGURATION_FIELD_NAME, Type.INT_TYPE.getDescriptor());
	super.visitInsn(Opcodes.DUP);
	super.visitJumpInsn(Opcodes.IFEQ, normal);
	super.visitInsn(Opcodes.IRETURN);
	super.visitLabel(normal);
	super.visitInsn(Opcodes.POP);
	Label end = new Label();
	super.visitJumpInsn(Opcodes.GOTO, end);
	super.visitLabel(end);
	super.visitTryCatchBlock(start, normal, end, Type.getType(Throwable.class).getDescriptor());
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:19,代码来源:RuntimeInstrument.java

示例8: visitFieldInsn

@Override
public void visitFieldInsn(int opcode, String originalType, String originalName, String desc)
{
    // This method solves the problem of a static field reference changing type. In all probability it is a
    // compatible change, however we need to fix up the desc to point at the new type
    String type = remapper.mapType(originalType);
    String fieldName = remapper.mapFieldName(originalType, originalName, desc);
    String newDesc = remapper.mapDesc(desc);
    if (opcode == Opcodes.GETSTATIC && type.startsWith("net/minecraft/") && newDesc.startsWith("Lnet/minecraft/"))
    {
        String replDesc = FMLDeobfuscatingRemapper.INSTANCE.getStaticFieldType(originalType, originalName, type, fieldName);
        if (replDesc != null)
        {
            newDesc = remapper.mapDesc(replDesc);
        }
    }
    // super.super
    if (mv != null) {
        mv.visitFieldInsn(opcode, type, fieldName, newDesc);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:FMLRemappingAdapter.java

示例9: visitMethod

@Override
public MethodVisitor visitMethod(int access, String name, String desc,
                                 String signature, String[] exceptions) {
    return new MethodVisitor(Opcodes.ASM5,
            super.visitMethod(access, name, desc, signature, exceptions)) {

        @Override
        public void visitFieldInsn(int opcode, String owner, String fieldName,
                                   String fieldDesc) {
            if (opcode != Opcodes.GETSTATIC || owner.startsWith("java/lang/")) {
                // skip!
                this.mv.visitFieldInsn(opcode, owner, fieldName, fieldDesc);
                return;
            }
            String typeName = owner.substring(owner.lastIndexOf('/') + 1);
            String key = typeName + '.' + fieldName;
            if (rSymbols.containsKey(key)) {
                Integer value = rSymbols.get(key);
                if (value == null)
                    throw new UnsupportedOperationException("value of " + key + " is null!");
                if (logger.isEnabled(LogLevel.DEBUG)) {
                    logger.debug("replace {}.{} to 0x{}", owner, fieldName, Integer.toHexString(value));
                }
                pushInt(this.mv, value);
            } else if (owner.endsWith("/R$styleable")) { // replace all */R$styleable ref!
                this.mv.visitFieldInsn(opcode, RSymbols.R_STYLEABLES_CLASS_NAME, fieldName, fieldDesc);
            } else {
                this.mv.visitFieldInsn(opcode, owner, fieldName, fieldDesc);
            }
        }
    };
}
 
开发者ID:yrom,项目名称:shrinker,代码行数:32,代码来源:ShrinkRClassVisitor.java

示例10: CanvasHook

public CanvasHook() {
	super(new Regex(
			new Instruction(Opcodes.GOTO, false),
			new Instruction(Opcodes.GETSTATIC, true),
			new Instruction(Opcodes.CHECKCAST, false),
			new Instruction(Opcodes.ALOAD, false),
			new Instruction(Opcodes.GETFIELD, false),
			new Instruction(Opcodes.LDC, false),
			new Instruction(Opcodes.INVOKEVIRTUAL, true),
			new Instruction(Opcodes.GOTO, false)
		));
}
 
开发者ID:jonathanedgecombe,项目名称:mithril,代码行数:12,代码来源:CanvasHook.java

示例11: visitFieldInsn

public void visitFieldInsn(int opcode, String owner, String fieldName,
		String desc) {
	if (firstInstruction)
		addInc();
	if (logPointerChange && opcode == Opcodes.PUTFIELD
			&& desc.charAt(0) == 'L') {
		if (constructor && !doneSuperConstructor && name.equals(owner)
				&& finalFields.contains(fieldName))
			delayedFieldPointer.put(fieldName, desc);
		else {
			// instrument reference changes from
			// putfield ...,obj,v' => ...
			// to
			// dup2 ...,obj,v' => ...,obj,v',obj,v'
			// swap ...,obj,v',obj,v' => ...,obj,v',v',obj
			// dup ...,obj,v',v',obj => ...,obj,v',v',obj,obj
			// getfield ...,obj,v',v',obj,obj => ...,obj,v',v',obj,v
			// invokespecial
			// pointerchangelog(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
			// ...,obj,v',v',obj,v => ...,obj,v'
			// putfield ...,obj,v' =>
			super.visitInsn(Opcodes.DUP2);
			super.visitInsn(Opcodes.SWAP);
			super.visitInsn(Opcodes.DUP);
			super.visitFieldInsn(Opcodes.GETFIELD, owner, fieldName,
					desc);
			super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
					LOG_INTERNAL_POINTER_CHANGE,
					POINTER_CHANGE_SIGNATURE);
		}
	} else if (logPointerChange && opcode == Opcodes.PUTSTATIC
			&& desc.charAt(0) == 'L') {
		// if (finalFields.contains(fieldName)) {
		// // assume field is initially null
		// super.visitInsn(Opcodes.DUP);
		// } else {
		// instrument reference changes from
		// putstatic ...,v' => ...
		// to
		// dup ...,v' => ...,v',v'
		// ldc owner.class ...,v',v' => ...,v',v',k
		// getstatic ...,v',v',k => ...,v',v',k,v
		// invokespecial
		// staticpointerchangelog(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Object;)V
		// ...,v',v',k,v => ...,v'
		super.visitInsn(Opcodes.DUP);
		super.visitLdcInsn(Type.getObjectType(owner));
		super.visitFieldInsn(Opcodes.GETSTATIC, owner, fieldName, desc);
		super.visitMethodInsn(Opcodes.INVOKESTATIC, name,
				LOG_INTERNAL_STATIC_POINTER_CHANGE,
				STATIC_POINTER_CHANGE_SIGNATURE);
		// }
	}
	super.visitFieldInsn(opcode, owner, fieldName, desc);
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:55,代码来源:AllocateInstrument.java

示例12: canThrow

private boolean canThrow(AbstractInsnNode insn) {
  switch (insn.getOpcode()) {
    case Opcodes.AALOAD:
    case Opcodes.AASTORE:
    case Opcodes.ANEWARRAY:
      // ARETURN does not throw in its dex image.
    case Opcodes.ARRAYLENGTH:
    case Opcodes.ATHROW:
    case Opcodes.BALOAD:
    case Opcodes.BASTORE:
    case Opcodes.CALOAD:
    case Opcodes.CASTORE:
    case Opcodes.CHECKCAST:
    case Opcodes.DALOAD:
    case Opcodes.DASTORE:
      // DRETURN does not throw in its dex image.
    case Opcodes.FALOAD:
    case Opcodes.FASTORE:
      // FRETURN does not throw in its dex image.
    case Opcodes.GETFIELD:
    case Opcodes.GETSTATIC:
    case Opcodes.IALOAD:
    case Opcodes.IASTORE:
    case Opcodes.IDIV:
    case Opcodes.INSTANCEOF:
    case Opcodes.INVOKEDYNAMIC:
    case Opcodes.INVOKEINTERFACE:
    case Opcodes.INVOKESPECIAL:
    case Opcodes.INVOKESTATIC:
    case Opcodes.INVOKEVIRTUAL:
    case Opcodes.IREM:
      // IRETURN does not throw in its dex image.
    case Opcodes.LALOAD:
    case Opcodes.LASTORE:
    case Opcodes.LDIV:
    case Opcodes.LREM:
      // LRETURN does not throw in its dex image.
    case Opcodes.MONITORENTER:
    case Opcodes.MONITOREXIT:
    case Opcodes.MULTIANEWARRAY:
    case Opcodes.NEW:
    case Opcodes.NEWARRAY:
    case Opcodes.PUTFIELD:
    case Opcodes.PUTSTATIC:
      // RETURN does not throw in its dex image.
    case Opcodes.SALOAD:
    case Opcodes.SASTORE:
      return true;
    case Opcodes.LDC: {
      // const-class and const-string* may throw in dex.
      LdcInsnNode ldc = (LdcInsnNode) insn;
      return ldc.cst instanceof String || ldc.cst instanceof Type;
    }
    default:
      return false;
  }
}
 
开发者ID:inferjay,项目名称:r8,代码行数:57,代码来源:JarSourceCode.java

示例13: isFieldRead

private boolean isFieldRead(int opcode) {
	return opcode == Opcodes.GETFIELD || opcode == Opcodes.GETSTATIC;
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:3,代码来源:Result.java

示例14: overclockServer

private static void overclockServer(ClassNode node, boolean isObfuscated)
{
    // We're attempting to replace this code (from the heart of MinecraftServer.run):
    /*       
        {
            while (i > 50L)
            {
                i -= 50L;
                this.tick();
            }
        }

        Thread.sleep(Math.max(1L, 50L - i));
    */

    // With this:
    /*       
    {
        while (i > TimeHelper.serverTickLength)
        {
            i -= TimeHelper.serverTickLength;
            this.tick();
        }
    }

    Thread.sleep(Math.max(1L, TimeHelper.serverTickLength - i));
*/
    // This allows us to alter the tick length via TimeHelper.
    
    final String methodName = "run";
    final String methodDescriptor = "()V"; // No params, returns void.

    System.out.println("MALMO: Found MinecraftServer, attempting to transform it");

    for (MethodNode method : node.methods)
    {
        if (method.name.equals(methodName) && method.desc.equals(methodDescriptor))
        {
            System.out.println("MALMO: Found MinecraftServer.run() method, attempting to transform it");
            for (AbstractInsnNode instruction : method.instructions.toArray())
            {
                if (instruction.getOpcode() == Opcodes.LDC)
                {
                    Object cst = ((LdcInsnNode)instruction).cst;
                    if ((cst instanceof Long) && (Long)cst == 50)
                    {
                        System.out.println("MALMO: Transforming LDC");
                        AbstractInsnNode replacement = new FieldInsnNode(Opcodes.GETSTATIC, "com/microsoft/Malmo/Utils/TimeHelper", "serverTickLength", "J");
                        method.instructions.set(instruction, replacement);
                    }
                }
            }
        }
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:55,代码来源:OverclockingClassTransformer.java


注:本文中的org.objectweb.asm.Opcodes.GETSTATIC属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。