Merge "Make methods and fields accessible by default in art." into dalvik-dev
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index e64131f..b51822f 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -398,13 +398,6 @@
   };
 };
 
-struct AccessibleObjectOffsets : public CheckOffsets<AccessibleObject> {
-  AccessibleObjectOffsets()
-      : CheckOffsets<AccessibleObject>(false, "Ljava/lang/reflect/AccessibleObject;") {
-    offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AccessibleObject, java_flag_), "flag"));
-  };
-};
-
 struct FieldOffsets : public CheckOffsets<Field> {
   FieldOffsets() : CheckOffsets<Field>(false, "Ljava/lang/reflect/Field;") {
     // alphabetical references
@@ -637,7 +630,6 @@
 // ClassLinker::LinkFields.
 TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) {
   EXPECT_TRUE(ObjectOffsets().Check());
-  EXPECT_TRUE(AccessibleObjectOffsets().Check());
   EXPECT_TRUE(ConstructorOffsets().Check());
   EXPECT_TRUE(FieldOffsets().Check());
   EXPECT_TRUE(MethodOffsets().Check());
diff --git a/src/java_lang_reflect_Field.cc b/src/java_lang_reflect_Field.cc
index b23a29e..7e66dd9 100644
--- a/src/java_lang_reflect_Field.cc
+++ b/src/java_lang_reflect_Field.cc
@@ -194,6 +194,11 @@
   if (!CheckReceiver(env, javaObj, javaDeclaringClass, f, o)) {
     return;
   }
+  if (f->GetPrimitiveType() == Primitive::kPrimNot) {
+    Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
+        "Not a primitive field: %s", PrettyField(f).c_str());
+    return;
+  }
 
   // Widen the value if necessary (and possible).
   JValue wide_value;
diff --git a/src/object.h b/src/object.h
index 98b36ab..91fca63 100644
--- a/src/object.h
+++ b/src/object.h
@@ -373,17 +373,8 @@
   }
 };
 
-// C++ mirror of java.lang.reflect.AccessibleObject
-class MANAGED AccessibleObject : public Object {
- private:
-  // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
-  uint32_t java_flag_;  // can accessibility checks be bypassed
-  friend struct AccessibleObjectOffsets;  // for verifying offset information
-  DISALLOW_IMPLICIT_CONSTRUCTORS(AccessibleObject);
-};
-
 // C++ mirror of java.lang.reflect.Field
-class MANAGED Field : public AccessibleObject {
+class MANAGED Field : public Object {
  public:
   Class* GetDeclaringClass() const;
 
@@ -518,7 +509,7 @@
 };
 
 // C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor
-class MANAGED Method : public AccessibleObject {
+class MANAGED Method : public Object {
  public:
   // An function that invokes a method with an array of its arguments.
   typedef void InvokeStub(const Method* method,
diff --git a/src/reflection.cc b/src/reflection.cc
index 0bdfe82..f02c2d2 100644
--- a/src/reflection.cc
+++ b/src/reflection.cc
@@ -152,6 +152,7 @@
  */
 bool ConvertPrimitiveValue(Primitive::Type srcType, Primitive::Type dstType,
                            const JValue& src, JValue& dst) {
+  CHECK(srcType != Primitive::kPrimNot && dstType != Primitive::kPrimNot);
   switch (dstType) {
   case Primitive::kPrimBoolean:
   case Primitive::kPrimChar: