/** * Validates the constructor. * * @throws InvalidProxyDescriptionException * if something is wrong */ private void validateConstructor() throws InvalidProxyDescriptionException { Class<?>[] params = this.getConstructorParameterTypes().toArray(new Class<?>[getConstructorParameterTypes().size()]); try { Constructor<?> ctr = superClass.getDeclaredConstructor(params); if ((ctr.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) == 0) { InvalidProxyDescriptionException.throwException("The constructor with parameter types %s found in class %s is neither public nor protected!", params, superClass); } } catch (NoSuchMethodException e) { InvalidProxyDescriptionException.throwException("No accessible constructor with parameter types %s found in class %s", params, superClass); } }
/** * Fetches the type with the given name, if an exception occurs an * {@link InvalidProxyDescriptionException} is thrown. Also supports the primitive classes (like * int.class) * * @param typeName * the name of the type * @param context * the context * @return the class representing the given typename * @throws InvalidProxyDescriptionException * if the type was not found */ private static Class<?> getType(String typeName, ClassLoader context) throws InvalidProxyDescriptionException { try { return AutoboxingHelper.findClass(typeName, false, context); } catch (ClassNotFoundException e) { InvalidProxyDescriptionException.throwException("The type %s does not exist in the given context!", typeName); return null; // never reached } }
InvalidProxyDescriptionException.throwException("The proxy class can't inherit from %s!", superClass); InvalidProxyDescriptionException.throwException("%s is not an interface!", interf); MethodBuildPlanImpl second = methods.get(j); if (first.isSignatureEqual(second.getMethodName(), second.getParameterTypes())) { InvalidProxyDescriptionException.throwException("The method %s%s occurs multiple times!", second.getMethodName(), second.getParameterTypes().toArray(new Class<?>[0])); InvalidProxyDescriptionException.throwException("The abstract method %s%s of the type %s is not overriden!", meth.getName(), meth.getParameterTypes(), parent);
ProxyMethod anno = method.getAnnotation(ProxyMethod.class); if ((method.getModifiers() & Modifier.STATIC) != 0) { InvalidProxyDescriptionException.throwException("The method " + method.getName() + " is static and therefore can not be proxied!"); InvalidProxyDescriptionException.throwException("The parameter count in the ProxyMethod annotation " + "does not match the actual parameter count for " + method.getName()); InvalidProxyDescriptionException.throwException("Invalid parameter type: %s", typeName); InvalidProxyDescriptionException.throwException("Incompatible parameter types: %s and %s", paramType, targetMethodParamTypes[i]);
ProxyFor proxyInfo = proxySubjectType.getAnnotation(ProxyFor.class); if (proxyInfo == null) { InvalidProxyDescriptionException.throwException("%s does not have the ProxyFor - annotation!", proxySubjectType);