From 9c45cf75d0438700b29211be14970d8068ca02c5 Mon Sep 17 00:00:00 2001 From: aurimas Date: Mon, 13 Apr 2015 18:42:02 -0700 Subject: Move several annotations to annotations package. Move AccessedByNative, CalledByNativeUnchecked and UsedByReflection to annotations package where they belond. CalledByNative and NativeCall will be moved in a separate CL since they touch every file under the sun. BUG=None Review URL: https://codereview.chromium.org/1078343002 Cr-Commit-Position: refs/heads/master@{#324983} --- .../src/org/chromium/base/AccessedByNative.java | 20 ---------------- .../org/chromium/base/CalledByNativeUnchecked.java | 27 ---------------------- .../src/org/chromium/base/UsedByReflection.java | 24 ------------------- .../base/annotations/AccessedByNative.java | 20 ++++++++++++++++ .../base/annotations/CalledByNativeUnchecked.java | 27 ++++++++++++++++++++++ .../base/annotations/UsedByReflection.java | 24 +++++++++++++++++++ .../org/chromium/base/library_loader/Linker.java | 2 +- .../example/jni_generator/SampleForTests.java | 4 ++-- 8 files changed, 74 insertions(+), 74 deletions(-) delete mode 100644 base/android/java/src/org/chromium/base/AccessedByNative.java delete mode 100644 base/android/java/src/org/chromium/base/CalledByNativeUnchecked.java delete mode 100644 base/android/java/src/org/chromium/base/UsedByReflection.java create mode 100644 base/android/java/src/org/chromium/base/annotations/AccessedByNative.java create mode 100644 base/android/java/src/org/chromium/base/annotations/CalledByNativeUnchecked.java create mode 100644 base/android/java/src/org/chromium/base/annotations/UsedByReflection.java (limited to 'base') diff --git a/base/android/java/src/org/chromium/base/AccessedByNative.java b/base/android/java/src/org/chromium/base/AccessedByNative.java deleted file mode 100644 index 3e163fc..0000000 --- a/base/android/java/src/org/chromium/base/AccessedByNative.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.base; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @AccessedByNative is used to ensure proguard will keep this field, since it's - * only accessed by native. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.CLASS) -public @interface AccessedByNative { - public String value() default ""; -} diff --git a/base/android/java/src/org/chromium/base/CalledByNativeUnchecked.java b/base/android/java/src/org/chromium/base/CalledByNativeUnchecked.java deleted file mode 100644 index d5e9b74..0000000 --- a/base/android/java/src/org/chromium/base/CalledByNativeUnchecked.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.base; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @CalledByNativeUnchecked is used to generate JNI bindings that do not check for exceptions. - * It only makes sense to use this annotation on methods that declare a throws... spec. - * However, note that the exception received native side maybe an 'unchecked' (RuntimeExpception) - * such as NullPointerException, so the native code should differentiate these cases. - * Usage of this should be very rare; where possible handle exceptions in the Java side and use a - * return value to indicate success / failure. - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.CLASS) -public @interface CalledByNativeUnchecked { - /* - * If present, tells which inner class the method belongs to. - */ - public String value() default ""; -} diff --git a/base/android/java/src/org/chromium/base/UsedByReflection.java b/base/android/java/src/org/chromium/base/UsedByReflection.java deleted file mode 100644 index 7d18fb0..0000000 --- a/base/android/java/src/org/chromium/base/UsedByReflection.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.base; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; - -/** - * Annotation used for marking methods and fields that are called by reflection. - * Useful for keeping components that would otherwise be removed by Proguard. - * Use the value parameter to mention a file that calls this method. - * - * Note that adding this annotation to a method is not enough to guarantee that - * it is kept - either its class must be referenced elsewhere in the program, or - * the class must be annotated with this as well. - */ -@Target({ - ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, - ElementType.CONSTRUCTOR }) -public @interface UsedByReflection { - String value(); -} diff --git a/base/android/java/src/org/chromium/base/annotations/AccessedByNative.java b/base/android/java/src/org/chromium/base/annotations/AccessedByNative.java new file mode 100644 index 0000000..6df7c11 --- /dev/null +++ b/base/android/java/src/org/chromium/base/annotations/AccessedByNative.java @@ -0,0 +1,20 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @AccessedByNative is used to ensure proguard will keep this field, since it's + * only accessed by native. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.CLASS) +public @interface AccessedByNative { + public String value() default ""; +} diff --git a/base/android/java/src/org/chromium/base/annotations/CalledByNativeUnchecked.java b/base/android/java/src/org/chromium/base/annotations/CalledByNativeUnchecked.java new file mode 100644 index 0000000..c0abcbe6 --- /dev/null +++ b/base/android/java/src/org/chromium/base/annotations/CalledByNativeUnchecked.java @@ -0,0 +1,27 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @CalledByNativeUnchecked is used to generate JNI bindings that do not check for exceptions. + * It only makes sense to use this annotation on methods that declare a throws... spec. + * However, note that the exception received native side maybe an 'unchecked' (RuntimeExpception) + * such as NullPointerException, so the native code should differentiate these cases. + * Usage of this should be very rare; where possible handle exceptions in the Java side and use a + * return value to indicate success / failure. + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +public @interface CalledByNativeUnchecked { + /* + * If present, tells which inner class the method belongs to. + */ + public String value() default ""; +} diff --git a/base/android/java/src/org/chromium/base/annotations/UsedByReflection.java b/base/android/java/src/org/chromium/base/annotations/UsedByReflection.java new file mode 100644 index 0000000..a2af704 --- /dev/null +++ b/base/android/java/src/org/chromium/base/annotations/UsedByReflection.java @@ -0,0 +1,24 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** + * Annotation used for marking methods and fields that are called by reflection. + * Useful for keeping components that would otherwise be removed by Proguard. + * Use the value parameter to mention a file that calls this method. + * + * Note that adding this annotation to a method is not enough to guarantee that + * it is kept - either its class must be referenced elsewhere in the program, or + * the class must be annotated with this as well. + */ +@Target({ + ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, + ElementType.CONSTRUCTOR }) +public @interface UsedByReflection { + String value(); +} diff --git a/base/android/java/src/org/chromium/base/library_loader/Linker.java b/base/android/java/src/org/chromium/base/library_loader/Linker.java index dbeb758..7e50998 100644 --- a/base/android/java/src/org/chromium/base/library_loader/Linker.java +++ b/base/android/java/src/org/chromium/base/library_loader/Linker.java @@ -10,10 +10,10 @@ import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.util.Log; -import org.chromium.base.AccessedByNative; import org.chromium.base.CalledByNative; import org.chromium.base.SysUtils; import org.chromium.base.ThreadUtils; +import org.chromium.base.annotations.AccessedByNative; import java.io.FileNotFoundException; import java.util.HashMap; diff --git a/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java b/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java index 732fe6e..89bee99 100644 --- a/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java +++ b/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java @@ -6,11 +6,11 @@ package org.chromium.example.jni_generator; import android.graphics.Rect; -import org.chromium.base.AccessedByNative; import org.chromium.base.CalledByNative; -import org.chromium.base.CalledByNativeUnchecked; import org.chromium.base.JNINamespace; import org.chromium.base.NativeClassQualifiedName; +import org.chromium.base.annotations.AccessedByNative; +import org.chromium.base.annotations.CalledByNativeUnchecked; import java.util.ArrayList; import java.util.Iterator; -- cgit v1.1