Docs can now be generated without warnings/errors using Java 8

This commit is contained in:
Demian Rootring 2015-03-01 14:55:33 +01:00
parent b0b20221cf
commit 8863d43810
3 changed files with 52 additions and 7 deletions

View File

@ -33,14 +33,23 @@ public abstract class ConstructorAccess<T> {
* <p>
* If the underlying class is a inner (non-static nested) class, a new instance will be created using <code>null</code> as the
* this$0 synthetic reference. The instantiated object will work as long as it actually don't use any member variable or method
* fron the enclosing instance. */
* from the enclosing instance.
* @return a new Instance. */
abstract public T newInstance ();
/** Constructor for inner classes (non-static nested classes).
* @param enclosingInstance The instance of the enclosing type to which this inner instance is related to (assigned to its
* synthetic this$0 field). */
* synthetic this$0 field).
* @return a new Instance. */
abstract public T newInstance (Object enclosingInstance);
/**
* Get a ConstructorAccess object for the supplied Class.
* @param type the Class to construct the ConstructorAccess for.
* @param <T> the generic Type.
* @return the created ConstructorAccess.
* @throws RuntimeException on problems accessing member classes or on missing/inaccessible no-argument constructor and any
* other visibility issues. */
static public <T> ConstructorAccess<T> get (Class<T> type) {
Class enclosingType = type.getEnclosingClass();
boolean isNonStaticMemberClass = enclosingType != null && type.isMemberClass() && !Modifier.isStatic(type.getModifiers());

View File

@ -25,6 +25,9 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;
/**
* Used to access a field.
*/
public abstract class FieldAccess {
private String[] fieldNames;
private Class[] fieldTypes;

View File

@ -27,6 +27,9 @@ import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
/**
* Represents MethodAccess.
*/
public abstract class MethodAccess {
private String[] methodNames;
private Class[][] parameterTypes;
@ -34,49 +37,79 @@ public abstract class MethodAccess {
abstract public Object invoke (Object object, int methodIndex, Object... args);
/** Invokes the method with the specified name and the specified param types. */
/** Invokes the method with the specified name and the specified param types.
* @param object the object to use in invocation.
* @param methodName the name of the method.
* @param paramTypes the parameterTypes as Class[].
* @param args any number of parameters to use.
* @return the result. */
public Object invoke (Object object, String methodName, Class[] paramTypes, Object... args) {
return invoke(object, getIndex(methodName, paramTypes), args);
}
/** Invokes the first method with the specified name and the specified number of arguments. */
/** Invokes the first method with the specified name and the specified number of arguments.
* @param object the object to use in invocation.
* @param methodName the name of the method.
* @param args any number of parameters to use.
* @return the result. */
public Object invoke (Object object, String methodName, Object... args) {
return invoke(object, getIndex(methodName, args == null ? 0 : args.length), args);
}
/** Returns the index of the first method with the specified name. */
/** Returns the index of the first method with the specified name.
* @param methodName the name of the method.
* @return the index. */
public int getIndex (String methodName) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName)) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName);
}
/** Returns the index of the first method with the specified name and param types. */
/** Returns the index of the first method with the specified name and param types.
* @param methodName the name of the method.
* @param paramTypes the Classes of the method signature.
* @return the index. */
public int getIndex (String methodName, Class... paramTypes) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName) && Arrays.equals(paramTypes, parameterTypes[i])) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName + " " + Arrays.toString(paramTypes));
}
/** Returns the index of the first method with the specified name and the specified number of arguments. */
/** Returns the index of the first method with the specified name and the specified number of arguments.
* @param methodName the name of the method.
* @param paramsCount the number of parameters.
* @return the index. */
public int getIndex (String methodName, int paramsCount) {
for (int i = 0, n = methodNames.length; i < n; i++)
if (methodNames[i].equals(methodName) && parameterTypes[i].length == paramsCount) return i;
throw new IllegalArgumentException("Unable to find non-private method: " + methodName + " with " + paramsCount + " params.");
}
/**
* All method names.
* @return the method names as String[]. */
public String[] getMethodNames () {
return methodNames;
}
/**
* All parameter types.
* @return all parameter types as Class[][]. */
public Class[][] getParameterTypes () {
return parameterTypes;
}
/**
* All return types.
* @return the return types as Class[]. */
public Class[] getReturnTypes () {
return returnTypes;
}
/**
* Retrieve a MethodAccess object by Class.
* @param type the Class.
* @return the MethodAccess object. */
static public MethodAccess get (Class type) {
ArrayList<Method> methods = new ArrayList<Method>();
boolean isInterface = type.isInterface();