List of usage examples for org.apache.commons.bcel6.classfile Method getName
public final String getName()
From source file:ru.objective.jni.tasks.builders.ClassBuilder.java
private String getMethodImplementation(Method method, String declaration) { StringBuilder builder = new StringBuilder(); String vars = generateArgumentString(method); builder.append(declaration).append(" {").append(System.lineSeparator()); builder.append("OJNIEnv *__env = [OJNIEnv currentEnv];").append(System.lineSeparator()); builder.append("jmethodID mid = [[OJNIMidManager sharedManager] methodIDFor"); if (method.isStatic()) builder.append("Static"); builder.append("Method:@\"" + method.getName() + "\" "); builder.append("signature:@\"" + method.getSignature() + "\" inClass:self.class];"); builder.append(System.lineSeparator()); // todo remove [self.class OJNIClass]; if (method.getReturnType().equals(Type.VOID)) { if (Utils.isConstructor(method)) { builder.append("jobject __obj = [__env newObject:[self.class OJNIClass] method:mid"); builder.append(vars).append("];").append(System.lineSeparator()); builder.append("return [super initWithJavaObject:__obj];"); } else {// w w w .j av a2 s. c o m if (method.isStatic()) { builder.append("[__env callStaticVoidMethodOnClass:[self.class OJNIClass] method:mid"); } else { builder.append("[__env callVoidMethodOnObject:[self javaObject] method:mid"); } builder.append(vars).append("];"); } } else { builder.append(generateCallMethod(method, vars)); builder.append(generateReturnObject(method.getReturnType())); } builder.append(System.lineSeparator()).append("}"); return builder.toString(); }
From source file:ru.objective.jni.utils.Utils.java
public static HashSet<Method> getOverloadedMethods(Method[] methods) { HashSet<Method> result = new HashSet<>(methods.length); for (Method method : methods) { if (Utils.getMethodExportInfo(method) == null) continue; for (Method foundMethod : methods) { if (Utils.getMethodExportInfo(foundMethod) == null) continue; if (method.equals(foundMethod)) continue; if (method.getName().equals(foundMethod.getName()) && method.getArgumentTypes().length == foundMethod.getArgumentTypes().length) { result.add(method);/* w ww . ja v a 2s . c om*/ break; } } } return result; }
From source file:ru.objective.jni.utils.Utils.java
public static MethodExportInfo getMethodExportInfo(Method method) { MethodExportInfo result = new MethodExportInfo(); if (!method.isPublic() || method.isAnnotation() || method.isSynthetic()) return result; String name = method.getName(); AnnotationEntry[] entries = method.getAnnotationEntries(); for (AnnotationEntry annotationEntry : entries) { String translated = Signature.translate(annotationEntry.getAnnotationType()); if (translated.equals(OJNIExclude.class.getName())) return result; if (translated.equals(OJNIExportName.class.getName())) { result.isCustom = true;/*from ww w . ja v a 2 s. c o m*/ ElementValuePair[] elementValuePairs = annotationEntry.getElementValuePairs(); AnnotationType annotationType = AnnotationType.getInstance(OJNIExportName.class); for (ElementValuePair elementValuePair : elementValuePairs) { if (annotationType.memberTypes().get(elementValuePair.getNameString()) != null) { name = elementValuePair.getValue().stringifyValue(); } } } } result.name = name; return result; }
From source file:ru.objective.jni.utils.Utils.java
public static boolean isConstructor(Method method) { return (method.getName().equals("<init>")); }