avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scottca...@apache.org
Subject svn commit: r1478244 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java
Date Thu, 02 May 2013 01:01:48 GMT
Author: scottcarey
Date: Thu May  2 01:01:47 2013
New Revision: 1478244

URL: http://svn.apache.org/r1478244
Log:
AVRO-1313. Java: Add system property avro.disable.unsafe for disabling
    use of sun.misc.Unsafe.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1478244&r1=1478243&r2=1478244&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu May  2 01:01:47 2013
@@ -42,6 +42,9 @@ Trunk (not yet released)
     AVRO-1282. Java: Use sun.misc.Unsafe to improve Reflect API Performance.
     (Leo Romanoff via scottcarey)
 
+    AVRO-1313. Java: Add system property avro.disable.unsafe for disabling
+    use of sun.misc.Unsafe. (scottcarey)
+
   BUG FIXES
 
     AVRO-1296. Python: Fix schemas retrieved from protocol types

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java?rev=1478244&r1=1478243&r2=1478244&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
Thu May  2 01:01:47 2013
@@ -32,6 +32,7 @@ class FieldAccessReflect extends FieldAc
 
     public ReflectionBasedAccessor(Field field) {
       this.field = field;
+      this.field.setAccessible(true);
     }
 
     @Override

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java?rev=1478244&r1=1478243&r2=1478244&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java Thu
May  2 01:01:47 2013
@@ -39,10 +39,12 @@ class ReflectionUtil {
     // so it is monomorphic and the JIT can inline
     FieldAccess access = null;
     try {
-      FieldAccess unsafeAccess = load(
-          "org.apache.avro.reflect.FieldAccessUnsafe", FieldAccess.class);
-      if (validate(unsafeAccess)) {
-        access = unsafeAccess;
+      if (null == System.getProperty("avro.disable.unsafe")) {
+        FieldAccess unsafeAccess = load(
+            "org.apache.avro.reflect.FieldAccessUnsafe", FieldAccess.class);
+        if (validate(unsafeAccess)) {
+          access = unsafeAccess;
+        }
       }
     } catch (Throwable ignored) {
     }
@@ -75,9 +77,9 @@ class ReflectionUtil {
   }
 
   private static final class AccessorTestClass {
-    boolean b = true;
-    byte by = 0xf;
-    char c = 'c';
+    private boolean b = true;
+    protected byte by = 0xf;
+    public char c = 'c';
     short s = 123;
     int i = 999;
     long l = 12345L;



Mime
View raw message