All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pure4j.model.MethodHandle Maven / Gradle / Ivy

Go to download

Parses Byte-code to check the purity semantics defined using pure4j-core annotations

The newest version!
package org.pure4j.model;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class MethodHandle extends MemberHandle implements ImplementationHandle {

	public MethodHandle(Method m) {
		super(convertClassName(m.getDeclaringClass()), m.getName(), Type.getMethodDescriptor(m), 0);
	}

	public MethodHandle(String className, String name, String desc, int line) {
	    super(className, name, desc, line);
	}

	public Method hydrate(ClassLoader cl) {
	    return hydrateMethod(this, cl);
	}
	
	public Class hydrateClass(ClassLoader cl) {
	    return hydrateClass(className, cl);
	}

	public String getDeclaringClass() {
		return className;
	}

	public boolean overrides(MethodHandle another) {
		return (this.name.equals(another.getName())) && (this.getDesc().equals(another.getDesc()));
	}

	public  T getAnnotation(ClassLoader cl, Class c) {
		Method m = hydrate(cl);
		return m.getAnnotation(c);
	}
	
	@Override
	public Class getDeclaringClass(ClassLoader cl) {
		return hydrateClass(className, cl);
	}
	
	@Override
	public java.lang.reflect.Type[] getGenericTypes(ClassLoader cl) {
		return hydrate(cl).getGenericParameterTypes();
	}
	
	public Class[] getRawTypes(ClassLoader cl) {
		return hydrate(cl).getParameterTypes();
	}

	@Override
	public int getModifiers(ClassLoader cl) {
		return hydrate(cl).getModifiers();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy