Package net.sourceforge.javautil.bytecode.api

Examples of net.sourceforge.javautil.bytecode.api.IBytecodeResolvable


      if (am == ArgumentMatch.FUNCTIONAL && bm == null) bm = method;
      else if (am == ArgumentMatch.EXACT) { bm = method; break; }
    }
   
    if (bm == null) {
      IBytecodeResolvable st = this.superType;
      if (st == null) st = pool.resolve(Object.class.getName());
      return st.findMethod(pool, name, parameters);
    }
   
    return bm;
  }
View Full Code Here


    @Override protected Class<?> findClass(String name) throws ClassNotFoundException {
      try {
        return super.findClass(name);
      } catch (ClassNotFoundException e) {
        IBytecodeResolvable resolved = pool.resolve(name);
        if (resolved != null) {
          if (resolved instanceof AbstractType) {
            return compile( (AbstractType) resolved );
          } else {
            return ((Linkable)resolved).getWrapped();
View Full Code Here

 
  /**
   * @param parameters The parameters to pass to the super constructor
   */
  public void superConstruct (IBytecodeReferenceable... parameters) {
    IBytecodeResolvable type = this.getEnclosingType().getSuperType();
    if (type == null) type = getResolutionPool().resolve(Object.class.getName());
   
    this.construct(resolve("this"), type, parameters);
  }
View Full Code Here

   * Looks up the super method for the specified parameters
   *
   * @see #createInvocation(BytecodeContextMethod, IBytecodeMethod, IBytecodeReferenceable...)
   */
  public MethodInvocation createSuperInvocation (String name, IBytecodeReferenceable... parameters) {
    IBytecodeResolvable st = this.getEnclosingType().getSuperType();
    if (st == null) st = this.getResolutionPool().resolve(Object.class.getName());
   
    IBytecodeMethod method = st.findMethod(this.getResolutionPool(), name, getTypes(parameters));
   
    if (method == null)
      throw new BytecodeException("No such method could be found: " + name + " for " + st.getType().toDescriptorString());
   
    return this.createInvocation(resolve("this"), method, parameters);
  }
View Full Code Here

  /**
   * @param parameters The parameters to pass to the super constructor
   * @return The method invocation
   */
  public MethodInvocation createSuperConstructorInvocation (IBytecodeReferenceable... parameters) {
    IBytecodeResolvable st = getEnclosingType().getSuperType() == null ?
      getResolutionPool().resolve(Object.class.getName()) : getEnclosingType().getSuperType();
     
    return this.createConstructorInvocation(resolve("this"), st, parameters);
  }
View Full Code Here

        }
       
        if (p == parameterTypes.length - 1 && parameterTypes[p].getType().isArray() && varArgs) {
          if (arguments.length == p) { matched++; continue; }
         
          IBytecodeResolvable ct = parameterTypes[p];
          for (int a=p; a<arguments.length; a++) {
            if (arguments[a] == null && ct.getType().isPrimitive()) return ArgumentMatch.NONE;
            if (arguments[a] == null) continue;
           
            IBytecodeResolvable abr = pool.resolve(arguments[a].getClassName());
           
            if (abr.isInstanceof(pool, ct)) continue;
            if (arguments[a].isArray() && arguments[a].getComponentType().compareTo( ct.getType() ) == 0) continue;
           
            return ArgumentMatch.NONE;
          }
        } else if (parameterTypes[p].getType().isPrimitive()) {
         
          TypeDescriptor ptype = parameterTypes[p].getType();
          if (ptype == arguments[p]) { matched++; continue; }
         
          if (ptype.isPrimitive() && arguments[p].getClassName().equals(ptype.getBoxedType())) {
           
            matched++; continue;
           
          } else return ArgumentMatch.NONE;
         
        } else if (arguments.length > p) {
          if (parameterTypes[p].getType().compareTo( arguments[p] ) == 0) { matched++; continue; }
          else {
            IBytecodeResolvable abr = pool.resolve(arguments[p].getClassName());
            if (abr.isInstanceof( pool, parameterTypes[p] )) continue;
          }
         
          return ArgumentMatch.NONE;
        }
      }
View Full Code Here

   
    for (int i=0; i<ifaces.length; i++) {
      interfaces[i] = ifaces[i].getType().getName();
    }
   
    IBytecodeResolvable st = context.getEnclosingType().getSuperType() == null ?
      context.getResolutionPool().resolve(Object.class.getName()) : context.getEnclosingType().getSuperType();
   
    context.getClassWriter().visit(this.getVersion(context.getVersion()), getAccess(context.getEnclosingType()),
      context.getEnclosingType().getType().getName(), null,
      st.getType().getName(),
      interfaces
    );
   
    for (IBytecodeAnnotation annotation : context.getEnclosingType().getDeclaredAnnotations()) {
      this.declareAnnotation(context, annotation, context.getClassWriter().visitAnnotation(
View Full Code Here

   * @param context The context in which to declare the annotation
   * @param ba The annotation declaration
   * @param av The annotation visitor
   */
  protected void declareAnnotation (BytecodeContextTypeASM context, IBytecodeAnnotation ba, AnnotationVisitor av) {
    IBytecodeResolvable enumType = context.getResolutionPool().resolve(Enum.class.getName());
    IBytecodeResolvable annoType = context.getResolutionPool().resolve(Enum.class.getName());

    Map<String, AnnotationValue> values = ba.getValues();
    for (String name : values.keySet()) {
      AnnotationValue value = values.get(name);
      IBytecodeResolvable avt = context.getResolutionPool().resolve( value.getValue().getClass().getName() );
      if (avt.isInstanceof(context.getResolutionPool(), enumType)) {
        // TODO: support enums
      } else if (avt.getType().isArray() &&
                 context.getResolutionPool().resolve(
                     avt.getType().getComponentType().getClassName()
                 ).isInstanceof(context.getResolutionPool(), annoType)) {
        // TODO: support annotation arrays
      } else {
        av.visit(name, value.getValue());
      }
View Full Code Here

  /**
   * @param type The type the template is for
   * @return The concrete class template
   */
  protected JavaClassConcrete getProxyClassTemplate (Class<?> type, boolean wrapper) {
    IBytecodeResolvable resolved = getPool().resolve(type.getName());
    if (resolved.isFinal() || resolved.isAbstract())
      throw new IllegalArgumentException("Cannot create class based proxies for final/non static/abstract classes");
   
    final List<IInterceptorManipulator> abilities = this.getInterceptorAbilities(type);
    InterceptorProxyTypeAbstract proxy = wrapper ?
      new InterceptorProxyTypeCJCW(this, abilities, type, type.getName() + "$CJCW$" + proxySuffix) :
View Full Code Here

  public InterceptorProxyMethod () {
    this.addExceptionHandler(new ProxyMethodExceptionHandler());
  }

  @Override protected void writeLogic(BytecodeContextMethod context) {
    IBytecodeResolvable helper = context.resolve(InterceptorHelper.class);
   
    context.returnValue( context.getThisField("interceptor").createInvocation(context, "invoke", context.resolve("this"),
      context.createInvocation(helper, "findMethod",
        context.createInvocation(context.resolve("this"), "getClass"),
        new LiteralValue(context.getMethod().getName() + "$$"),
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.bytecode.api.IBytecodeResolvable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.