aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/sun
diff options
context:
space:
mode:
authorTom Tromey <tromey@gcc.gnu.org>2007-01-09 19:58:05 +0000
committerTom Tromey <tromey@gcc.gnu.org>2007-01-09 19:58:05 +0000
commit97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch)
tree996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/sun
parentc648dedbde727ca3f883bb5fd773aa4af70d3369 (diff)
downloadgcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.zip
gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.gz
gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.bz2
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
Diffstat (limited to 'libjava/classpath/sun')
-rw-r--r--libjava/classpath/sun/misc/Service.java66
-rw-r--r--libjava/classpath/sun/misc/ServiceConfigurationError.java64
-rw-r--r--libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java56
-rw-r--r--libjava/classpath/sun/reflect/annotation/AnnotationParser.java57
-rw-r--r--libjava/classpath/sun/reflect/annotation/AnnotationType.java52
-rw-r--r--libjava/classpath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java52
-rw-r--r--libjava/classpath/sun/reflect/annotation/ExceptionProxy.java46
7 files changed, 393 insertions, 0 deletions
diff --git a/libjava/classpath/sun/misc/Service.java b/libjava/classpath/sun/misc/Service.java
new file mode 100644
index 0000000..bdcbbfe
--- /dev/null
+++ b/libjava/classpath/sun/misc/Service.java
@@ -0,0 +1,66 @@
+/* Service.java -- A wrapper around GNU service provision.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package sun.misc;
+
+import gnu.classpath.ServiceFactory;
+
+import java.util.Iterator;
+
+public class Service
+{
+
+ /**
+ * Returns an {@link Iterator} over the service providers which
+ * provide a service of the given class, and are available from
+ * the specified classloader.
+ *
+ * @param c the service provider interface which must be
+ * implemented by any loaded service providers.
+ * @param cl the class loader that will be used to load the
+ * service providers, or <code>null</code> for the system class
+ * loader.
+ * @return an iterator over the service providers.
+ */
+ public static <P> Iterator<P> providers(Class<P> c, ClassLoader cl)
+ {
+ return (Iterator<P>) ServiceFactory.lookupProviders(c, cl);
+ }
+
+}
+
diff --git a/libjava/classpath/sun/misc/ServiceConfigurationError.java b/libjava/classpath/sun/misc/ServiceConfigurationError.java
new file mode 100644
index 0000000..9c29d6e
--- /dev/null
+++ b/libjava/classpath/sun/misc/ServiceConfigurationError.java
@@ -0,0 +1,64 @@
+/* ServiceConfigurationError.java -- An error from service configuration.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package sun.misc;
+
+public class ServiceConfigurationError
+ extends Error
+{
+
+ /**
+ * Constructs a new {@link ServiceConfigurationError}
+ */
+ public ServiceConfigurationError()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new {@link ServiceConfigurationError}
+ * with the specified message.
+ */
+ public ServiceConfigurationError(String message)
+ {
+ super(message);
+ }
+
+
+}
+
diff --git a/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java b/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java
index ab9ad13..f132d81 100644
--- a/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java
+++ b/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java
@@ -39,11 +39,13 @@ exception statement from your version. */
package sun.reflect.annotation;
import java.io.Serializable;
+import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
@@ -74,6 +76,24 @@ public final class AnnotationInvocationHandler
this.memberValues = memberValues;
}
+ public static Annotation create(Class type, Map memberValues)
+ {
+ for (Method m : type.getDeclaredMethods())
+ {
+ String name = m.getName();
+ if (! memberValues.containsKey(name))
+ {
+ // FIXME: what to do about exceptions here?
+ memberValues.put(name, m.getDefaultValue());
+ }
+ }
+ AnnotationInvocationHandler handler
+ = new AnnotationInvocationHandler(type, memberValues);
+ return (Annotation) Proxy.newProxyInstance(type.getClassLoader(),
+ new Class[] { type },
+ handler);
+ }
+
/**
* Compare an instance of AnnotationInvocationHandler with another object.
* Note that the other object does not have to be an
@@ -295,6 +315,38 @@ public final class AnnotationInvocationHandler
return returnType;
}
+ private Object arrayClone(Object obj)
+ {
+ if (obj instanceof boolean[])
+ return ((boolean[]) obj).clone();
+
+ if (obj instanceof byte[])
+ return ((byte[]) obj).clone();
+
+ if (obj instanceof char[])
+ return ((char[]) obj).clone();
+
+ if (obj instanceof short[])
+ return ((short[]) obj).clone();
+
+ if (obj instanceof int[])
+ return ((int[]) obj).clone();
+
+ if (obj instanceof float[])
+ return ((float[]) obj).clone();
+
+ if (obj instanceof long[])
+ return ((long[]) obj).clone();
+
+ if (obj instanceof double[])
+ return ((double[]) obj).clone();
+
+ if (obj instanceof Object[])
+ return ((Object[]) obj).clone();
+
+ return obj;
+ }
+
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
@@ -325,6 +377,10 @@ public final class AnnotationInvocationHandler
throw new AnnotationTypeMismatchException(method,
val.getClass().getName());
}
+ if (val.getClass().isArray())
+ {
+ val = arrayClone(val);
+ }
return val;
}
}
diff --git a/libjava/classpath/sun/reflect/annotation/AnnotationParser.java b/libjava/classpath/sun/reflect/annotation/AnnotationParser.java
new file mode 100644
index 0000000..a5452d0
--- /dev/null
+++ b/libjava/classpath/sun/reflect/annotation/AnnotationParser.java
@@ -0,0 +1,57 @@
+/* sun.reflect.annotation.AnnotationParser
+ Copyright (C) 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package sun.reflect.annotation;
+
+import gnu.classpath.NotImplementedException;
+
+import java.lang.annotation.Annotation;
+
+import java.util.Map;
+
+public class AnnotationParser
+{
+
+ public static Annotation annotationForMap(Class<? extends Annotation> annoType,
+ Map<String, Object> map)
+ throws NotImplementedException
+ {
+ return null;
+ }
+
+}
diff --git a/libjava/classpath/sun/reflect/annotation/AnnotationType.java b/libjava/classpath/sun/reflect/annotation/AnnotationType.java
new file mode 100644
index 0000000..38d8aa8
--- /dev/null
+++ b/libjava/classpath/sun/reflect/annotation/AnnotationType.java
@@ -0,0 +1,52 @@
+/* sun.reflect.annotation.AnnotationType
+ Copyright (C) 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package sun.reflect.annotation;
+
+import gnu.classpath.NotImplementedException;
+
+public class AnnotationType
+{
+
+ public static Class<?> invocationHandlerReturnType(Class<?> returnClass)
+ throws NotImplementedException
+ {
+ return null;
+ }
+
+}
diff --git a/libjava/classpath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java b/libjava/classpath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
new file mode 100644
index 0000000..33b0dae
--- /dev/null
+++ b/libjava/classpath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
@@ -0,0 +1,52 @@
+/* sun.reflect.annotation.EnumConstantNotPresentExceptionProxy
+ Copyright (C) 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package sun.reflect.annotation;
+
+import gnu.classpath.NotImplementedException;
+
+public class EnumConstantNotPresentExceptionProxy
+ extends ExceptionProxy
+{
+
+ public EnumConstantNotPresentExceptionProxy(Class c, String s)
+ throws NotImplementedException
+ {
+ }
+
+}
diff --git a/libjava/classpath/sun/reflect/annotation/ExceptionProxy.java b/libjava/classpath/sun/reflect/annotation/ExceptionProxy.java
new file mode 100644
index 0000000..8edb361
--- /dev/null
+++ b/libjava/classpath/sun/reflect/annotation/ExceptionProxy.java
@@ -0,0 +1,46 @@
+/* sun.reflect.annotation.ExceptionProxy
+ Copyright (C) 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package sun.reflect.annotation;
+
+import gnu.classpath.NotImplementedException;
+
+public class ExceptionProxy
+{
+
+}