Fixed remaining javadoc issues

This commit is contained in:
Andy Clement
2014-02-25 15:15:58 -08:00
parent 6082381468
commit b474237898
23 changed files with 112 additions and 43 deletions

View File

@@ -56,6 +56,7 @@ public class FieldReaderWriter {
* @param instance the object instance upon which to set the field
* @param newValue the new value for that field
* @param stateManager the optional state manager for this instance, which will be looked up (expensive) if not passed in
* @throws IllegalAccessException if the field value cannot be set
*/
public void setValue(Object instance, Object newValue, ISMgr stateManager) throws IllegalAccessException {
if (typeDescriptor.isReloadable()) {
@@ -121,6 +122,8 @@ public class FieldReaderWriter {
*
* @param instance the instance for which the field should be fetched
* @param stateManager an optional state manager containing the map of values (will be discovered if not supplied)
* @return the value of the field
* @throws IllegalAccessException if there is a problem accessing the field value
*/
public Object getValue(Object instance, ISMgr stateManager) throws IllegalAccessException, IllegalArgumentException {
Object result = null;

View File

@@ -53,6 +53,7 @@ public class ISMgr {
* @param name the name of the field
*
* @return the value of the field
* @throws IllegalAccessException if there is a problem accessing the field
*/
public Object getValue(ReloadableType rtype, Object instance, String name) throws IllegalAccessException {
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.FINER)) {
@@ -152,7 +153,9 @@ public class ISMgr {
*
* @param rtype the reloadabletype
* @param instance the instance upon which to set the field
* @param value the value to put into the field
* @param name the name of the field
* @throws IllegalAccessException if there is a problem setting the field value
*/
public void setValue(ReloadableType rtype, Object instance, Object value, String name) throws IllegalAccessException {
// System.err.println(">setValue(rtype=" + rtype + ",instance=" + instance + ",value=" + value + ",name=" + name + ")");

View File

@@ -71,6 +71,7 @@ public class IncrementalTypeDescriptor implements Constants {
* <li>method was represented as a catcher in the original, but is now 'real'
* </ul>
* It does not include catchers.
* @return list of new or changed methods in this type
*/
public List<MethodMember> getNewOrChangedMethods() {
compute();
@@ -83,6 +84,7 @@ public class IncrementalTypeDescriptor implements Constants {
* <li>constructors that did not exist in the original class as loaded, but do now
* <li>constructors that did exist in the original class but have changed in some way (visibility)
* </ul>
* @return list of new or changed constructors in this type
*/
public List<MethodMember> getNewOrChangedConstructors() {
compute();
@@ -240,6 +242,7 @@ public class IncrementalTypeDescriptor implements Constants {
// For checking the bitflags:
/**
* @param mm the MethodMember to check if brand new
* @return true if the method is brand new after a reload (i.e. was never defined in the original type)
*/
public static boolean isBrandNewMethod(MethodMember mm) {

View File

@@ -53,7 +53,12 @@ public class InterfaceExtractor {
}
/**
* Extract the fixed interface for a class and a type descriptor with more details on the methods
* Extract the fixed interface for a class and a type descriptor with more details on the methods.
*
* @param classbytes bytes for the class which is going through interface extraction
* @param registry type registry related to the classloader for this class
* @param typeDescriptor previously extracted type descriptor for the class
* @return class bytes for extracted interface
*/
public static byte[] extract(byte[] classbytes, TypeRegistry registry, TypeDescriptor typeDescriptor) {
return new InterfaceExtractor(registry).extract(classbytes, typeDescriptor);

View File

@@ -29,10 +29,11 @@ import org.springsource.loaded.agent.ReloadDecision;
public interface IsReloadableTypePlugin extends Plugin {
/**
* @param typeRegistry
* @param typeRegistry the type registry asking the question
* @param typename slashed type name (e.g. java/lang/String)
* @param protectionDomain
* @param protectionDomain the protection domain under which the class is being loaded
* @param bytes the classfile data
* @return a decision indicating whether the specified type should be made reloadable
*/
ReloadDecision shouldBeMadeReloadable(TypeRegistry typeRegistry, String typename, ProtectionDomain protectionDomain, byte[] bytes);

View File

@@ -287,7 +287,7 @@ public class MethodMember extends AbstractMember {
return "[" + s.toString().trim() + "]";
}
/**
/*
* Determine whether this method should replace the other method on reload. In accordance to how JVM works at class load time,
* this will be the case if this and other have the same Class, name, parameter types and return type. I.e. formally, in JVM
* bytecode (unlike source code) a method doesn't override a method with a different return type. When such a situation occurs

View File

@@ -33,6 +33,7 @@ public class RTH {
*
* @param aString some string
* @param anInt some int
* @return the collapsed array
*/
public static Object[] collapse(String aString, int anInt) {
return new Object[] { aString, Integer.valueOf(anInt) };

View File

@@ -277,6 +277,7 @@ public class ReloadableType {
*
* @param versionsuffix the String suffix to append to classnames being created for the reloaded class
* @param newbytedata the class bytes for the new version of this class
* @return true if the reload succeeded
*/
public boolean loadNewVersion(String versionsuffix, byte[] newbytedata) {
javaMethodCache = null;
@@ -765,6 +766,9 @@ public class ReloadableType {
/**
* Gets the method corresponding to given name and descriptor, from the original type descriptor.
*
* @param nameAndDescriptor the method name and descriptor (e.g. foo(Ljava/lang/String;)I)
* @return the MethodMember for the name and descriptor if it exists, otherwise null
*/
public MethodMember getOriginalMethod(String nameAndDescriptor) {
return getMethod(nameAndDescriptor);
@@ -999,8 +1003,9 @@ public class ReloadableType {
* Intended to handle dynamic dispatch. This will determine the right type to handle the specified method and return a
* dispatcher that can handle it.
*
* @param instance
* @param instance the target instance for the invocation
* @param nameAndDescriptor an encoded method name and descriptor, e.g. foo(Ljava/langString;)V
* @return a dispatcher that can handle the method indicated
*/
@UsedByGeneratedCode
public __DynamicallyDispatchable determineDispatcher(Object instance, String nameAndDescriptor) {
@@ -1200,6 +1205,7 @@ public class ReloadableType {
* @param fieldname the name of the field
* @param isStatic whether the field is static
* @param newValue the new value to put into the field
* @throws IllegalAccessException if there is a problem setting the field value
*/
public void setField(Object instance, String fieldname, boolean isStatic, Object newValue) throws IllegalAccessException {
FieldReaderWriter fieldReaderWriter = locateField(fieldname);
@@ -1232,6 +1238,8 @@ public class ReloadableType {
* @param instance the object upon which to set the field (maybe null for static fields)
* @param fieldname the name of the field
* @param isStatic whether the field is static or not
* @return the field value
* @throws IllegalAccessException if there is a problem accessing the field
*/
public Object getField(Object instance, String fieldname, boolean isStatic) throws IllegalAccessException {
FieldReaderWriter fieldReaderWriter = locateField(fieldname);
@@ -1252,7 +1260,7 @@ public class ReloadableType {
return o;
}
/**
/*
* Find the field according to the rules of section 5.4.3.2 of the spec.
*/
// TODO [perf] performance sucks as we walk multiple times!
@@ -1341,7 +1349,7 @@ public class ReloadableType {
return hasFieldChangedInHierarchy(fieldname, originalTypeDescriptor.supertypeName);
}
/**
/*
* Want to check if this field looks the same as originally declared and is on the same type as it was
*/
public boolean hasFieldChangedInHierarchy(String name) {

View File

@@ -139,7 +139,8 @@ public class TypeDescriptor implements Constants {
* Check if this descriptor defines the specified method. A strict check on all aspects of the method - names/exceptions/flags,
* etc.
*
* @return true if this descriptor defines the specified method.
* @param method the method to check the existence of in this type descriptor
* @return true if this descriptor defines the specified method
*/
public boolean defines(MethodMember method) {
for (MethodMember existingMethod : methods) {
@@ -154,6 +155,10 @@ public class TypeDescriptor implements Constants {
/**
* Check if this descriptor defines a method with the specified name and descriptor. Return the method if it is found.
* Modifiers, generic signature and exceptions are ignored in this search.
*
* @param name the member name
* @param descriptor the member descriptor (e.g. (Ljava/lang/String;)I)
* @return the MethodMember if there is one
*/
public MethodMember getByDescriptor(String name, String descriptor) {
for (MethodMember existingMethod : methods) {
@@ -229,7 +234,7 @@ public class TypeDescriptor implements Constants {
* Search for a field on this type descriptor - do not try supertypes. This lookup does not differentiate between
* static/instance fields.
*
* @param name
* @param name the name of the field
* @return a FieldMember if the field is found, otherwise null
*/
public FieldMember getField(String name) {

View File

@@ -229,6 +229,9 @@ public class TypeRegistry {
/**
* Factory access method for obtaining TypeRegistry instances. Returns a TypeRegistry for the specified classloader.
*
* @param classloader The classloader to create/retrieve the type registry for
* @return the TypeRegistry for the classloader
*/
public static TypeRegistry getTypeRegistryFor(ClassLoader classloader) {
if (classloader == null) {
@@ -288,10 +291,12 @@ public class TypeRegistry {
/**
* Only checks the reloadable types this registry knows about, it doesn't search beyond that.
*
* @param slashedClassname the slashed classname (e.g. java/lang/String)
* @return the TypeDescriptor or null if that classname is unknown
*/
public TypeDescriptor getDescriptorForReloadableType(String slashedname) {
TypeDescriptor td = reloadableTypeDescriptorCache.get(slashedname);
return td;
public TypeDescriptor getDescriptorForReloadableType(String slashedClassname) {
return reloadableTypeDescriptorCache.get(slashedClassname);
}
public TypeDescriptor getDescriptorFor(String slashedname) {
@@ -676,6 +681,8 @@ public class TypeRegistry {
* Determine if the type specified is a reloadable type. This method works purely by name, it does not load anything.
*
* @param slashedName the type name, eg. a/b/c/D
* @param protectionDomain the protection domain this class is being loaded under
* @param bytes the class bytes for the class being loaded
* @return true if the type is reloadable, false otherwise
*/
public boolean isReloadableTypeName(String slashedName, ProtectionDomain protectionDomain, byte[] bytes) {
@@ -805,7 +812,7 @@ public class TypeRegistry {
}
}
/**
/*
* Rewrite the call sites in some class in the context of this registry (which knows about a particular set of types as being
* Reloadable).
*/
@@ -813,7 +820,7 @@ public class TypeRegistry {
return MethodInvokerRewriter.rewrite(this, bytes);
}
/**
/*
* This version will attempt to use a cache if one is being managed.
*/
public byte[] methodCallRewriteUseCacheIfAvailable(String slashedClassName, byte[] bytes) {
@@ -1961,6 +1968,9 @@ public class TypeRegistry {
* recognizes that bsm and the parameters to that bsm. The index can be
* used when rewriting that invokedynamic
*
* @param slashedClassName the slashed class name containing the bootstrap method
* @param bsm the bootstrap methods
* @param bsmArgs the bootstrap method arguments (asm types)
* @return id that represents this bootstrap method usage
*/
public synchronized int recordBootstrapMethod(String slashedClassName, Handle bsm, Object[] bsmArgs) {

View File

@@ -105,6 +105,7 @@ public class Utils implements Opcodes, Constants {
*
* @param mv where to visit to append the instructions
* @param returnType return type descriptor
* @param createCast whether to include CHECKCAST instructions for return type values
*/
public static void addCorrectReturnInstruction(MethodVisitor mv, ReturnType returnType, boolean createCast) {
if (returnType.isPrimitive()) {
@@ -611,6 +612,7 @@ public class Utils implements Opcodes, Constants {
* @param methodDescriptor a method descriptor (e.g (Ljava/lang/String;)I)
* @param classLoader a class loader that can be used to lookup types
* @return an array for classes representing the types in the method descriptor
* @throws ClassNotFoundException if there is a problem finding the Class for a particular name in the descriptor
*/
public static Class<?>[] toParamClasses(String methodDescriptor, ClassLoader classLoader) throws ClassNotFoundException {
Type[] paramTypes = Type.getArgumentTypes(methodDescriptor);
@@ -628,6 +630,7 @@ public class Utils implements Opcodes, Constants {
* @param type the asm Type
* @param classLoader a class loader that can be used to find types
* @return the JVM Class for the type
* @throws ClassNotFoundException if there is a problem finding the Class for the type
*/
public static Class<?> toClass(Type type, ClassLoader classLoader) throws ClassNotFoundException {
switch (type.getSort()) {
@@ -1011,6 +1014,7 @@ public class Utils implements Opcodes, Constants {
*
* @param mv the method visitor to receive the unpack instructions
* @param toCallDescriptor the descriptor for the method whose parameters describe the array contents
* @param arrayVariableIndex index of the array variable
*/
public static void generateInstructionsToUnpackArrayAccordingToDescriptor(MethodVisitor mv, String toCallDescriptor,
int arrayVariableIndex) {
@@ -1081,11 +1085,11 @@ public class Utils implements Opcodes, Constants {
* Dump the specified bytes under the specified name in the filesystem. If the location hasn't been configured then
* File.createTempFile() is used to determine where the file will be put.
*
* @param slashname
* @param bytesLoaded
* @param slashname the slashed class name (e.g. java/lang/String)
* @param bytes the bytes to dump
* @return the path to the file
*/
public static String dump(String slashname, byte[] bytesLoaded) {
public static String dump(String slashname, byte[] bytes) {
if (GlobalConfiguration.assertsMode) {
if (slashname.indexOf('.') != -1) {
throw new IllegalStateException("Slashed type name expected, not '" + slashname + "'");
@@ -1110,7 +1114,7 @@ public class Utils implements Opcodes, Constants {
System.out.println("dump to " + dumplocation);
f = new File(dumplocation);
FileOutputStream fos = new FileOutputStream(f);
fos.write(bytesLoaded);
fos.write(bytes);
fos.flush();
fos.close();
return f.toString();
@@ -1330,6 +1334,9 @@ public class Utils implements Opcodes, Constants {
/**
* Load the contents of an input stream.
*
* @param stream input stream that contains the bytes to load
* @return the byte array loaded from the input stream
*/
public static byte[] loadFromStream(InputStream stream) {
try {
@@ -1364,6 +1371,9 @@ public class Utils implements Opcodes, Constants {
* If the flags indicate it is not public, private or protected, then it is default and make it public.
*
* Default visibility needs promoting because package visibility is determined by classloader+package, not just package.
*
* @param access incoming access modifiers
* @return adjusted modifiers
*/
public static int promoteDefaultOrProtectedToPublic(int access) {
if ((access & Constants.ACC_PUBLIC_PRIVATE_PROTECTED) == 0) {
@@ -1420,6 +1430,7 @@ public class Utils implements Opcodes, Constants {
/**
* Utility method similar to Java 1.6 Arrays.copyOf, used instead of that method to stick to Java 1.5 only API.
*
* @param <T> the type of the array entries
* @param array the array to copy
* @param newSize the size of the new array
* @return a new array of the specified size containing the supplied array elements at the beginning
@@ -1452,6 +1463,8 @@ public class Utils implements Opcodes, Constants {
}
/**
* @param possiblyBoxedType a reference type that may be the boxed form of a primitive
* @param primitive the primitive we are looking for
* @return true if the possiblyBoxedType is the boxed form of the primitive
*/
public static boolean isObjectIsUnboxableTo(Class<?> possiblyBoxedType, char primitive) {
@@ -1484,6 +1497,7 @@ public class Utils implements Opcodes, Constants {
*
* @param value the value
* @param desc the type the caller would like it to be
* @return the converted value or possibly a default value for the type if the incoming value is null
*/
public static Object toResultCheckIfNull(Object value, String desc) {
if (value == null) {
@@ -1571,7 +1585,7 @@ public class Utils implements Opcodes, Constants {
return isAssignableFrom(reg, clazz.getSuperclass(), lookingFor);
}
/**
/*
* Determine if the type specified in lookingFor is a supertype (class/interface) of the specified typedescriptor, i.e. can an
* object of type 'candidate' be assigned to a variable of typ 'lookingFor'.
*
@@ -1598,7 +1612,7 @@ public class Utils implements Opcodes, Constants {
return isAssignableFrom(lookingFor, candidate.getTypeRegistry().getDescriptorFor(supertypename));
}
/**
/*
* Produce the bytecode that will collapse the stack entries into an array - the descriptor describes what is being packed.
*
* @param mv the method visitor to receive the instructions to package the data

View File

@@ -36,8 +36,8 @@ public class ClassVisitingConstructorAppender extends ClassVisitor implements Co
* just before each constructor returns. The target of the call should be a collecting method that will likely do something with
* the instances later on class reload.
*
* @param owner
* @param name
* @param owner the owning class of the method to call
* @param name the method to call
*/
public ClassVisitingConstructorAppender(String owner, String name) {
super(ASM5,new ClassWriter(0)); // TODO review 0 here

View File

@@ -67,7 +67,7 @@ public class ModifyDefineInClassLoaderForClassArtifactsType extends ClassVisitor
}
/**
/*
* The classloader for class artifacts (org/codehaus/groovy/reflection/ClassLoaderForClassArtifacts) is used to load the
* generated classes for call sites. We need to rewrite these classes
* because they may be either calling something that disappears on a later reload (so need to fail appropriately) or calling

View File

@@ -49,7 +49,7 @@ public class SpringLoadedAgent {
}
/**
* Returns the Instrumentation instance
* @return the Instrumentation instance
*/
public static Instrumentation getInstrumentation() {
if (instrumentation == null) {

View File

@@ -98,6 +98,10 @@ public class SpringLoadedPreProcessor implements Constants {
* order to determine whether the type should be made reloadable. Non-reloadable types will at least get their call sites
* rewritten.
*
* @param classLoader the classloader loading this type
* @param slashedClassName the slashed class name (e.g. java/lang/String) being loaded
* @param protectionDomain the protection domain for the loaded class
* @param bytes the class bytes for the class being loaded
* @return potentially modified bytes
*/
public byte[] preProcess(ClassLoader classLoader, String slashedClassName, ProtectionDomain protectionDomain, byte[] bytes) {

View File

@@ -103,7 +103,7 @@ public class JVM {
sun.reflect.Reflection.ensureMemberAccess(callerClass, declaringClass, target, mods);
}
/**
/*
* Create a new Method object from scratch. This Method object is 'fake' and will not be "invokable". ReflectionInterceptor will
* be responsible to make sure user code calling 'invoke' on this object will be intercepted and handled appropriately.
*/
@@ -126,7 +126,7 @@ public class JVM {
return returnMethod;
}
/**
/*
* Creates a copy of a method object that is equivalent to the original.
*/
public static Method copyMethod(Method method) {

View File

@@ -31,6 +31,8 @@ public class DynamicLookup {
/**
* Create an object capable of performing a dynamic method lookup in some MethodProvider
* @param name method name
* @param methodDescriptor method descriptor (e.g. (Ljava/lang/String;)V)
*/
public DynamicLookup(String name, String methodDescriptor) {
this.name = name;

View File

@@ -28,7 +28,7 @@ public class GetDeclaredMethodLookup {
private String name;
private String paramsDescriptor;
/**
/*
* Create an object capable of performing the lookup in some MethodProvider
*/
public GetDeclaredMethodLookup(String name, String paramsDescriptor) {
@@ -49,7 +49,7 @@ public class GetDeclaredMethodLookup {
return found;
}
/**
/*
* @return true if m2 has a more specific return type than m1
*/
private boolean isMoreSpecificReturnTypeThan(Invoker m1, Invoker m2) {

View File

@@ -31,7 +31,7 @@ public class GetMethodLookup {
private String name;
private String paramsDescriptor;
/**
/*
* Create an object capable of performing the lookup
*/
public GetMethodLookup(String name, String paramsDescriptor) {

View File

@@ -38,7 +38,7 @@ public class JavaMethodCache {
//TODO: [...] This cache uses string+descriptor for key. It may be possible to cache method objects inside MethodMembers
// themselves, which would make for much quicker 'lookup'.
/**
/*
* This class is used to initialise the cache in a thread safe manner. I.e. a fully filled map should be passed into the cache's
* initialize method, so that the 'isInitialized' method will not return true unless initialisation is complete and all entries
* are present.
@@ -54,7 +54,7 @@ public class JavaMethodCache {
}
/**
/*
* Map indexed by name+descriptor.
*/
private Map<String, Method> cache = null;
@@ -63,7 +63,7 @@ public class JavaMethodCache {
return cache != null;
}
/**
/*
* This method should be called to put all entries into the map.
*/
public void initialize(Initializer init) {

View File

@@ -85,7 +85,7 @@ public class ReflectiveInterceptor {
}
}
/**
/*
* Implementation of java.lang.class.getDeclaredMethod(String name, Class... params).
*/
@UsedByGeneratedCode
@@ -107,7 +107,7 @@ public class ReflectiveInterceptor {
}
}
/**
/*
* Implementation of java.lang.class.getMethod(String name, Class... params).
*/
@UsedByGeneratedCode
@@ -180,7 +180,7 @@ public class ReflectiveInterceptor {
}
private static int depth = 4;
/**
/*
* Get the Class that declares the method calling interceptor method that called this method.
*/
@SuppressWarnings("restriction")
@@ -224,6 +224,7 @@ public class ReflectiveInterceptor {
* Called to satisfy an invocation of java.lang.Class.getDeclaredAnnotations().
*
* @param clazz the class upon which the original call was being invoked
* @return array of annotations on the class
*/
public static Annotation[] jlClassGetDeclaredAnnotations(Class<?> clazz) {
if (TypeRegistry.nothingReloaded) {
@@ -237,7 +238,7 @@ public class ReflectiveInterceptor {
return clv.getExecutorClass().getDeclaredAnnotations();
}
/**
/*
* Called to satisfy an invocation of java.lang.Class.getDeclaredAnnotations().
*
* @param clazz the class upon which the original call was being invoked
@@ -1632,6 +1633,8 @@ public class ReflectiveInterceptor {
/**
* Although fields are not reloadable, we have to intercept this because otherwise we'll return the r$type field as a result
* here.
* @param clazz the class for which to retrieve the fields
* @return array of fields in the class
*/
public static Field[] jlClassGetFields(Class<?> clazz) {
ReloadableType rtype = getRType(clazz);
@@ -1646,6 +1649,9 @@ public class ReflectiveInterceptor {
/**
* Gather up all (public) fields in an interface and all its super interfaces recursively.
* @param clazz the class for which to collect up fields
* @param collected a collector that has fields added to it as this method runs (recursively)
* @param visited a set recording which types have already been visited
*/
private static void gatherFields(Class<?> clazz, List<Field> collected, HashSet<Class<?>> visited) {
if (visited.contains(clazz)) {

View File

@@ -30,6 +30,8 @@ public class StaticLookup {
/**
* Create an object capable of performing a dynamic method lookup in some MethodProvider
* @param name the method name
* @param methodDescriptor the method descriptor (e.g. (Ljava/lang/String;)I)
*/
public StaticLookup(String name, String methodDescriptor) {
this.name = name;

View File

@@ -81,11 +81,13 @@ public class Java8 {
* Programmatic emulation of INVOKEDYNAMIC so initialize the callsite via use of the bootstrap method then
* invoke the result.
*
* @param executorClass null if not yet reloaded
* @param handle
* @param bsmArgs
* @param lookup
* @return
* @param executorClass the executor that will contain the lambda function, null if not yet reloaded
* @param handle bootstrap method handle
* @param bsmArgs bootstrap method arguments
* @param lookup The MethodHandles.Lookup object that can be used to find types
* @param indyNameAndDescriptor Method name and descriptor at invokedynamic site
* @param indyParams parameters when the invokedynamic call is made
* @return the result of the invokedynamic call
*/
public static Object emulateInvokeDynamic(Class<?> executorClass, Handle handle, Object[] bsmArgs, Object lookup, String indyNameAndDescriptor, Object[] indyParams) {
try {
@@ -144,8 +146,8 @@ public class Java8 {
/**
* The metafactory we are enhancing is responsible for generating the anonymous classes that will call the lambda methods in our type
*
* @param bytes
* @return
* @param bytes the class bytes for the InnerClassLambdaMetaFactory that is going to be modified
* @return the class bytes for the modified InnerClassLambdaMetaFactory
*/
public static byte[] enhanceInnerClassLambdaMetaFactory(byte[] bytes) {
// TODO Auto-generated method stub