javassist.bytecode.Bytecode.addCheckcast()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中javassist.bytecode.Bytecode.addCheckcast()方法的一些代码示例,展示了Bytecode.addCheckcast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.addCheckcast()方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:addCheckcast

Bytecode.addCheckcast介绍

[英]Appends CHECKCAST.
[中]附加CHECKCAST。

代码示例

代码示例来源:origin: redisson/redisson

private static void addUnwrapper(Bytecode code, Class type) {
  if (type.isPrimitive()) {
    if (type == Void.TYPE)
      code.addOpcode(Opcode.POP);
    else {
      int index = FactoryHelper.typeIndex(type);
      String wrapper = FactoryHelper.wrapperTypes[index];
      code.addCheckcast(wrapper);
      code.addInvokevirtual(wrapper,
                 FactoryHelper.unwarpMethods[index],
                 FactoryHelper.unwrapDesc[index]);
    }
  }
  else       
    code.addCheckcast(type.getName());
}

代码示例来源:origin: org.javassist/javassist

private static void addUnwrapper(Bytecode code, Class<?> type) {
  if (type.isPrimitive()) {
    if (type == Void.TYPE)
      code.addOpcode(Opcode.POP);
    else {
      int index = FactoryHelper.typeIndex(type);
      String wrapper = FactoryHelper.wrapperTypes[index];
      code.addCheckcast(wrapper);
      code.addInvokevirtual(wrapper,
                 FactoryHelper.unwarpMethods[index],
                 FactoryHelper.unwrapDesc[index]);
    }
  }
  else       
    code.addCheckcast(type.getName());
}

代码示例来源:origin: hibernate/hibernate-orm

private void addUnwrapper(Bytecode code, Class type) {
  final int index = FactoryHelper.typeIndex( type );
  final String wrapperType = FactoryHelper.wrapperTypes[index];
  // checkcast
  code.addCheckcast( wrapperType );
  // invokevirtual
  code.addInvokevirtual( wrapperType, FactoryHelper.unwarpMethods[index], FactoryHelper.unwrapDesc[index] );
}

代码示例来源:origin: redisson/redisson

private static void compileReturn(Bytecode code, CtClass type) {
    if (type.isPrimitive()) {
      CtPrimitiveType pt = (CtPrimitiveType)type;
      if (pt != CtClass.voidType) {
        String wrapper = pt.getWrapperName();
        code.addCheckcast(wrapper);
        code.addInvokevirtual(wrapper, pt.getGetMethodName(),
                   pt.getGetMethodDescriptor());
      }

      code.addOpcode(pt.getReturnOp());
    }
    else {
      code.addCheckcast(type);
      code.addOpcode(Bytecode.ARETURN);
    }
  }
}

代码示例来源:origin: redisson/redisson

protected void compileUnwrapValue(CtClass type, Bytecode code)
  throws CompileError
{
  if (type == CtClass.voidType) {
    addNullIfVoid();
    return;
  }
  if (exprType == VOID)
    throw new CompileError("invalid type for " + returnCastName);
  if (type instanceof CtPrimitiveType) {
    CtPrimitiveType pt = (CtPrimitiveType)type;
    // pt is not voidType.
    String wrapper = pt.getWrapperName();
    code.addCheckcast(wrapper);
    code.addInvokevirtual(wrapper, pt.getGetMethodName(),
               pt.getGetMethodDescriptor());
    setType(type);
  }
  else {
    code.addCheckcast(type);
    setType(type);
  }
}

代码示例来源:origin: redisson/redisson

public void atCastExpr(CastExpr expr) throws CompileError {
  String cname = resolveClassName(expr.getClassName());
  String toClass = checkCastExpr(expr, cname);
  int srcType = exprType;
  exprType = expr.getType();
  arrayDim = expr.getArrayDim();
  className = cname;
  if (toClass == null)
    atNumCastExpr(srcType, exprType);   // built-in type
  else
    bytecode.addCheckcast(toClass);
}

代码示例来源:origin: org.javassist/javassist

private static void compileReturn(Bytecode code, CtClass type) {
    if (type.isPrimitive()) {
      CtPrimitiveType pt = (CtPrimitiveType)type;
      if (pt != CtClass.voidType) {
        String wrapper = pt.getWrapperName();
        code.addCheckcast(wrapper);
        code.addInvokevirtual(wrapper, pt.getGetMethodName(),
                   pt.getGetMethodDescriptor());
      }

      code.addOpcode(pt.getReturnOp());
    }
    else {
      code.addCheckcast(type);
      code.addOpcode(Bytecode.ARETURN);
    }
  }
}

