Package org.apache.aries.proxy

Examples of org.apache.aries.proxy.UnableToProxyException


            throw new FinalModifierException(aClass);
          } else {
            throw new FinalModifierException(aClass, exceptionParts[1]);
          }
        } else if (className.charAt(0) == UNABLE_TO_PROXY) {
          throw new UnableToProxyException(aClass);
        }

        try {
          classToReturn = loader.loadClass(className);
        } catch (ClassNotFoundException cnfe) {
          LOGGER.debug(Constants.LOG_EXCEPTION, cnfe);
          throw new UnableToLoadProxyException(className, cnfe);
        }
      } else {

        LOGGER.debug("Need to generate subclass. Using key {}.", key);
        try {
          scanForFinalModifiers(aClass);

          classToReturn = generateAndLoadSubclass(aClass, loader);

          if (classToReturn != null) {
            proxyMap.put(key, classToReturn.getName());
          } else {
            proxyMap.put(key, UNABLE_TO_PROXY + aClass.getName());
            throw new UnableToProxyException(aClass);
          }
        } catch (FinalModifierException e) {
          if (e.isFinalClass()) {
            proxyMap.put(key, FINAL_MODIFIER + e.getClassName());
            throw e;
View Full Code Here


      }
    } catch (ClassNotFoundException e) {
      // If this happens we're about to hit bigger trouble on verify, so we
      // should stop weaving and fail. Make sure we don't cause the hook to
      // throw an error though.
      UnableToProxyException u = new UnableToProxyException(name, e);
      throw new RuntimeException(NLS.MESSAGES.getMessage("cannot.load.superclass", superName.replace('/', '.'), typeBeingWoven.getClassName()), u);
    }
  }
View Full Code Here

      if(is == null)
        throw new IOException();
     
      new ClassReader(is).accept(cf, ClassReader.SKIP_FRAMES + ClassReader.SKIP_DEBUG + ClassReader.SKIP_CODE);
    } catch (IOException ioe) {
      UnableToProxyException u = new UnableToProxyException(name, ioe);
      throw new RuntimeException(NLS.MESSAGES.getMessage("cannot.load.superclass", superName.replace('/', '.'), typeBeingWoven.getClassName()), u);
    }
    return cf.hasNoArgsConstructor();
  }
View Full Code Here

        methodAdapter.invokeConstructor(superType, NO_ARGS_CONSTRUCTOR);
      else {
        if(hasNoArgsConstructor)
          methodAdapter.invokeConstructor(typeBeingWoven, NO_ARGS_CONSTRUCTOR);
        else
          throw new RuntimeException(new UnableToProxyException(typeBeingWoven.getClassName(),
              NLS.MESSAGES.getMessage("type.lacking.no.arg.constructor", typeBeingWoven.getClassName(), superType.getClassName())));
      }
      methodAdapter.loadThis();
      methodAdapter.loadArg(0);
      methodAdapter.putField(typeBeingWoven, DISPATCHER_FIELD, DISPATCHER_TYPE);
View Full Code Here

      }

      if (unable == null) {
          throw new RuntimeException(NLS.MESSAGES.getMessage("no.common.superclass", arg0, arg1));
      } else {
          throw new RuntimeException(new UnableToProxyException(unable, NLS.MESSAGES.getMessage("no.common.superclass", arg0, arg1)));
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

      if(old != null) {
        c = Class.forName(className, false, this);
      }
      return c;
    } catch (ClassFormatError cfe) {
      throw new UnableToProxyException(createSet.iterator().next(), cfe);
    } catch (ClassNotFoundException e) {
      throw new UnableToProxyException(createSet.iterator().next(), e);
    }
  }
View Full Code Here

  private static final Class<?>[] getInterfaces(Collection<Class<?>> classes) throws UnableToProxyException
  {
    for (Class<?> clazz : classes) {
        if (!!!clazz.isInterface()) {
          throw new UnableToProxyException(clazz, NLS.MESSAGES.getMessage("class.is.class", clazz.getName()));
        }
    }
    return (Class[]) classes.toArray(new Class[classes.size()]);
  }
