Bug 1209574 - Generate constants for non-accessible static final fields; r=snorp
authorJim Chen <nchen@mozilla.com>
Thu, 08 Oct 2015 15:25:49 -0400
changeset 266982 e3c955ddee7b89986d99ff8d61f0c433a6d446f9
parent 266981 25b2caf967ea2adefefe4b215d0bc4558fea9ac6
child 266983 fd8e1746870e57c537646dfd219847e55727cba9
push id29504
push usercbook@mozilla.com
push dateFri, 09 Oct 2015 09:43:23 +0000
treeherdermozilla-central@d01dd42e654b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1209574
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1209574 - Generate constants for non-accessible static final fields; r=snorp We try to generate a C++ constant for static final fields, but that was failing for inaccessible fields. Now we set the field to be accessible so that we do end up generating a C++ constant.
build/annotationProcessors/CodeGenerator.java
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
--- a/build/annotationProcessors/CodeGenerator.java
+++ b/build/annotationProcessors/CodeGenerator.java
@@ -387,16 +387,17 @@ public class CodeGenerator {
         }
 
         final boolean isStatic = Utils.isStatic(field);
         final boolean isFinal = Utils.isFinal(field);
 
         if (isStatic && isFinal && (type.isPrimitive() || type == String.class)) {
             Object val = null;
             try {
+                field.setAccessible(true);
                 val = field.get(null);
             } catch (final IllegalAccessException e) {
             }
 
             if (val != null && type.isPrimitive()) {
                 // For static final primitive fields, we can use a "static const" declaration.
                 header.append(
                     "public:\n" +
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -1548,24 +1548,16 @@ auto SQLiteBridgeException::New() -> SQL
 constexpr char SQLiteBridgeException::New2_t::name[];
 constexpr char SQLiteBridgeException::New2_t::signature[];
 
 auto SQLiteBridgeException::New(mozilla::jni::String::Param a0) -> SQLiteBridgeException::LocalRef
 {
     return mozilla::jni::Constructor<New2_t>::Call(nullptr, nullptr, a0);
 }
 
-constexpr char SQLiteBridgeException::SerialVersionUID_t::name[];
-constexpr char SQLiteBridgeException::SerialVersionUID_t::signature[];
-
-auto SQLiteBridgeException::SerialVersionUID() -> int64_t
-{
-    return mozilla::jni::Field<SerialVersionUID_t>::Get(nullptr, nullptr);
-}
-
 constexpr char Clipboard::name[];
 
 constexpr char Clipboard::ClearText_t::name[];
 constexpr char Clipboard::ClearText_t::signature[];
 
 auto Clipboard::ClearText() -> void
 {
     return mozilla::jni::Method<ClearText_t>::Call(nullptr, nullptr);
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -3908,31 +3908,17 @@ public:
         static const bool isMultithreaded = true;
         static const mozilla::jni::ExceptionMode exceptionMode =
                 mozilla::jni::ExceptionMode::ABORT;
     };
 
     static auto New(mozilla::jni::String::Param) -> SQLiteBridgeException::LocalRef;
 
 public:
-    struct SerialVersionUID_t {
-        typedef SQLiteBridgeException Owner;
-        typedef int64_t ReturnType;
-        typedef int64_t SetterType;
-        typedef mozilla::jni::Args<> Args;
-        static constexpr char name[] = "serialVersionUID";
-        static constexpr char signature[] =
-                "J";
-        static const bool isStatic = true;
-        static const bool isMultithreaded = true;
-        static const mozilla::jni::ExceptionMode exceptionMode =
-                mozilla::jni::ExceptionMode::ABORT;
-    };
-
-    static auto SerialVersionUID() -> int64_t;
+    static const int64_t SerialVersionUID = 1;
 
 };
 
 class Clipboard : public mozilla::jni::Class<Clipboard>
 {
 public:
     typedef mozilla::jni::Ref<Clipboard> Ref;
     typedef mozilla::jni::LocalRef<Clipboard> LocalRef;