You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/08/20 22:54:31 UTC
svn commit: r433041 [12/13] - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang:
./ ref/ reflect/
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/VirtualMachineError.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/VirtualMachineError.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/VirtualMachineError.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/VirtualMachineError.java Sun Aug 20 13:54:27 2006
@@ -1,46 +1,46 @@
-/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang;
-
-
-/**
- * This class is the superclass of all classes which represent errors that occur
- * during the operation of the virtual machine.
- *
- * @see Error
- */
-public abstract class VirtualMachineError extends Error {
-
- private static final long serialVersionUID = 4161983926571568670L;
-
- /**
- * Constructs a new instance of this class with its walkback filled in.
- */
- public VirtualMachineError() {
- super();
- }
-
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param detailMessage
- * String The detail message for the exception.
- */
- public VirtualMachineError(String detailMessage) {
- super(detailMessage);
- }
-}
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang;
+
+
+/**
+ * This class is the superclass of all classes which represent errors that occur
+ * during the operation of the virtual machine.
+ *
+ * @see Error
+ */
+public abstract class VirtualMachineError extends Error {
+
+ private static final long serialVersionUID = 4161983926571568670L;
+
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
+ public VirtualMachineError() {
+ super();
+ }
+
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param detailMessage
+ * String The detail message for the exception.
+ */
+ public VirtualMachineError(String detailMessage) {
+ super(detailMessage);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/VirtualMachineError.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java Sun Aug 20 13:54:27 2006
@@ -1,49 +1,49 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang;
-
-import java.lang.reflect.Method;
-
-/**
- * This class is a placeholder class for the Java keyword <code>void</code>
- * @since 1.1
- */
-public final class Void extends Object {
-
- /**
- * The {@link Class} instance that represents primitive type
- * <code>void</code>.
- */
- public static final Class<Void> TYPE = lookupType();
-
- // Note: This can't be set to "void.class", since *that* is
- // defined to be "java.lang.Void.TYPE";
-
- @SuppressWarnings("unchecked")
- private static Class<Void> lookupType() {
- Class<?> voidType = null;
- try {
- Method method = Runnable.class.getMethod("run", new Class[0]);
- voidType = method.getReturnType();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return (Class<Void>) voidType;
- }
-
- private Void() {
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang;
+
+import java.lang.reflect.Method;
+
+/**
+ * This class is a placeholder class for the Java keyword <code>void</code>
+ * @since 1.1
+ */
+public final class Void extends Object {
+
+ /**
+ * The {@link Class} instance that represents primitive type
+ * <code>void</code>.
+ */
+ public static final Class<Void> TYPE = lookupType();
+
+ // Note: This can't be set to "void.class", since *that* is
+ // defined to be "java.lang.Void.TYPE";
+
+ @SuppressWarnings("unchecked")
+ private static Class<Void> lookupType() {
+ Class<?> voidType = null;
+ try {
+ Method method = Runnable.class.getMethod("run", new Class[0]);
+ voidType = method.getReturnType();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return (Class<Void>) voidType;
+ }
+
+ private Void() {
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ref/ReferenceQueue.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ref/ReferenceQueue.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ref/ReferenceQueue.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ref/ReferenceQueue.java Sun Aug 20 13:54:27 2006
@@ -1,160 +1,160 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.ref;
-
-
-/**
- * The implementation of this class is provided. The non-public implementation
- * details are documented so the vm vendor can use the implementation.
- *
- * ReferenceQueue is the container on which reference objects are enqueued when
- * their reachability type is detected for the referent.
- *
- * @since JDK1.2
- */
-public class ReferenceQueue<T> extends Object {
-
- private Reference<? extends T>[] references;
-
- private int head, tail;
-
- private boolean empty;
-
- static private final int DEFAULT_QUEUE_SIZE = 128;
-
- /**
- * Returns the next available reference from the queue if one is enqueued,
- * null otherwise. Does not wait for a reference to become available.
- *
- * @return Reference next available Reference or NULL.
- */
- public Reference<? extends T> poll() {
- Reference<? extends T> ref;
-
- synchronized (this) {
- if (empty) {
- return null;
- }
- ref = references[head++];
- ref.dequeue();
- if (head == references.length) {
- head = 0;
- }
- if (head == tail) {
- empty = true;
- }
- }
- return ref;
- }
-
- /**
- * Return the next available enqueued reference on the queue, blocking
- * indefinately until one is available.
- *
- * @return Reference a Reference object if one is available, null otherwise.
- * @exception InterruptedException
- * to interrupt the wait.
- */
- public Reference<? extends T> remove() throws InterruptedException {
- return remove(0L);
- }
-
- /**
- * Return the next available enqueued reference on the queue, blocking up to
- * the time given until one is available. Return null if no reference became
- * available.
- *
- * @param timeout
- * maximum time spent waiting for a reference object to become
- * available.
- * @return Reference a Reference object if one is available, null otherwise.
- * @exception IllegalArgumentException
- * if the wait period is negative. InterruptedException to
- * interrupt the wait.
- */
- public Reference<? extends T> remove(long timeout) throws IllegalArgumentException,
- InterruptedException {
- if (timeout < 0) {
- throw new IllegalArgumentException();
- }
-
- Reference<? extends T> ref;
- synchronized (this) {
- if (empty) {
- wait(timeout);
- if (empty) {
- return null;
- }
- }
- ref = references[head++];
- ref.dequeue();
- if (head == references.length) {
- head = 0;
- }
- if (head == tail) {
- empty = true;
- } else {
- notifyAll();
- }
- }
- return ref;
- }
-
- /**
- * Enqueue the reference object on the receiver.
- *
- * @param reference
- * reference object to be enqueued.
- * @return boolean true if reference is enqueued. false if reference failed
- * to enqueue.
- */
- boolean enqueue(Reference<? extends T> reference) {
- synchronized (this) {
- if (!empty && head == tail) {
- /* Queue is full - grow */
- int newQueueSize = (int) (references.length * 1.10);
- Reference<? extends T> newQueue[] =
- (Reference<? extends T>[])new Reference[newQueueSize];
- System.arraycopy(references, head, newQueue, 0,
- references.length - head);
- if (tail > 0) {
- System.arraycopy(references, 0, newQueue, references.length
- - head, tail);
- }
- head = 0;
- tail = references.length;
- references = newQueue;
- }
- references[tail++] = reference;
- if (tail == references.length) {
- tail = 0;
- }
- empty = false;
- notifyAll();
- }
- return true;
- }
-
- /**
- * Constructs a new instance of this class.
- */
- public ReferenceQueue() {
- references = (Reference<? extends T>[])new Reference[DEFAULT_QUEUE_SIZE];
- head = 0;
- tail = 0;
- empty = true;
- }
-}
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.ref;
+
+
+/**
+ * The implementation of this class is provided. The non-public implementation
+ * details are documented so the vm vendor can use the implementation.
+ *
+ * ReferenceQueue is the container on which reference objects are enqueued when
+ * their reachability type is detected for the referent.
+ *
+ * @since JDK1.2
+ */
+public class ReferenceQueue<T> extends Object {
+
+ private Reference<? extends T>[] references;
+
+ private int head, tail;
+
+ private boolean empty;
+
+ static private final int DEFAULT_QUEUE_SIZE = 128;
+
+ /**
+ * Returns the next available reference from the queue if one is enqueued,
+ * null otherwise. Does not wait for a reference to become available.
+ *
+ * @return Reference next available Reference or NULL.
+ */
+ public Reference<? extends T> poll() {
+ Reference<? extends T> ref;
+
+ synchronized (this) {
+ if (empty) {
+ return null;
+ }
+ ref = references[head++];
+ ref.dequeue();
+ if (head == references.length) {
+ head = 0;
+ }
+ if (head == tail) {
+ empty = true;
+ }
+ }
+ return ref;
+ }
+
+ /**
+ * Return the next available enqueued reference on the queue, blocking
+ * indefinately until one is available.
+ *
+ * @return Reference a Reference object if one is available, null otherwise.
+ * @exception InterruptedException
+ * to interrupt the wait.
+ */
+ public Reference<? extends T> remove() throws InterruptedException {
+ return remove(0L);
+ }
+
+ /**
+ * Return the next available enqueued reference on the queue, blocking up to
+ * the time given until one is available. Return null if no reference became
+ * available.
+ *
+ * @param timeout
+ * maximum time spent waiting for a reference object to become
+ * available.
+ * @return Reference a Reference object if one is available, null otherwise.
+ * @exception IllegalArgumentException
+ * if the wait period is negative. InterruptedException to
+ * interrupt the wait.
+ */
+ public Reference<? extends T> remove(long timeout) throws IllegalArgumentException,
+ InterruptedException {
+ if (timeout < 0) {
+ throw new IllegalArgumentException();
+ }
+
+ Reference<? extends T> ref;
+ synchronized (this) {
+ if (empty) {
+ wait(timeout);
+ if (empty) {
+ return null;
+ }
+ }
+ ref = references[head++];
+ ref.dequeue();
+ if (head == references.length) {
+ head = 0;
+ }
+ if (head == tail) {
+ empty = true;
+ } else {
+ notifyAll();
+ }
+ }
+ return ref;
+ }
+
+ /**
+ * Enqueue the reference object on the receiver.
+ *
+ * @param reference
+ * reference object to be enqueued.
+ * @return boolean true if reference is enqueued. false if reference failed
+ * to enqueue.
+ */
+ boolean enqueue(Reference<? extends T> reference) {
+ synchronized (this) {
+ if (!empty && head == tail) {
+ /* Queue is full - grow */
+ int newQueueSize = (int) (references.length * 1.10);
+ Reference<? extends T> newQueue[] =
+ (Reference<? extends T>[])new Reference[newQueueSize];
+ System.arraycopy(references, head, newQueue, 0,
+ references.length - head);
+ if (tail > 0) {
+ System.arraycopy(references, 0, newQueue, references.length
+ - head, tail);
+ }
+ head = 0;
+ tail = references.length;
+ references = newQueue;
+ }
+ references[tail++] = reference;
+ if (tail == references.length) {
+ tail = 0;
+ }
+ empty = false;
+ notifyAll();
+ }
+ return true;
+ }
+
+ /**
+ * Constructs a new instance of this class.
+ */
+ public ReferenceQueue() {
+ references = (Reference<? extends T>[])new Reference[DEFAULT_QUEUE_SIZE];
+ head = 0;
+ tail = 0;
+ empty = true;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ref/ReferenceQueue.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/AnnotatedElement.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/AnnotatedElement.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/AnnotatedElement.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/AnnotatedElement.java Sun Aug 20 13:54:27 2006
@@ -1,78 +1,78 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package java.lang.reflect;
-
-import java.lang.annotation.Annotation;
-
-/**
- * <p>
- * An interface implemented an annotated element to enable reflective access to
- * annotation information.
- * </p>
- *
- * @since 1.5
- */
-public interface AnnotatedElement {
-
- /**
- * <p>
- * Gets the {@link Annotation} for this element for the annotation type
- * passed, if it exists.
- * </p>
- *
- * @param annotationType The Class instance of the annotation to search for.
- * @return The {@link Annotation} for this element or <code>null</code>.
- * @throws NullPointerException if <code>annotationType</code> is
- * <code>null</code>.
- */
- <T extends Annotation> T getAnnotation(Class<T> annotationType);
-
- /**
- * <p>
- * Gets all {@link Annotation}s for this element.
- * </p>
- *
- * @return An array of {@link Annotation}s, which may be empty, but never
- * <code>null</code>.
- */
- Annotation[] getAnnotations();
-
- /**
- * <p>
- * Gets all {@link Annotation}s that are explicitly declared by this
- * element (not inherited).
- * </p>
- *
- * @return An array of {@link Annotation}s, which may be empty, but never
- * <code>null</code>.
- */
- Annotation[] getDeclaredAnnotations();
-
- /**
- * <p>
- * Determines if this element has an annotation for the annotation type
- * passed.
- * </p>
- *
- * @param annotationType The class instance of the annotation to search for.
- * @return <code>true</code> if the annotation exists, otherwise
- * <code>false</code>.
- * @throws NullPointerException if <code>annotationType</code> is
- * <code>null</code>.
- */
- boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
-}
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package java.lang.reflect;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * <p>
+ * An interface implemented an annotated element to enable reflective access to
+ * annotation information.
+ * </p>
+ *
+ * @since 1.5
+ */
+public interface AnnotatedElement {
+
+ /**
+ * <p>
+ * Gets the {@link Annotation} for this element for the annotation type
+ * passed, if it exists.
+ * </p>
+ *
+ * @param annotationType The Class instance of the annotation to search for.
+ * @return The {@link Annotation} for this element or <code>null</code>.
+ * @throws NullPointerException if <code>annotationType</code> is
+ * <code>null</code>.
+ */
+ <T extends Annotation> T getAnnotation(Class<T> annotationType);
+
+ /**
+ * <p>
+ * Gets all {@link Annotation}s for this element.
+ * </p>
+ *
+ * @return An array of {@link Annotation}s, which may be empty, but never
+ * <code>null</code>.
+ */
+ Annotation[] getAnnotations();
+
+ /**
+ * <p>
+ * Gets all {@link Annotation}s that are explicitly declared by this
+ * element (not inherited).
+ * </p>
+ *
+ * @return An array of {@link Annotation}s, which may be empty, but never
+ * <code>null</code>.
+ */
+ Annotation[] getDeclaredAnnotations();
+
+ /**
+ * <p>
+ * Determines if this element has an annotation for the annotation type
+ * passed.
+ * </p>
+ *
+ * @param annotationType The class instance of the annotation to search for.
+ * @return <code>true</code> if the annotation exists, otherwise
+ * <code>false</code>.
+ * @throws NullPointerException if <code>annotationType</code> is
+ * <code>null</code>.
+ */
+ boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/AnnotatedElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericArrayType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericArrayType.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericArrayType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericArrayType.java Sun Aug 20 13:54:27 2006
@@ -1,40 +1,40 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package java.lang.reflect;
-
-/**
- * <p>
- * Represents an array type with a component type that is parameterized or a
- * type variable.
- * </p>
- *
- * @since 1.5
- */
-public interface GenericArrayType extends Type {
- /**
- * <p>
- * The {@link Type} that represents the component type of the array.
- * </p>
- *
- * @return A {@link Type} instance.
- * @throws TypeNotPresentException if the component type points to a missing
- * type.
- * @throws MalformedParameterizedTypeException if the component type points
- * to a type that can't be instantiated for some reason.
- */
- Type getGenericComponentType();
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package java.lang.reflect;
+
+/**
+ * <p>
+ * Represents an array type with a component type that is parameterized or a
+ * type variable.
+ * </p>
+ *
+ * @since 1.5
+ */
+public interface GenericArrayType extends Type {
+ /**
+ * <p>
+ * The {@link Type} that represents the component type of the array.
+ * </p>
+ *
+ * @return A {@link Type} instance.
+ * @throws TypeNotPresentException if the component type points to a missing
+ * type.
+ * @throws MalformedParameterizedTypeException if the component type points
+ * to a type that can't be instantiated for some reason.
+ */
+ Type getGenericComponentType();
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericArrayType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericSignatureFormatError.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericSignatureFormatError.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericSignatureFormatError.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericSignatureFormatError.java Sun Aug 20 13:54:27 2006
@@ -1,33 +1,33 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package java.lang.reflect;
-
-/**
- * <p>
- * Indicates that a malformed signature has been encountered via a reflective
- * method.
- * </p>
- *
- * @since 1.5
- */
-public class GenericSignatureFormatError extends ClassFormatError {
- private static final long serialVersionUID = 6709919147137911034L;
-
- public GenericSignatureFormatError() {
- super();
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package java.lang.reflect;
+
+/**
+ * <p>
+ * Indicates that a malformed signature has been encountered via a reflective
+ * method.
+ * </p>
+ *
+ * @since 1.5
+ */
+public class GenericSignatureFormatError extends ClassFormatError {
+ private static final long serialVersionUID = 6709919147137911034L;
+
+ public GenericSignatureFormatError() {
+ super();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/GenericSignatureFormatError.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationHandler.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationHandler.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationHandler.java Sun Aug 20 13:54:27 2006
@@ -1,48 +1,48 @@
-/* Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.reflect;
-
-
-/**
- * Implementors of this interface decode and dispatch methods sent to proxy
- * instances.
- *
- * @see Proxy
- */
-public interface InvocationHandler {
- /**
- * Return the result of decoding and dispatching the method which was
- * originally sent to the proxy instance.
- *
- * @param proxy
- * the proxy instance which was the receiver of the method.
- * @param method
- * the Method invoked on the proxy instance.
- * @param args
- * an array of objects containing the parameters passed to the
- * method, or null if no arguments are expected. primitive types
- * are wrapped in the appropriate class.
- * @return the result of executing the method
- *
- * @throws Throwable
- * if an exception was thrown by the invoked method. The
- * exception must match one of the declared exception types for
- * the invoked method or any unchecked exception type. If not
- * then an UndeclaredThrowableException is thrown.
- */
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable;
-}
+/* Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+
+/**
+ * Implementors of this interface decode and dispatch methods sent to proxy
+ * instances.
+ *
+ * @see Proxy
+ */
+public interface InvocationHandler {
+ /**
+ * Return the result of decoding and dispatching the method which was
+ * originally sent to the proxy instance.
+ *
+ * @param proxy
+ * the proxy instance which was the receiver of the method.
+ * @param method
+ * the Method invoked on the proxy instance.
+ * @param args
+ * an array of objects containing the parameters passed to the
+ * method, or null if no arguments are expected. primitive types
+ * are wrapped in the appropriate class.
+ * @return the result of executing the method
+ *
+ * @throws Throwable
+ * if an exception was thrown by the invoked method. The
+ * exception must match one of the declared exception types for
+ * the invoked method or any unchecked exception type. If not
+ * then an UndeclaredThrowableException is thrown.
+ */
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable;
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationTargetException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationTargetException.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationTargetException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationTargetException.java Sun Aug 20 13:54:27 2006
@@ -1,82 +1,82 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.reflect;
-
-
-/**
- * This class provides a wrapper for an exception thrown by a Method or
- * Constructor invocation.
- *
- * @see java.lang.reflect.Method#invoke
- * @see java.lang.reflect.Constructor#newInstance
- */
-public class InvocationTargetException extends Exception {
-
- private static final long serialVersionUID = 4085088731926701167L;
-
- private Throwable target;
-
- /**
- * Constructs a new instance of this class with its walkback filled in.
- */
- protected InvocationTargetException() {
- super((Throwable) null);
- }
-
- /**
- * Constructs a new instance of this class with its walkback and target
- * exception filled in.
- *
- * @param exception
- * Throwable The exception which occurred while running the
- * Method or Constructor.
- */
- public InvocationTargetException(Throwable exception) {
- super(null, exception);
- target = exception;
- }
-
- /**
- * Constructs a new instance of this class with its walkback, target
- * exception and message filled in.
- *
- * @param detailMessage
- * String The detail message for the exception.
- * @param exception
- * Throwable The exception which occurred while running the
- * Method or Constructor.
- */
- public InvocationTargetException(Throwable exception, String detailMessage) {
- super(detailMessage, exception);
- target = exception;
- }
-
- /**
- * Answers the exception which caused the receiver to be thrown.
- */
- public Throwable getTargetException() {
- return target;
- }
-
- /**
- * Answers the cause of this Throwable, or null if there is no cause.
- *
- * @return Throwable The receiver's cause.
- */
- public Throwable getCause() {
- return target;
- }
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+
+/**
+ * This class provides a wrapper for an exception thrown by a Method or
+ * Constructor invocation.
+ *
+ * @see java.lang.reflect.Method#invoke
+ * @see java.lang.reflect.Constructor#newInstance
+ */
+public class InvocationTargetException extends Exception {
+
+ private static final long serialVersionUID = 4085088731926701167L;
+
+ private Throwable target;
+
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
+ protected InvocationTargetException() {
+ super((Throwable) null);
+ }
+
+ /**
+ * Constructs a new instance of this class with its walkback and target
+ * exception filled in.
+ *
+ * @param exception
+ * Throwable The exception which occurred while running the
+ * Method or Constructor.
+ */
+ public InvocationTargetException(Throwable exception) {
+ super(null, exception);
+ target = exception;
+ }
+
+ /**
+ * Constructs a new instance of this class with its walkback, target
+ * exception and message filled in.
+ *
+ * @param detailMessage
+ * String The detail message for the exception.
+ * @param exception
+ * Throwable The exception which occurred while running the
+ * Method or Constructor.
+ */
+ public InvocationTargetException(Throwable exception, String detailMessage) {
+ super(detailMessage, exception);
+ target = exception;
+ }
+
+ /**
+ * Answers the exception which caused the receiver to be thrown.
+ */
+ public Throwable getTargetException() {
+ return target;
+ }
+
+ /**
+ * Answers the cause of this Throwable, or null if there is no cause.
+ *
+ * @return Throwable The receiver's cause.
+ */
+ public Throwable getCause() {
+ return target;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/InvocationTargetException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/MalformedParameterizedTypeException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/MalformedParameterizedTypeException.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/MalformedParameterizedTypeException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/MalformedParameterizedTypeException.java Sun Aug 20 13:54:27 2006
@@ -1,36 +1,36 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package java.lang.reflect;
-
-/**
- * <p>
- * Indicates that a malformed parameterized type has been accessed by a
- * reflected method.
- * </p>
- *
- * @since 1.5
- */
-public class MalformedParameterizedTypeException extends RuntimeException {
- private static final long serialVersionUID = -5696557788586220964L;
-
- /**
- * <p>Constructs an instance.</p>
- */
- public MalformedParameterizedTypeException() {
- super();
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package java.lang.reflect;
+
+/**
+ * <p>
+ * Indicates that a malformed parameterized type has been accessed by a
+ * reflected method.
+ * </p>
+ *
+ * @since 1.5
+ */
+public class MalformedParameterizedTypeException extends RuntimeException {
+ private static final long serialVersionUID = -5696557788586220964L;
+
+ /**
+ * <p>Constructs an instance.</p>
+ */
+ public MalformedParameterizedTypeException() {
+ super();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/MalformedParameterizedTypeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java Sun Aug 20 13:54:27 2006
@@ -1,63 +1,63 @@
-/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.reflect;
-
-
-/**
- * Implementors of this interface model a class member.
- *
- * @see Field
- * @see Constructor
- * @see Method
- */
-public interface Member {
-
- public static final int PUBLIC = 0;
-
- public static final int DECLARED = 1;
-
- /**
- * Return the {@link Class} associated with the class that defined this
- * member.
- *
- * @return the declaring class
- */
- @SuppressWarnings("unchecked")
- Class getDeclaringClass();
-
- /**
- * Return the modifiers for the member. The Modifier class should be used to
- * decode the result.
- *
- * @return the modifiers
- * @see java.lang.reflect.Modifier
- */
- int getModifiers();
-
- /**
- * Return the name of the member.
- *
- * @return the name
- */
- String getName();
-
- /**
- * <p>Indicates whether or not this member is synthetic (artificially introduced by
- * the compiler).</p>
- * @return A value of <code>true</code> if synthetic, otherwise <code>false</code>.
- */
- boolean isSynthetic();
-}
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+
+/**
+ * Implementors of this interface model a class member.
+ *
+ * @see Field
+ * @see Constructor
+ * @see Method
+ */
+public interface Member {
+
+ public static final int PUBLIC = 0;
+
+ public static final int DECLARED = 1;
+
+ /**
+ * Return the {@link Class} associated with the class that defined this
+ * member.
+ *
+ * @return the declaring class
+ */
+ @SuppressWarnings("unchecked")
+ Class getDeclaringClass();
+
+ /**
+ * Return the modifiers for the member. The Modifier class should be used to
+ * decode the result.
+ *
+ * @return the modifiers
+ * @see java.lang.reflect.Modifier
+ */
+ int getModifiers();
+
+ /**
+ * Return the name of the member.
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * <p>Indicates whether or not this member is synthetic (artificially introduced by
+ * the compiler).</p>
+ * @return A value of <code>true</code> if synthetic, otherwise <code>false</code>.
+ */
+ boolean isSynthetic();
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Member.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Modifier.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Modifier.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Modifier.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Modifier.java Sun Aug 20 13:54:27 2006
@@ -1,255 +1,255 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.reflect;
-
-
-/**
- * This class provides methods to decode class and member modifiers.
- *
- * @see java.lang.Class#getModifiers()
- * @see java.lang.reflect.Member#getModifiers()
- */
-public class Modifier {
-
- public static final int PUBLIC = 0x1;
-
- public static final int PRIVATE = 0x2;
-
- public static final int PROTECTED = 0x4;
-
- public static final int STATIC = 0x8;
-
- public static final int FINAL = 0x10;
-
- public static final int SYNCHRONIZED = 0x20;
-
- public static final int VOLATILE = 0x40;
-
- public static final int TRANSIENT = 0x80;
-
- public static final int NATIVE = 0x100;
-
- public static final int INTERFACE = 0x200;
-
- public static final int ABSTRACT = 0x400;
-
- public static final int STRICT = 0x800;
-
- // Non-public types required by Java 5 update to class file format
- static final int BRIDGE = 0x40;
-
- static final int VARARGS = 0x80;
-
- static final int SYNTHETIC = 0x1000;
-
- static final int ANNOTATION = 0x2000;
-
- static final int ENUM = 0x4000;
-
- public Modifier() {
- }
-
- /**
- * Return true if the specified modifiers contain the <code>abstract</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the abstract modifier
- */
- public static boolean isAbstract(int modifiers) {
- return ((modifiers & ABSTRACT) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>final</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the final modifier
- */
- public static boolean isFinal(int modifiers) {
- return ((modifiers & FINAL) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>interface</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the interface modifier
- */
- public static boolean isInterface(int modifiers) {
- return ((modifiers & INTERFACE) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>native</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the native modifier
- */
- public static boolean isNative(int modifiers) {
- return ((modifiers & NATIVE) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>private</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the private modifier
- */
- public static boolean isPrivate(int modifiers) {
- return ((modifiers & PRIVATE) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>protected</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the protected modifier
- */
- public static boolean isProtected(int modifiers) {
- return ((modifiers & PROTECTED) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>public</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the abstract modifier
- */
- public static boolean isPublic(int modifiers) {
- return ((modifiers & PUBLIC) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>static</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the static modifier
- */
- public static boolean isStatic(int modifiers) {
- return ((modifiers & STATIC) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>strict</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the strict modifier
- */
- public static boolean isStrict(int modifiers) {
- return ((modifiers & STRICT) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the
- * <code>synchronized</code> modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the synchronized modifier
- */
- public static boolean isSynchronized(int modifiers) {
- return ((modifiers & SYNCHRONIZED) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>transient</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the transient modifier
- */
- public static boolean isTransient(int modifiers) {
- return ((modifiers & TRANSIENT) != 0);
- }
-
- /**
- * Return true if the specified modifiers contain the <code>volatile</code>
- * modifier, false otherwise.
- *
- * @param modifiers
- * the modifiers to test
- * @return if the modifiers contain the volatile modifier
- */
- public static boolean isVolatile(int modifiers) {
- return ((modifiers & VOLATILE) != 0);
- }
-
- /**
- * Answers a string containing the string representation of all modifiers
- * present in the specified modifiers.
- *
- * Modifiers appear in the order specified by the Java Language
- * Specification:
- * <code>public private protected abstract static final transient volatile native synchronized interface strict</code>
- *
- * @param modifiers
- * the modifiers to print
- * @return a printable representation of the modifiers
- */
- public static java.lang.String toString(int modifiers) {
- StringBuffer buf;
-
- buf = new StringBuffer();
-
- if (isPublic(modifiers))
- buf.append("public ");
- if (isProtected(modifiers))
- buf.append("protected ");
- if (isPrivate(modifiers))
- buf.append("private ");
- if (isAbstract(modifiers))
- buf.append("abstract ");
- if (isStatic(modifiers))
- buf.append("static ");
- if (isFinal(modifiers))
- buf.append("final ");
- if (isTransient(modifiers))
- buf.append("transient ");
- if (isVolatile(modifiers))
- buf.append("volatile ");
- if (isSynchronized(modifiers))
- buf.append("synchronized ");
- if (isNative(modifiers))
- buf.append("native ");
- if (isStrict(modifiers))
- buf.append("strictfp ");
- if (isInterface(modifiers))
- buf.append("interface ");
- if (buf.length() == 0)
- return "";
- buf.setLength(buf.length() - 1);
- return buf.toString();
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+
+/**
+ * This class provides methods to decode class and member modifiers.
+ *
+ * @see java.lang.Class#getModifiers()
+ * @see java.lang.reflect.Member#getModifiers()
+ */
+public class Modifier {
+
+ public static final int PUBLIC = 0x1;
+
+ public static final int PRIVATE = 0x2;
+
+ public static final int PROTECTED = 0x4;
+
+ public static final int STATIC = 0x8;
+
+ public static final int FINAL = 0x10;
+
+ public static final int SYNCHRONIZED = 0x20;
+
+ public static final int VOLATILE = 0x40;
+
+ public static final int TRANSIENT = 0x80;
+
+ public static final int NATIVE = 0x100;
+
+ public static final int INTERFACE = 0x200;
+
+ public static final int ABSTRACT = 0x400;
+
+ public static final int STRICT = 0x800;
+
+ // Non-public types required by Java 5 update to class file format
+ static final int BRIDGE = 0x40;
+
+ static final int VARARGS = 0x80;
+
+ static final int SYNTHETIC = 0x1000;
+
+ static final int ANNOTATION = 0x2000;
+
+ static final int ENUM = 0x4000;
+
+ public Modifier() {
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>abstract</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the abstract modifier
+ */
+ public static boolean isAbstract(int modifiers) {
+ return ((modifiers & ABSTRACT) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>final</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the final modifier
+ */
+ public static boolean isFinal(int modifiers) {
+ return ((modifiers & FINAL) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>interface</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the interface modifier
+ */
+ public static boolean isInterface(int modifiers) {
+ return ((modifiers & INTERFACE) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>native</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the native modifier
+ */
+ public static boolean isNative(int modifiers) {
+ return ((modifiers & NATIVE) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>private</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the private modifier
+ */
+ public static boolean isPrivate(int modifiers) {
+ return ((modifiers & PRIVATE) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>protected</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the protected modifier
+ */
+ public static boolean isProtected(int modifiers) {
+ return ((modifiers & PROTECTED) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>public</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the abstract modifier
+ */
+ public static boolean isPublic(int modifiers) {
+ return ((modifiers & PUBLIC) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>static</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the static modifier
+ */
+ public static boolean isStatic(int modifiers) {
+ return ((modifiers & STATIC) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>strict</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the strict modifier
+ */
+ public static boolean isStrict(int modifiers) {
+ return ((modifiers & STRICT) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the
+ * <code>synchronized</code> modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the synchronized modifier
+ */
+ public static boolean isSynchronized(int modifiers) {
+ return ((modifiers & SYNCHRONIZED) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>transient</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the transient modifier
+ */
+ public static boolean isTransient(int modifiers) {
+ return ((modifiers & TRANSIENT) != 0);
+ }
+
+ /**
+ * Return true if the specified modifiers contain the <code>volatile</code>
+ * modifier, false otherwise.
+ *
+ * @param modifiers
+ * the modifiers to test
+ * @return if the modifiers contain the volatile modifier
+ */
+ public static boolean isVolatile(int modifiers) {
+ return ((modifiers & VOLATILE) != 0);
+ }
+
+ /**
+ * Answers a string containing the string representation of all modifiers
+ * present in the specified modifiers.
+ *
+ * Modifiers appear in the order specified by the Java Language
+ * Specification:
+ * <code>public private protected abstract static final transient volatile native synchronized interface strict</code>
+ *
+ * @param modifiers
+ * the modifiers to print
+ * @return a printable representation of the modifiers
+ */
+ public static java.lang.String toString(int modifiers) {
+ StringBuffer buf;
+
+ buf = new StringBuffer();
+
+ if (isPublic(modifiers))
+ buf.append("public ");
+ if (isProtected(modifiers))
+ buf.append("protected ");
+ if (isPrivate(modifiers))
+ buf.append("private ");
+ if (isAbstract(modifiers))
+ buf.append("abstract ");
+ if (isStatic(modifiers))
+ buf.append("static ");
+ if (isFinal(modifiers))
+ buf.append("final ");
+ if (isTransient(modifiers))
+ buf.append("transient ");
+ if (isVolatile(modifiers))
+ buf.append("volatile ");
+ if (isSynchronized(modifiers))
+ buf.append("synchronized ");
+ if (isNative(modifiers))
+ buf.append("native ");
+ if (isStrict(modifiers))
+ buf.append("strictfp ");
+ if (isInterface(modifiers))
+ buf.append("interface ");
+ if (buf.length() == 0)
+ return "";
+ buf.setLength(buf.length() - 1);
+ return buf.toString();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Modifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/ParameterizedType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/ParameterizedType.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/ParameterizedType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/ParameterizedType.java Sun Aug 20 13:54:27 2006
@@ -1,62 +1,62 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package java.lang.reflect;
-
-/**
- * <p>
- * Represents a parameterized type.
- * </p>
- *
- * @since 1.5
- */
-public interface ParameterizedType extends Type {
- /**
- * <p>
- * Gets the type arguments for this type.
- * </p>
- *
- * @return An array of {@link Type}, which may be empty.
- * @throws TypeNotPresentException if one of the type arguments can't be
- * found.
- * @throws MalformedParameterizedTypeException if one of the type arguments
- * can't be instantiated for some reason.
- */
- Type[] getActualTypeArguments();
-
- /**
- * <p>
- * Gets the parent/owner type, if this type is an inner type, otherwise
- * <code>null</code> is returned if this is a top-level type.
- * </p>
- *
- * @return An instance of {@link Type} or <code>null</code>.
- * @throws TypeNotPresentException if one of the type arguments can't be
- * found.
- * @throws MalformedParameterizedTypeException if one of the type arguments
- * can't be instantiated for some reason.
- */
- Type getOwnerType();
-
- /**
- * <p>
- * Gets the raw type of this type.
- * </p>
- *
- * @return An instance of {@link Type}.
- */
- Type getRawType();
-}
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package java.lang.reflect;
+
+/**
+ * <p>
+ * Represents a parameterized type.
+ * </p>
+ *
+ * @since 1.5
+ */
+public interface ParameterizedType extends Type {
+ /**
+ * <p>
+ * Gets the type arguments for this type.
+ * </p>
+ *
+ * @return An array of {@link Type}, which may be empty.
+ * @throws TypeNotPresentException if one of the type arguments can't be
+ * found.
+ * @throws MalformedParameterizedTypeException if one of the type arguments
+ * can't be instantiated for some reason.
+ */
+ Type[] getActualTypeArguments();
+
+ /**
+ * <p>
+ * Gets the parent/owner type, if this type is an inner type, otherwise
+ * <code>null</code> is returned if this is a top-level type.
+ * </p>
+ *
+ * @return An instance of {@link Type} or <code>null</code>.
+ * @throws TypeNotPresentException if one of the type arguments can't be
+ * found.
+ * @throws MalformedParameterizedTypeException if one of the type arguments
+ * can't be instantiated for some reason.
+ */
+ Type getOwnerType();
+
+ /**
+ * <p>
+ * Gets the raw type of this type.
+ * </p>
+ *
+ * @return An instance of {@link Type}.
+ */
+ Type getRawType();
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/ParameterizedType.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java?rev=433041&r1=433040&r2=433041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java Sun Aug 20 13:54:27 2006
@@ -1,246 +1,246 @@
-/* Copyright 2001, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.reflect;
-
-import java.io.Serializable;
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.apache.harmony.luni.internal.reflect.ProxyClassFile;
-
-import org.apache.harmony.luni.util.Msg;
-
-/**
- * This class provides methods to creating dynamic proxy classes and instances.
- *
- * @see java.lang.reflect.InvocationHandler
- * @since 1.3
- */
-public class Proxy implements Serializable {
-
- private static final long serialVersionUID = -2222568056686623797L;
-
- // maps class loaders to created classes by interface names
- private static final Map<ClassLoader, Map<String, WeakReference<Class<?>>>> loaderCache = new WeakHashMap<ClassLoader, Map<String, WeakReference<Class<?>>>>();
-
- // to find previously created types
- private static final Map<Class<?>, String> proxyCache = new WeakHashMap<Class<?>, String>();
-
- private static int NextClassNameIndex = 0;
-
- protected InvocationHandler h;
-
- private Proxy() {
- }
-
- protected Proxy(InvocationHandler h) {
- this.h = h;
- }
-
- /**
- * Return the dynamically build class for the given interfaces, build a new
- * one when necessary. The order of the interfaces is important.
- *
- * The interfaces must be visible from the supplied class loader; no
- * duplicates are permitted. All non-public interfaces must be defined in
- * the same package.
- *
- * @param loader
- * the class loader that will define the proxy class.
- * @param interfaces
- * an array of <code>Class</code> objects, each one identifying
- * an interface that the new proxy must implement
- * @return a proxy class that implements all of the interfaces referred to
- * in the contents of <code>interfaces</code>.
- * @exception IllegalArgumentException
- * @exception NullPointerException
- * if either <code>interfaces</code> or any of its elements
- * are <code>null</code>.
- */
- public static Class<?> getProxyClass(ClassLoader loader, Class<?>[] interfaces)
- throws IllegalArgumentException {
- // check that interfaces are a valid array of visible interfaces
- if (interfaces == null) {
- throw new NullPointerException();
- }
- String commonPackageName = null;
- for (int i = 0, length = interfaces.length; i < length; i++) {
- Class<?> next = interfaces[i];
- if (next == null) {
- throw new NullPointerException();
- }
- String name = next.getName();
- if (!next.isInterface()) {
- throw new IllegalArgumentException(Msg.getString("K00ed", name));
- }
- if (loader != next.getClassLoader()) {
- try {
- if (next != Class.forName(name, false, loader)) {
- throw new IllegalArgumentException(Msg.getString(
- "K00ee", name));
- }
- } catch (ClassNotFoundException ex) {
- throw new IllegalArgumentException(Msg.getString("K00ee",
- name));
- }
- }
- for (int j = i + 1; j < length; j++) {
- if (next == interfaces[j]) {
- throw new IllegalArgumentException(Msg.getString("K00ef",
- name));
- }
- }
- if (!Modifier.isPublic(next.getModifiers())) {
- int last = name.lastIndexOf('.');
- String p = last == -1 ? "" : name.substring(0, last);
- if (commonPackageName == null) {
- commonPackageName = p;
- } else if (!commonPackageName.equals(p)) {
- throw new IllegalArgumentException(Msg.getString("K00f0"));
- }
- }
- }
-
- // search cache for matching proxy class using the class loader
- synchronized (loaderCache) {
- Map<String, WeakReference<Class<?>>> interfaceCache = loaderCache.get(loader);
- if (interfaceCache == null) {
- loaderCache.put(loader, (interfaceCache = new HashMap<String, WeakReference<Class<?>>>()));
- }
-
- String interfaceKey = "";
- if (interfaces.length == 1) {
- interfaceKey = interfaces[0].getName();
- } else {
- StringBuilder names = new StringBuilder();
- for (int i = 0, length = interfaces.length; i < length; i++) {
- names.append(interfaces[i].getName());
- names.append(' ');
- }
- interfaceKey = names.toString();
- }
-
- Class<?> newClass;
- WeakReference<Class<?>> ref = interfaceCache.get(interfaceKey);
- if (ref == null) {
- String nextClassName = "$Proxy" + NextClassNameIndex++;
- if (commonPackageName != null) {
- nextClassName = commonPackageName + "." + nextClassName;
- }
- byte[] classFileBytes = ProxyClassFile.generateBytes(
- nextClassName, interfaces);
- if (loader == null) {
- loader = ClassLoader.getSystemClassLoader();
- }
- newClass = defineClassImpl(loader, nextClassName.replace('.',
- '/'), classFileBytes);
- // Need a weak reference to the class so it can
- // be unloaded if the class loader is discarded
- interfaceCache.put(interfaceKey, new WeakReference<Class<?>>(newClass));
- synchronized (proxyCache) {
- proxyCache.put(newClass, ""); // the value is unused
- }
- } else {
- newClass = ref.get();
- }
- return newClass;
- }
- }
-
- /**
- * Return an instance of the dynamically build class for the given
- * interfaces that forwards methods to the specified invocation handler.
- *
- * The interfaces must be visible from the supplied class loader; no
- * duplicates are permitted. All non-public interfaces must be defined in
- * the same package.
- *
- * @param loader
- * the class loader that will define the proxy class.
- * @param interfaces
- * the list of interfaces to implement.
- * @param h
- * the invocation handler for the forwarded methods.
- * @return a new proxy object that delegates to the handler <code>h</code>
- * @exception IllegalArgumentException
- * @exception NullPointerException
- * if the interfaces or any of its elements are null.
- */
- public static Object newProxyInstance(ClassLoader loader,
- Class<?>[] interfaces, InvocationHandler h)
- throws IllegalArgumentException {
- if (h != null) {
- try {
- return getProxyClass(loader, interfaces).getConstructor(
- new Class<?>[] { InvocationHandler.class }).newInstance(
- new Object[] { h });
- } catch (NoSuchMethodException ex) {
- throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
- } catch (IllegalAccessException ex) {
- throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
- } catch (InstantiationException ex) {
- throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
- } catch (InvocationTargetException ex) {
- Throwable target = ex.getTargetException();
- throw (InternalError)(new InternalError(target.toString()).initCause(target));
- }
- }
- throw new NullPointerException();
- }
-
- /**
- * Return whether the supplied class is a dynamically generated proxy class.
- *
- * @param cl
- * the class.
- * @return true if the class is a proxy class and false otherwise.
- * @exception NullPointerException
- * if the class is null.
- */
- public static boolean isProxyClass(Class<?> cl) {
- if (cl != null) {
- synchronized (proxyCache) {
- return proxyCache.containsKey(cl);
- }
- }
- throw new NullPointerException();
- }
-
- /**
- * Return the proxy instance's invocation handler.
- *
- * @param proxy
- * the proxy instance.
- * @return the proxy's invocation handler object
- * @exception IllegalArgumentException
- * if the supplied <code>proxy</code> is not a proxy
- * object.
- */
- public static InvocationHandler getInvocationHandler(Object proxy)
- throws IllegalArgumentException {
- if (isProxyClass(proxy.getClass())) {
- return ((Proxy) proxy).h;
- }
-
- throw new IllegalArgumentException(Msg.getString("K00f1"));
- }
-
- private static native Class<?> defineClassImpl(ClassLoader classLoader,
- String className, byte[] classFileBytes);
-
-}
+/* Copyright 2001, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+import java.io.Serializable;
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.harmony.luni.internal.reflect.ProxyClassFile;
+
+import org.apache.harmony.luni.util.Msg;
+
+/**
+ * This class provides methods to creating dynamic proxy classes and instances.
+ *
+ * @see java.lang.reflect.InvocationHandler
+ * @since 1.3
+ */
+public class Proxy implements Serializable {
+
+ private static final long serialVersionUID = -2222568056686623797L;
+
+ // maps class loaders to created classes by interface names
+ private static final Map<ClassLoader, Map<String, WeakReference<Class<?>>>> loaderCache = new WeakHashMap<ClassLoader, Map<String, WeakReference<Class<?>>>>();
+
+ // to find previously created types
+ private static final Map<Class<?>, String> proxyCache = new WeakHashMap<Class<?>, String>();
+
+ private static int NextClassNameIndex = 0;
+
+ protected InvocationHandler h;
+
+ private Proxy() {
+ }
+
+ protected Proxy(InvocationHandler h) {
+ this.h = h;
+ }
+
+ /**
+ * Return the dynamically build class for the given interfaces, build a new
+ * one when necessary. The order of the interfaces is important.
+ *
+ * The interfaces must be visible from the supplied class loader; no
+ * duplicates are permitted. All non-public interfaces must be defined in
+ * the same package.
+ *
+ * @param loader
+ * the class loader that will define the proxy class.
+ * @param interfaces
+ * an array of <code>Class</code> objects, each one identifying
+ * an interface that the new proxy must implement
+ * @return a proxy class that implements all of the interfaces referred to
+ * in the contents of <code>interfaces</code>.
+ * @exception IllegalArgumentException
+ * @exception NullPointerException
+ * if either <code>interfaces</code> or any of its elements
+ * are <code>null</code>.
+ */
+ public static Class<?> getProxyClass(ClassLoader loader, Class<?>[] interfaces)
+ throws IllegalArgumentException {
+ // check that interfaces are a valid array of visible interfaces
+ if (interfaces == null) {
+ throw new NullPointerException();
+ }
+ String commonPackageName = null;
+ for (int i = 0, length = interfaces.length; i < length; i++) {
+ Class<?> next = interfaces[i];
+ if (next == null) {
+ throw new NullPointerException();
+ }
+ String name = next.getName();
+ if (!next.isInterface()) {
+ throw new IllegalArgumentException(Msg.getString("K00ed", name));
+ }
+ if (loader != next.getClassLoader()) {
+ try {
+ if (next != Class.forName(name, false, loader)) {
+ throw new IllegalArgumentException(Msg.getString(
+ "K00ee", name));
+ }
+ } catch (ClassNotFoundException ex) {
+ throw new IllegalArgumentException(Msg.getString("K00ee",
+ name));
+ }
+ }
+ for (int j = i + 1; j < length; j++) {
+ if (next == interfaces[j]) {
+ throw new IllegalArgumentException(Msg.getString("K00ef",
+ name));
+ }
+ }
+ if (!Modifier.isPublic(next.getModifiers())) {
+ int last = name.lastIndexOf('.');
+ String p = last == -1 ? "" : name.substring(0, last);
+ if (commonPackageName == null) {
+ commonPackageName = p;
+ } else if (!commonPackageName.equals(p)) {
+ throw new IllegalArgumentException(Msg.getString("K00f0"));
+ }
+ }
+ }
+
+ // search cache for matching proxy class using the class loader
+ synchronized (loaderCache) {
+ Map<String, WeakReference<Class<?>>> interfaceCache = loaderCache.get(loader);
+ if (interfaceCache == null) {
+ loaderCache.put(loader, (interfaceCache = new HashMap<String, WeakReference<Class<?>>>()));
+ }
+
+ String interfaceKey = "";
+ if (interfaces.length == 1) {
+ interfaceKey = interfaces[0].getName();
+ } else {
+ StringBuilder names = new StringBuilder();
+ for (int i = 0, length = interfaces.length; i < length; i++) {
+ names.append(interfaces[i].getName());
+ names.append(' ');
+ }
+ interfaceKey = names.toString();
+ }
+
+ Class<?> newClass;
+ WeakReference<Class<?>> ref = interfaceCache.get(interfaceKey);
+ if (ref == null) {
+ String nextClassName = "$Proxy" + NextClassNameIndex++;
+ if (commonPackageName != null) {
+ nextClassName = commonPackageName + "." + nextClassName;
+ }
+ byte[] classFileBytes = ProxyClassFile.generateBytes(
+ nextClassName, interfaces);
+ if (loader == null) {
+ loader = ClassLoader.getSystemClassLoader();
+ }
+ newClass = defineClassImpl(loader, nextClassName.replace('.',
+ '/'), classFileBytes);
+ // Need a weak reference to the class so it can
+ // be unloaded if the class loader is discarded
+ interfaceCache.put(interfaceKey, new WeakReference<Class<?>>(newClass));
+ synchronized (proxyCache) {
+ proxyCache.put(newClass, ""); // the value is unused
+ }
+ } else {
+ newClass = ref.get();
+ }
+ return newClass;
+ }
+ }
+
+ /**
+ * Return an instance of the dynamically build class for the given
+ * interfaces that forwards methods to the specified invocation handler.
+ *
+ * The interfaces must be visible from the supplied class loader; no
+ * duplicates are permitted. All non-public interfaces must be defined in
+ * the same package.
+ *
+ * @param loader
+ * the class loader that will define the proxy class.
+ * @param interfaces
+ * the list of interfaces to implement.
+ * @param h
+ * the invocation handler for the forwarded methods.
+ * @return a new proxy object that delegates to the handler <code>h</code>
+ * @exception IllegalArgumentException
+ * @exception NullPointerException
+ * if the interfaces or any of its elements are null.
+ */
+ public static Object newProxyInstance(ClassLoader loader,
+ Class<?>[] interfaces, InvocationHandler h)
+ throws IllegalArgumentException {
+ if (h != null) {
+ try {
+ return getProxyClass(loader, interfaces).getConstructor(
+ new Class<?>[] { InvocationHandler.class }).newInstance(
+ new Object[] { h });
+ } catch (NoSuchMethodException ex) {
+ throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
+ } catch (IllegalAccessException ex) {
+ throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
+ } catch (InstantiationException ex) {
+ throw (InternalError)(new InternalError(ex.toString()).initCause(ex));
+ } catch (InvocationTargetException ex) {
+ Throwable target = ex.getTargetException();
+ throw (InternalError)(new InternalError(target.toString()).initCause(target));
+ }
+ }
+ throw new NullPointerException();
+ }
+
+ /**
+ * Return whether the supplied class is a dynamically generated proxy class.
+ *
+ * @param cl
+ * the class.
+ * @return true if the class is a proxy class and false otherwise.
+ * @exception NullPointerException
+ * if the class is null.
+ */
+ public static boolean isProxyClass(Class<?> cl) {
+ if (cl != null) {
+ synchronized (proxyCache) {
+ return proxyCache.containsKey(cl);
+ }
+ }
+ throw new NullPointerException();
+ }
+
+ /**
+ * Return the proxy instance's invocation handler.
+ *
+ * @param proxy
+ * the proxy instance.
+ * @return the proxy's invocation handler object
+ * @exception IllegalArgumentException
+ * if the supplied <code>proxy</code> is not a proxy
+ * object.
+ */
+ public static InvocationHandler getInvocationHandler(Object proxy)
+ throws IllegalArgumentException {
+ if (isProxyClass(proxy.getClass())) {
+ return ((Proxy) proxy).h;
+ }
+
+ throw new IllegalArgumentException(Msg.getString("K00f1"));
+ }
+
+ private static native Class<?> defineClassImpl(ClassLoader classLoader,
+ String className, byte[] classFileBytes);
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/reflect/Proxy.java
------------------------------------------------------------------------------
svn:eol-style = native