代码示例来源:origin: org.javassist/javassist

protected void compileUnwrapValue(CtClass type, Bytecode code)
  throws CompileError
{
  if (type == CtClass.voidType) {
    addNullIfVoid();
    return;
  }
  if (exprType == VOID)
    throw new CompileError("invalid type for " + returnCastName);
  if (type instanceof CtPrimitiveType) {
    CtPrimitiveType pt = (CtPrimitiveType)type;
    // pt is not voidType.
    String wrapper = pt.getWrapperName();
    code.addCheckcast(wrapper);
    code.addInvokevirtual(wrapper, pt.getGetMethodName(),
               pt.getGetMethodDescriptor());
    setType(type);
  }
  else {
    code.addCheckcast(type);
    setType(type);
  }
}

代码示例来源:origin: org.javassist/javassist

@Override
public void atCastExpr(CastExpr expr) throws CompileError {
  String cname = resolveClassName(expr.getClassName());
  String toClass = checkCastExpr(expr, cname);
  int srcType = exprType;
  exprType = expr.getType();
  arrayDim = expr.getArrayDim();
  className = cname;
  if (toClass == null)
    atNumCastExpr(srcType, exprType);   // built-in type
  else
    bytecode.addCheckcast(toClass);
}

代码示例来源:origin: hibernate/hibernate-orm

code.addCheckcast( this.targetBean.getName() );

代码示例来源:origin: hibernate/hibernate-orm

code.addCheckcast( this.targetBean.getName() );
    code.addCheckcast( setterParamType.getName() );

代码示例来源:origin: fakereplace/fakereplace

public static Bytecode unboxInt(Bytecode bc) {
  bc.addCheckcast("java.lang.Number");
  bc.addInvokevirtual("java.lang.Number", "intValue", "()I");
  return bc;
}

代码示例来源:origin: fakereplace/fakereplace

public static Bytecode unboxByte(Bytecode bc) {
  bc.addCheckcast("java.lang.Number");
  bc.addInvokevirtual("java.lang.Number", "byteValue", "()B");
  return bc;
}

代码示例来源:origin: fakereplace/fakereplace

public static Bytecode unboxFloat(Bytecode bc) {
  bc.addCheckcast("java.lang.Number");
  bc.addInvokevirtual("java.lang.Number", "floatValue", "()F");
  return bc;
}

代码示例来源:origin: fakereplace/fakereplace

public static Bytecode unboxChar(Bytecode bc) {
  bc.addCheckcast("java.lang.Character");
  bc.addInvokevirtual("java.lang.Character", "charValue", "()C");
  return bc;
}

代码示例来源:origin: fakereplace/fakereplace

public static Bytecode unboxShort(Bytecode bc) {
  bc.addCheckcast("java.lang.Number");
  bc.addInvokevirtual("java.lang.Number", "shortValue", "()S");
  return bc;
}

代码示例来源:origin: fakereplace/fakereplace

public static Bytecode unboxBoolean(Bytecode bc) {
  bc.addCheckcast("java.lang.Boolean");
  bc.addInvokevirtual("java.lang.Boolean", "booleanValue", "()Z");
  return bc;
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

public void atCastExpr(CastExpr expr) throws CompileError {
  String cname = resolveClassName(expr.getClassName());
  String toClass = checkCastExpr(expr, cname);
  int srcType = exprType;
  exprType = expr.getType();
  arrayDim = expr.getArrayDim();
  className = cname;
  if (toClass == null)
    atNumCastExpr(srcType, exprType);   // built-in type
  else
    bytecode.addCheckcast(toClass);
}

代码示例来源:origin: org.jboss.javassist/com.springsource.javassist

public void atCastExpr(CastExpr expr) throws CompileError {
  String cname = resolveClassName(expr.getClassName());
  String toClass = checkCastExpr(expr, cname);
  int srcType = exprType;
  exprType = expr.getType();
  arrayDim = expr.getArrayDim();
  className = cname;
  if (toClass == null)
    atNumCastExpr(srcType, exprType);   // built-in type
  else
    bytecode.addCheckcast(toClass);
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

public void atCastExpr(CastExpr expr) throws CompileError {
  String cname = resolveClassName(expr.getClassName());
  String toClass = checkCastExpr(expr, cname);
  int srcType = exprType;
  exprType = expr.getType();
  arrayDim = expr.getArrayDim();
  className = cname;
  if (toClass == null)
    atNumCastExpr(srcType, exprType);   // built-in type
  else
    bytecode.addCheckcast(toClass);
}

相关文章