Bug 1067056: Remove JavaDomKeyLocation and GeneratorOptions annotation. r=jchen

This commit is contained in:
Chris Kitching 2014-09-13 17:42:03 -07:00
parent b15d6b3049
commit 2a77d725c8
6 changed files with 5 additions and 180 deletions

View File

@ -4,9 +4,6 @@
package org.mozilla.gecko.annotationProcessors.classloader;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
/**
@ -46,37 +43,9 @@ public class JarClassIterator implements Iterator<ClassWithOptions> {
if (canonicalName == null || "null".equals(canonicalName)) {
// Anonymous inner class - unsupported.
return next();
} else {
String generateName = null;
for (Annotation annotation : ret.getAnnotations()) {
Class<?> annotationType = annotation.annotationType();
if (annotationType.getCanonicalName().equals("org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions")) {
try {
// Determine the explicitly-given name of the stub to generate, if any.
final Method generateNameMethod = annotationType.getDeclaredMethod("generatedClassName");
generateNameMethod.setAccessible(true);
generateName = (String) generateNameMethod.invoke(annotation);
break;
} catch (NoSuchMethodException e) {
System.err.println("Unable to find expected field on GeneratorOptions annotation. Did the signature change?");
e.printStackTrace(System.err);
System.exit(3);
} catch (IllegalAccessException e) {
System.err.println("IllegalAccessException reading fields on GeneratorOptions annotation. Seems the semantics of Reflection have changed...");
e.printStackTrace(System.err);
System.exit(4);
} catch (InvocationTargetException e) {
System.err.println("InvocationTargetException reading fields on GeneratorOptions annotation. This really shouldn't happen.");
e.printStackTrace(System.err);
System.exit(5);
}
}
}
if (generateName == null) {
generateName = ret.getSimpleName();
}
return new ClassWithOptions(ret, generateName);
}
return new ClassWithOptions(ret, ret.getSimpleName());
} catch (ClassNotFoundException e) {
System.err.println("Unable to enumerate class: " + className + ". Corrupted jar file?");
e.printStackTrace();

View File

@ -11,10 +11,6 @@ import java.util.concurrent.ArrayBlockingQueue;
import org.mozilla.gecko.AppConstants.Versions;
import org.mozilla.gecko.gfx.DisplayPortMetrics;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.mozglue.JNITarget;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions;
import org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI;
import android.graphics.Point;
import android.graphics.PointF;
@ -29,6 +25,8 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.MotionEvent;
import org.mozilla.gecko.mozglue.JNITarget;
import org.mozilla.gecko.mozglue.RobocopTarget;
/* We're not allowed to hold on to most events given to us
* so we save the parts of the events we want to use in GeckoEvent.
@ -122,8 +120,7 @@ public class GeckoEvent {
* The DomKeyLocation enum encapsulates the DOM KeyboardEvent's constants.
* @see https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent#Key_location_constants
*/
@GeneratorOptions(generatedClassName = "JavaDomKeyLocation")
@WrapEntireClassForJNI
@JNITarget
public enum DomKeyLocation {
DOM_KEY_LOCATION_STANDARD(0),
DOM_KEY_LOCATION_LEFT(1),

View File

@ -28,7 +28,6 @@ mgjar = add_java_jar('gecko-mozglue')
mgjar.sources += [
'mozglue/ByteBufferInputStream.java',
'mozglue/DirectBufferAllocator.java',
'mozglue/generatorannotations/GeneratorOptions.java',
'mozglue/generatorannotations/OptionalGeneratedParameter.java',
'mozglue/generatorannotations/WrapElementForJNI.java',
'mozglue/generatorannotations/WrapEntireClassForJNI.java',

View File

@ -1,17 +0,0 @@
/* 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.mozglue.generatorannotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface GeneratorOptions {
// Specifies a custom name for the generated C++ class. If left empty, is AndroidJavaClassName.
String generatedClassName() default "";
}

View File

@ -1321,100 +1321,6 @@ void GeckoAppShell::VibrateA(jlongArray a0, int32_t a1) {
AndroidBridge::HandleUncaughtException(env);
env->PopLocalFrame(nullptr);
}
jclass JavaDomKeyLocation::mDomKeyLocationClass = 0;
jmethodID JavaDomKeyLocation::jvalueOf = 0;
jmethodID JavaDomKeyLocation::jvalues = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_JOYSTICK = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_LEFT = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_MOBILE = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_NUMPAD = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_RIGHT = 0;
jfieldID JavaDomKeyLocation::jDOM_KEY_LOCATION_STANDARD = 0;
jfieldID JavaDomKeyLocation::jvalue = 0;
void JavaDomKeyLocation::InitStubs(JNIEnv *jEnv) {
initInit();
mDomKeyLocationClass = getClassGlobalRef("org/mozilla/gecko/GeckoEvent$DomKeyLocation");
jvalueOf = getStaticMethod("valueOf", "(Ljava/lang/String;)Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jvalues = getStaticMethod("values", "()[Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jDOM_KEY_LOCATION_JOYSTICK = getStaticField("DOM_KEY_LOCATION_JOYSTICK", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jDOM_KEY_LOCATION_LEFT = getStaticField("DOM_KEY_LOCATION_LEFT", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jDOM_KEY_LOCATION_MOBILE = getStaticField("DOM_KEY_LOCATION_MOBILE", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jDOM_KEY_LOCATION_NUMPAD = getStaticField("DOM_KEY_LOCATION_NUMPAD", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jDOM_KEY_LOCATION_RIGHT = getStaticField("DOM_KEY_LOCATION_RIGHT", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jDOM_KEY_LOCATION_STANDARD = getStaticField("DOM_KEY_LOCATION_STANDARD", "Lorg/mozilla/gecko/GeckoEvent$DomKeyLocation;");
jvalue = getField("value", "I");
}
JavaDomKeyLocation* JavaDomKeyLocation::Wrap(jobject obj) {
JNIEnv *env = GetJNIForThread();
JavaDomKeyLocation* ret = new JavaDomKeyLocation(obj, env);
env->DeleteLocalRef(obj);
return ret;
}
jobject JavaDomKeyLocation::valueOf(const nsAString& a0) {
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (env->PushLocalFrame(2) != 0) {
AndroidBridge::HandleUncaughtException(env);
MOZ_CRASH("Exception should have caused crash.");
}
jstring j0 = AndroidBridge::NewJavaString(env, a0);
jobject temp = env->CallStaticObjectMethod(mDomKeyLocationClass, jvalueOf, j0);
AndroidBridge::HandleUncaughtException(env);
jobject ret = static_cast<jobject>(env->PopLocalFrame(temp));
return ret;
}
jobjectArray JavaDomKeyLocation::values() {
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (env->PushLocalFrame(1) != 0) {
AndroidBridge::HandleUncaughtException(env);
MOZ_CRASH("Exception should have caused crash.");
}
jobject temp = env->CallStaticObjectMethod(mDomKeyLocationClass, jvalues);
AndroidBridge::HandleUncaughtException(env);
jobjectArray ret = static_cast<jobjectArray>(env->PopLocalFrame(temp));
return ret;
}
jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_JOYSTICK() {
JNIEnv *env = GetJNIForThread();
return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_JOYSTICK));
}
jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_LEFT() {
JNIEnv *env = GetJNIForThread();
return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_LEFT));
}
jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_MOBILE() {
JNIEnv *env = GetJNIForThread();
return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_MOBILE));
}
jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_NUMPAD() {
JNIEnv *env = GetJNIForThread();
return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_NUMPAD));
}
jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_RIGHT() {
JNIEnv *env = GetJNIForThread();
return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_RIGHT));
}
jobject JavaDomKeyLocation::getDOM_KEY_LOCATION_STANDARD() {
JNIEnv *env = GetJNIForThread();
return static_cast<jobject>(env->GetStaticObjectField(mDomKeyLocationClass, jDOM_KEY_LOCATION_STANDARD));
}
int32_t JavaDomKeyLocation::getvalue() {
JNIEnv *env = GetJNIForThread();
return env->GetIntField(wrapped_obj, jvalue);
}
jclass GeckoJavaSampler::mGeckoJavaSamplerClass = 0;
jmethodID GeckoJavaSampler::jGetFrameNameJavaProfilingWrapper = 0;
jmethodID GeckoJavaSampler::jGetSampleTimeJavaProfiling = 0;
@ -2573,7 +2479,6 @@ void Clipboard::SetClipboardText(const nsAString& a0) {
void InitStubs(JNIEnv *jEnv) {
GeckoAppShell::InitStubs(jEnv);
JavaDomKeyLocation::InitStubs(jEnv);
GeckoJavaSampler::InitStubs(jEnv);
RestrictedProfiles::InitStubs(jEnv);
SurfaceBits::InitStubs(jEnv);

View File

@ -190,34 +190,6 @@ protected:
static jmethodID jVibrateA;
};
class JavaDomKeyLocation : public AutoGlobalWrappedJavaObject {
public:
static void InitStubs(JNIEnv *jEnv);
static JavaDomKeyLocation* Wrap(jobject obj);
JavaDomKeyLocation(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
static jobject valueOf(const nsAString& a0);
static jobjectArray values();
static jobject getDOM_KEY_LOCATION_JOYSTICK();
static jobject getDOM_KEY_LOCATION_LEFT();
static jobject getDOM_KEY_LOCATION_MOBILE();
static jobject getDOM_KEY_LOCATION_NUMPAD();
static jobject getDOM_KEY_LOCATION_RIGHT();
static jobject getDOM_KEY_LOCATION_STANDARD();
int32_t getvalue();
JavaDomKeyLocation() : AutoGlobalWrappedJavaObject() {};
protected:
static jclass mDomKeyLocationClass;
static jmethodID jvalueOf;
static jmethodID jvalues;
static jfieldID jDOM_KEY_LOCATION_JOYSTICK;
static jfieldID jDOM_KEY_LOCATION_LEFT;
static jfieldID jDOM_KEY_LOCATION_MOBILE;
static jfieldID jDOM_KEY_LOCATION_NUMPAD;
static jfieldID jDOM_KEY_LOCATION_RIGHT;
static jfieldID jDOM_KEY_LOCATION_STANDARD;
static jfieldID jvalue;
};
class GeckoJavaSampler : public AutoGlobalWrappedJavaObject {
public:
static void InitStubs(JNIEnv *jEnv);