View Full Code Here

      for(Class<?> c : interfaces) {
        adapter.setCurrentMethodDeclaringType(Type.getType(c), true);
        try {
          AbstractWovenProxyAdapter.readClass(c, this);
        } catch (IOException e) {
          throw new UnableToProxyException(c, e);
        }
      }

      Class<?> clazz = superclass;
View Full Code Here

      // We can't call up to a default access method if we aren't in the same
      // package
      if((access & (ACC_PUBLIC | ACC_PROTECTED | ACC_PRIVATE)) == 0) {
        if(!!!samePackage)
          throw new RuntimeException(NLS.MESSAGES.getMessage("method.from.superclass.is.hidden", name, superToCopy.getName(), overridingClassType.getClassName()),
                                     new UnableToProxyException(superToCopy));
      }
      //Safe to copy a call to this method!
      Type superType = Type.getType(superToCopy);
     
      // identify the target method parameters and return type
      String methodStaticFieldName = "methodField" + AbstractWovenProxyAdapter.getSanitizedUUIDString();
      transformedMethods.put(methodStaticFieldName, new TypeMethod(
          superType, currentTransformMethod))
     
      //Remember we need to copy the fake method *and* weave it, use a
      //WovenProxyMethodAdapter as well as a CopyingMethodAdapter
     
      MethodVisitor weaver = wovenProxyAdapter.getWeavingMethodVisitor(
              access, name, desc, sig, exceptions, currentTransformMethod,
              methodStaticFieldName, superType, false);
     
      if(weaver instanceof AbstractWovenProxyMethodAdapter) {
        //If we are weaving this method then we might have a problem. If it's a protected method and we
        //aren't in the same package then we can't dispatch the call to another object. This may sound
        //odd, but if class Super has a protected method foo(), then class Sub, that extends Super, cannot
        //call ((Super)o).foo() in code (it can call super.foo()). If we are in the same package then this
      //gets around the problem, but if not the class will fail verification.
        if(!samePackage && (access & ACC_PROTECTED) != 0)
          throw new RuntimeException(NLS.MESSAGES.getMessage("method.from.superclass.is.hidden", name, superToCopy.getName(), overridingClassType.getClassName()),
                new UnableToProxyException(superToCopy));
        mv = new CopyingMethodAdapter((GeneratorAdapter) weaver, superType, currentTransformMethod);
      }
      else {
        //For whatever reason we aren't weaving this method. The call to super.xxx() will always work
        mv = new CopyingMethodAdapter(new GeneratorAdapter(access, currentTransformMethod, mv),
View Full Code Here

            throw new FinalModifierException(aClass);
          } else {
            throw new FinalModifierException(aClass, exceptionParts[1]);
          }
        } else if (className.charAt(0) == UNABLE_TO_PROXY) {
          throw new UnableToProxyException(aClass);
        }

        try {
          classToReturn = loader.loadClass(className);
        } catch (ClassNotFoundException cnfe) {
          LOGGER.debug(Constants.LOG_EXCEPTION, cnfe);
          throw new UnableToLoadProxyException(className, cnfe);
        }
      } else {

        LOGGER.debug("Need to generate subclass. Using key {}.", key);
        try {
          scanForFinalModifiers(aClass);

          classToReturn = generateAndLoadSubclass(aClass, loader);

          if (classToReturn != null) {
            proxyMap.put(key, classToReturn.getName());
          } else {
            proxyMap.put(key, UNABLE_TO_PROXY + aClass.getName());
            throw new UnableToProxyException(aClass);
          }
        } catch (FinalModifierException e) {
          if (e.isFinalClass()) {
            proxyMap.put(key, FINAL_MODIFIER + e.getClassName());
            throw e;
View Full Code Here

TOP

Related Classes of org.apache.aries.proxy.UnableToProxyException

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.