mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
640cd329f9
- Bug 1160164 - Run "all the tests" when invoking xpcshell's mach command with no arguments instead of passing "all" to the test resolver.;r=ahal DONTBUILD (5583e3bce) - Bug 1171602 - Run mochitest using mach from a tests.zip, r=chmanchester (083d01f4c) - Bug 1178850 - Generate naive method bindings in annotation processor; r=snorp (8f8a14e3d) - Bug 1192079 - Support inner classes in generated JNI wrapper; r=snorp (1eefd6a4f)
63 lines
2.2 KiB
Java
63 lines
2.2 KiB
Java
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.annotationProcessors.classloader;
|
|
|
|
import org.mozilla.gecko.annotationProcessors.AnnotationInfo;
|
|
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Member;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Modifier;
|
|
|
|
/**
|
|
* Union type to hold either a method, field, or ctor. Allows us to iterate "The generatable stuff", despite
|
|
* the fact that such things can be of either flavour.
|
|
*/
|
|
public class AnnotatableEntity {
|
|
public enum ENTITY_TYPE {METHOD, NATIVE, FIELD, CONSTRUCTOR}
|
|
|
|
private final Member mMember;
|
|
public final ENTITY_TYPE mEntityType;
|
|
|
|
public final AnnotationInfo mAnnotationInfo;
|
|
|
|
public AnnotatableEntity(Member aObject, AnnotationInfo aAnnotationInfo) {
|
|
mMember = aObject;
|
|
mAnnotationInfo = aAnnotationInfo;
|
|
|
|
if (aObject instanceof Method) {
|
|
if (Modifier.isNative(aObject.getModifiers())) {
|
|
mEntityType = ENTITY_TYPE.NATIVE;
|
|
} else {
|
|
mEntityType = ENTITY_TYPE.METHOD;
|
|
}
|
|
} else if (aObject instanceof Field) {
|
|
mEntityType = ENTITY_TYPE.FIELD;
|
|
} else {
|
|
mEntityType = ENTITY_TYPE.CONSTRUCTOR;
|
|
}
|
|
}
|
|
|
|
public Method getMethod() {
|
|
if (mEntityType != ENTITY_TYPE.METHOD && mEntityType != ENTITY_TYPE.NATIVE) {
|
|
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
|
|
}
|
|
return (Method) mMember;
|
|
}
|
|
public Field getField() {
|
|
if (mEntityType != ENTITY_TYPE.FIELD) {
|
|
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
|
|
}
|
|
return (Field) mMember;
|
|
}
|
|
public Constructor<?> getConstructor() {
|
|
if (mEntityType != ENTITY_TYPE.CONSTRUCTOR) {
|
|
throw new UnsupportedOperationException("Attempt to cast to unsupported member type.");
|
|
}
|
|
return (Constructor<?>) mMember;
|
|
}
|
|
}
|