From 2bc043354c4edb1f5aad751285060fb722a63ea1 Mon Sep 17 00:00:00 2001 From: doko Date: Tue, 21 Oct 2008 17:55:01 +0000 Subject: libjava/ChangeLog: 2008-10-21 Andrew John Hughes * sources.am, Makfile.in: Regenerate. 2008-10-17 Matthias Klose * configure.ac: Fix bashisms. * configure: Regenerate. 2008-10-15 Matthias Klose * configure.ac: Disable build of gjdoc, if configured without --with-antlr-jar or if no antlr.jar found. * configure: Regenerate. 2008-10-09 Andrew John Hughes * classpath/configure.ac, * classpath/m4/ac_prog_antlr.m4, * classpath/m4/ac_prog_java.m4, * classpath/tools/Makefile.am: Ported --regen-gjdoc-parser patch and cantlr support from GNU Classpath. 2008-10-06 Andrew Haley * java/lang/Thread.java (Thread): Always create the ThreadLocalMap when creating a thread. (getThreadLocals) Don't lazily create the ThreadLocalMap. 2008-09-28 Andrew John Hughes * classpath/java/lang/ThreadLocalMap.java, * java/lang/ThreadLocalMap$Entry.h, * java/lang/ThreadLocalMap.h, * lib/java/lang/ThreadLocalMap.class, * lib/java/lang/ThreadLocalMap$Entry.class: Add the new files for the ThreadLocal patch. 2008-09-28 Andrew John Hughes * classpath/ChangeLog, * classpath/java/lang/InheritableThreadLocal.java, * classpath/java/lang/Thread.java, * classpath/java/lang/ThreadLocal.java: Merge Daniel Frampton's ThreadLocal patch. * gcj/javaprims.h: Updated. * java/lang/Thread.h: Regenerated. * java/lang/Thread.java: Replace WeakIdentityHashMap with ThreadLocalMap. (getThreadLocals()): Likewise. * java/lang/ThreadLocal.h: Regenerated. * java/lang/ThreadLocal.java: (computeNextHash()): New method. (ThreadLocal()): Initialise fastHash. (internalGet()): Updated to match Classpath's get(). (internalSet(Object)): Likewise for set(Object). (internalRemove()): Likewise for remove(). 2008-09-25 Andrew John Hughes * classpath/configure, * classpath/configure.ac: Resynchronise with Classpath's configure. * classpath/examples/Makefile.in: Add equivalent support for building as in tools/Makefile.in. * classpath/java/nio/Buffer.java, * classpath/java/nio/ByteBuffer.java, * classpath/java/nio/ByteBufferImpl.java, * classpath/java/nio/CharBuffer.java, * classpath/java/nio/CharBufferImpl.java, * classpath/java/nio/CharSequenceBuffer.java, * classpath/java/nio/CharViewBufferImpl.java, * classpath/java/nio/DirectByteBufferImpl.java, * classpath/java/nio/DoubleBuffer.java, * classpath/java/nio/DoubleBufferImpl.java, * classpath/java/nio/DoubleViewBufferImpl.java, * classpath/java/nio/FloatBuffer.java, * classpath/java/nio/FloatBufferImpl.java, * classpath/java/nio/FloatViewBufferImpl.java, * classpath/java/nio/IntBuffer.java, * classpath/java/nio/IntBufferImpl.java, * classpath/java/nio/IntViewBufferImpl.java, * classpath/java/nio/LongBuffer.java, * classpath/java/nio/LongBufferImpl.java, * classpath/java/nio/LongViewBufferImpl.java, * classpath/java/nio/MappedByteBuffer.java, * classpath/java/nio/MappedByteBufferImpl.java, * classpath/java/nio/ShortBuffer.java, * classpath/java/nio/ShortBufferImpl.java, * classpath/java/nio/ShortViewBufferImpl.java: Replace use of gnu.classpath.Pointer with gnu.gcj.RawData, and fix some formatting issues. * classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaLexer.java, * classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap, * classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java, * classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap, * classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java, * classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt: Regenerated (later version of antlr). * java/nio/Buffer.h: Regenerated. * java/nio/Buffer.java: Ported changes from Classpath. * java/nio/ByteBuffer.h, * java/nio/CharBuffer.h: Regenerated. * java/nio/DirectByteBufferImpl.java: Ported changes from Classpath. * java/nio/DoubleBuffer.h, * java/nio/FloatBuffer.h, * java/nio/IntBuffer.h, * java/nio/LongBuffer.h, * java/nio/MappedByteBuffer.h, * java/nio/MappedByteBufferImpl.h: Regenerated. * java/nio/MappedByteBufferImpl.java: Ported changes from Classpath. * java/nio/ShortBuffer.h: Regenerated. 2008-09-24 Matthias Klose * configure.ac: Search for antlr.jar, if not configured. * configure: Regenerate. 2008-09-24 Matthias Klose * Makefile.am: Build a gjdoc binary, if enabled. * configure.ac: Add options --disable-gjdoc, --with-antlr-jar=file. * Makefile.in, */Makefile.in, configure: Regenerate. 2008-09-22 Andrew Haley * java/lang/String.java (toString(char[], int, int)): New method. 2008-09-14 Matthias Klose Import GNU Classpath (libgcj-import-20080914). * Regenerate class and header files. * Regenerate auto* files. * configure.ac: Don't pass --disable-gjdoc to classpath. * sources.am: Regenerated. * HACKING: Mention to build gjdoc in maintainer builds. * gnu/classpath/Configuration.java: Update classpath version. * gcj/javaprims.h: Update. 2008-09-08 Andrew John Hughes * Makefile.am: Replace natStringBuffer.cc and natStringBuilder.cc with natAbstractStringBuffer.cc. * Makefile.in: Regenerated. * java/lang/AbstractStringBuffer.java: (append(int)): Made native. (regionMatches(int,String)): Likewise. * java/lang/StringBuffer.h: Regenerated. * java/lang/StringBuffer.java: Remerged with GNU Classpath. * java/lang/StringBuilder.h: Regenerated. * java/lang/StringBuilder.java: Remerged with GNU Classpath. * java/lang/natAbstractStringBuffer.cc: Provide common native methods for StringBuffer and StringBuilder. * java/lang/natStringBuffer.cc, * java/lang/natStringBuilder.cc: Removed. 2008-09-04 Andrew John Hughes * Makefile.in, * classpath/configure: Regenerated. * gnu/gcj/util/natDebug.cc, * gnu/gcj/xlib/natColormap.cc, * gnu/gcj/xlib/natDisplay.cc, * gnu/gcj/xlib/natDrawable.cc, * gnu/gcj/xlib/natFont.cc, * gnu/gcj/xlib/natWMSizeHints.cc, * gnu/gcj/xlib/natWindow.cc, * gnu/gcj/xlib/natXImage.cc: Add :: prefix to namespaces. * java/io/CharArrayWriter.h, * java/lang/StringBuffer.h: Regenerated using patched gjavah. * java/lang/natStringBuffer.cc: Fix naming of append(jint). * java/sql/Timestamp.h: Regenerated using patched gjavah. * jni.cc: Rename p to functions to match change in GNU Classpath. * scripts/makemake.tcl: Switch gnu.java.math to BC compilation. * sources.am: Regenerated. 2008-08-21 Andrew John Hughes * Makefile.in: Updated location of Configuration.java. * classpath/lib/gnu/java/locale/LocaleData.class: Regenerated. 2008-08-18 Andrew John Hughes * Makefile.in: Updated with new Java files. * classpath/configure: Regenerated. * classpath/tools/Makefile.am: Add missing use of GJDOC_EX so --disable-gjdoc works. * classpath/tools/Makefile.in: Regenerated. 2008-08-15 Matthias Klose Import GNU Classpath (libgcj-import-20080811). * Regenerate class and header files. * Regenerate auto* files. * configure.ac: Don't pass --with-fastjar to classpath, substitute new dummy value in classpath/gnu/classpath/Configuration.java.in, pass --disable-gjdoc to classpath. * scripts/makemake.tcl: * sources.am: Regenerated. * java/lang/AbstractStringBuffer.java, gnu/java/lang/VMCPStringBuilder.java: New, copied from classpath, use System instead of VMSystem. * java/lang/StringBuffer.java: Merge from classpath. * java/lang/ClassLoader.java: Merge from classpath. * gcj/javaprims.h: Update class definitions, remove _Jv_jobjectRefType, jobjectRefType definitions. libjava/classpath/ChangeLog.gcj: 2008-10-21 Matthias Klose * classpath/tools/gnu/classpath/tools/gjdoc/expr/Java*: Move from ... * classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/ ... here. * Update .class files. 2008-10-21 Andrew John Hughes * tools/Makefile.am: Always generate parser in the srcdir. 2008-10-21 Matthias Klose * doc/Makefile.am (MAINTAINERCLEANFILES): Add gjdoc.1. * doc/Makefile.in: Regenerate. 2008-10-20 Matthias Klose * configure.ac: Don't check for working java, if not configured with --enable-java-maintainer-mode. * configure: Regenerate. 2008-10-19 Matthias Klose * m4/ac_prog_java.m4: Revert previous change. * m4/ac_prog_javac.m4: Apply it here. * configure: Regenerate. 2008-10-19 Matthias Klose * m4/ac_prog_javac.m4: Don't check for working javac, if not configured with --enable-java-maintainer-mode. * configure: Regenerate. * Makefile.in, */Makefile.in: Regenerate. 2008-09-30 Matthias Klose * m4/ac_prog_antlr.m4: Check for cantlr binary as well. 2008-09-29 Matthias Klose * m4/ac_prog_antlr.m4: Check for antlr binary as well. 2008-09-28 Matthias Klose * PR libgcj/37636. Revert: 2008-02-20 Matthias Klose * tools/Makefile.am ($(TOOLS_ZIP)): Revert part of previous change, Do copy resource files in JAVA_MAINTAINER_MODE only. * tools/Makefile.in: Regenerate. 2008-09-14 Matthias Klose * m4/ac_prog_javac_works.m4, m4/ac_prog_javac.m4, m4/acinclude.m4: Revert local changes. * m4/ac_prog_antlr.m4: Check for an runantlr binary. * tools/Makefile.am, lib/Makefile.am: Revert local changes (JCOMPILER). * tools/Makefile.am: Remove USE_JAVAC_FLAGS, pass ANTLR_JAR in GLIBJ_CLASSPATH. 2008-09-14 Matthias Klose Revert: Daniel Frampton * AUTHORS: Added. * java/lang/InheritableThreadLocal.java, * java/lang/Thread.java, * java/lang/ThreadLocal.java: Modified to use java.lang.ThreadLocalMap. * java/lang/ThreadLocalMap.java: New cheaper ThreadLocal-specific WeakHashMap. 2008-08-15 Matthias Klose * m4/acinclude.m4 (CLASSPATH_JAVAC_MEM_CHECK): Remove unknown args for javac. libjava/classpath/ChangeLog: 2008-10-20 Andrew John Hughes * m4/ac_prog_antlr.m4: Remove redundant checks. * tools/Makefile.am: Use gjdoc_gendir when calling antlr. 2008-10-15 Andrew John Hughes * configure.ac: Remove superfluous AC_PROG_JAVA call. 2008-10-06 Andrew John Hughes * m4/ac_prog_antlr: Check for cantlr as well. * tools/Makefile.am: Only build GJDoc parser when both CREATE_GJDOC and CREATE_GJDOC_PARSER are on. 2008-10-02 Andrew John Hughes * configure.ac: Add regen-gjdoc-parser option, and separate antlr tests. * m4/ac_prog_antlr.m4: Turn single test into AC_LIB_ANTLR and AC_PROG_ANTLR. * m4/ac_prog_java.m4: Quote tests. * tools/Makefile.am: Support CREATE_GJDOC_PARSER option. 2008-09-14 Andrew John Hughes * examples/Makefile.am: Check lib directly as well as glibj.zip for boot classes. * m4/acinclude.m4: Only require the class files to be built to allow the tools and examples to be built, not the installation of glibj.zip. * tools/Makefile.am: Check lib directly as well as glibj.zip for boot classes. 2008-09-13 Andrew John Hughes * examples/Makefile.am, * lib/Makefile.am: Add GCJ rules. * m4/ac_prog_javac.m4: Check whether JAVAC is gcj. * m4/ac_prog_javac_works.m4: Add GCJ rules. * m4/acinclude.m4: Don't bother checking for -J if using GCJ. * tools/Makefile.am: Add GCJ rules. 2007-08-23 Daniel Frampton * AUTHORS: Added. * java/lang/InheritableThreadLocal.java, * java/lang/Thread.java, * java/lang/ThreadLocal.java: Modified to use java.lang.ThreadLocalMap. * java/lang/ThreadLocalMap.java: New cheaper ThreadLocal-specific WeakHashMap. 2008-02-07 Ian Rogers * java/util/zip/ZipEntry.java: Use byte fields instead of integer fields, store the time as well as the DOS time and don't retain a global Calendar instance. (setDOSTime(int)): Set KNOWN_DOSTIME instead of KNOWN_TIME, and unset KNOWN_TIME. (getDOSTime()): Compute DOS time from UNIX time only when needed. (clone()): Provide cloning via the ZipEntry constructor where possible. (setTime(long)): Don't compute DOS time at this point. (getCalendar()): Removed. 2008-09-09 Andrew John Hughes * tools/gnu/classpath/tools/getopt/Parser.java: (setHeader(String)): Make synchronized. (setFooter(String)): Likewise. * tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java, (reset()): Make synchronized. (name(Class)): Likewise. 2008-09-04 Robert Schuster * gnu/java/nio/charset/ByteDecodeLoopHelper: (arrayDecodeLoop): Added new break label, escape to that label. * gnu/java/nio/charset/ByteEncodeLoopHelper: (arrayDecodeLoop): Added new break label, escape to that label. 2008-09-04 Robert Schuster * java/text/DecimalFormat.java: (scanFix): Use 'i + 1' when looking at following character. (scanNegativePattern): Dito. 2008-09-02 Andrew John Hughes * tools/gnu/classpath/tools/javah/ClassWrapper.java: (makeVtable()): Populate methodNameMap. (printMethods(CniPrintStream)): Always use pre-populated methodNameMap for bridge targets. 2008-09-01 Mario Torre * gnu/java/awt/peer/x/XImage.java (XImageProducer): remove @Override annotation to allow compilation on javac < 1.6 and ecj < 3.4. 2008-09-01 Mario Torre * gnu/java/awt/peer/x/XGraphicsDevice.java (getDisplay): fix to support new Escher API. * gnu/java/awt/peer/x/XImage.java (getSource): method implemented. * gnu/java/awt/peer/x/XImage.java (XImageProducer): implement ImageProducer for getSource. 2008-09-01 Andrew John Hughes * gnu/java/util/regex/BacktrackStack.java, * gnu/java/util/regex/CharIndexed.java, * gnu/java/util/regex/CharIndexedCharArray.java, * gnu/java/util/regex/CharIndexedCharSequence.java, * gnu/java/util/regex/CharIndexedInputStream.java, * gnu/java/util/regex/CharIndexedString.java, * gnu/java/util/regex/CharIndexedStringBuffer.java, * gnu/java/util/regex/RE.java, * gnu/java/util/regex/REException.java, * gnu/java/util/regex/REFilterInputStream.java, * gnu/java/util/regex/REMatch.java, * gnu/java/util/regex/REMatchEnumeration.java, * gnu/java/util/regex/RESyntax.java, * gnu/java/util/regex/REToken.java, * gnu/java/util/regex/RETokenAny.java, * gnu/java/util/regex/RETokenBackRef.java, * gnu/java/util/regex/RETokenChar.java, * gnu/java/util/regex/RETokenEnd.java, * gnu/java/util/regex/RETokenEndOfPreviousMatch.java, * gnu/java/util/regex/RETokenEndSub.java, * gnu/java/util/regex/RETokenIndependent.java, * gnu/java/util/regex/RETokenLookAhead.java, * gnu/java/util/regex/RETokenLookBehind.java, * gnu/java/util/regex/RETokenNamedProperty.java, * gnu/java/util/regex/RETokenOneOf.java, * gnu/java/util/regex/RETokenPOSIX.java, * gnu/java/util/regex/RETokenRange.java, * gnu/java/util/regex/RETokenRepeated.java, * gnu/java/util/regex/RETokenStart.java, * gnu/java/util/regex/RETokenWordBoundary.java, * gnu/java/util/regex/UncheckedRE.java: Fix indentation. 2008-09-01 Andrew John Hughes * gnu/java/util/regex/RETokenStart.java: (getMaximumLength()): Add Override annotation. (matchThis(CharIndexed, REMatch)): Likewise. (returnsFixedLengthMatches()): Renamed from returnsFixedLengthmatches and added Override annotation. (findFixedLengthMatches(CharIndexed,REMatch,int)): Add Override annotation. (dump(CPStringBuilder)): Likewise. * gnu/javax/print/ipp/IppRequest.java: (RequestWriter.writeOperationAttributes(AttributeSet)): Throw exception, don't just create and drop it. * javax/management/MBeanServerPermission.java: (MBeanServerPermissionCollection.add(Permission)): Compare against individual Strings not the entire array, and store the result of replace. * javax/swing/text/html/StyleSheet.java: (setBaseFontSize(size)): Store result of trim(). 2008-09-01 Andrew John Hughes * javax/tools/FileObject.java: (openReader(boolean)): Document new parameter. 2008-03-27 Michael Franz PR classpath/35690: * javax/tools/FileObject.java: (toUri()): Fix case from toURI. (openReader(boolean)): Add missing boolean argument. 2008-08-26 Andrew John Hughes PR classpath/35487: * gnu/javax/management/Server.java: (beans): Change to ConcurrentHashMap. (defaultDomain): Make final. (outer): Likewise. (LazyListenersHolder): Added to wrap listeners, also now a ConcurrentHashMap, providing lazy initialisation safely. (sequenceNumber): Documented. (getBean(ObjectName)): Remove redundant cast. (addNotificationListener(ObjectName,NotificationListener, NotificationFilter,Object)): Remove map initialisation and use holder. (getObjectInstance(ObjectName)): Remove redundant cast. (registerMBean(Object,ObjectName)): Add bean atomically. (removeNotificationListener(ObjectName,NotificationListener)): Simplified. (removeNotificationListener(ObjectName,NotificationListener, NotificationFilter,Object)): Likewise. (notify(ObjectName,String)): Documented. 2008-08-26 Andrew John Hughes * gnu/javax/management/Server.java: Genericised. 2008-08-26 Andrew John Hughes * gnu/javax/management/Translator.java: Genericised. 2008-08-26 Andrew John Hughes * javax/management/DefaultLoaderRepository.java, * javax/management/JMX.java, * javax/management/MBeanAttributeInfo.java, * javax/management/MBeanConstructorInfo.java, * javax/management/MBeanOperationInfo.java, * javax/management/MBeanServerDelegate.java: Fix warnings due to generics. 2008-08-25 Andrew John Hughes * javax/management/MBeanPermission.java, * javax/management/MBeanServerDelegate.java, * javax/management/MBeanServerFactory.java, * javax/management/MBeanServerInvocationHandler.java, * javax/management/MBeanServerPermission.java: Fix warnings due to use of non-generic collections. 2008-08-25 Mario Torre * gnu/javax/rmi/CORBA/RmiUtilities.java (readValue): check if sender is null to avoid NPE. 2008-08-22 Mario Torre * gnu/CORBA/OrbFunctional.java (set_parameters): Fix NullPointerException checking when param is null. 2008-08-23 Andrew John Hughes * java/util/regex/Matcher.java: (reset()): Reset append position so we don't try and append to the end of the old input. 2008-08-22 Andrew John Hughes PR classpath/32028: * m4/acinclude.m4: Also allow versions of GJDoc from 0.8* on, as CVS is 0.8.0-pre. 2008-08-21 Andrew John Hughes PR classpath/32028: * m4/acinclude.m4: (CLASSPATH_WITH_GJDOC): Ensure version 0.7.9 is being used. 2008-08-20 Andrew John Hughes * tools/Makefile.am: Add taglets subdirectory to list of excluded paths when GJDoc is not compiled. 2008-08-19 David P Grove * scripts/check_jni_methods.sh.in: Fix build issue on AIX by splitting generation of method list. 2008-08-18 Andrew John Hughes * native/jni/gstreamer-peer/gst_native_pipeline.c: (get_free_space(int)): Use #else not #elif when there is no condition. 2008-08-17 Andrew John Hughes PR classpath/31895: * java/text/DecimalFormat.java: (setCurrency(Currency)): Update prefixes and suffixes when currency changes. * java/text/DecimalFormatSymbols.java: (DecimalFormatSymbols(Locale)): Set locale earlier so it can be used by setCurrency(Currency). (setCurrency(Currency)): Set the symbol correctly using the locale of the instance. * java/util/Currency.java: Throw error instead of just printing a message. 2008-08-17 Andrew John Hughes * javax/activation/ActivationDataFlavor.java: Suppress warnings from public API. (mimeType): Made final. (representationClass): Added generic type and made final. (normalizeMimeTypeParameter(String,String)): Use CPStringBuilder. * javax/activation/CommandInfo.java: (verb): Made final. (className): Made final. * javax/activation/DataHandler.java: (dataSource): Made final. * javax/activation/FileDataSource.java: (file): Made final. * javax/activation/MailcapCommandMap.java: Use generics on collections and CPStringBuilder instead of StringBuffer. * javax/activation/MimeType.java: (toString()): Use CPStringBuilder. (getBaseType()): Likewise. * javax/activation/MimeTypeParameterList.java: Use generics on collections and CPStringBuilder instead of StringBuffer. * javax/activation/MimeTypeParseException.java: (MimeTypeParseException(String,String)): Use CPStringBuilder. * javax/activation/MimetypesFileTypeMap.java: Use generics on collections and CPStringBuilder instead of StringBuffer. * javax/activation/URLDataSource.java: (url): Made final. 2008-08-17 Andrew John Hughes * gnu/javax/activation/viewers/ImageViewer.java, * gnu/javax/activation/viewers/TextEditor.java, * gnu/javax/activation/viewers/TextViewer.java, * javax/activation/ActivationDataFlavor.java, * javax/activation/CommandInfo.java, * javax/activation/CommandMap.java, * javax/activation/CommandObject.java, * javax/activation/DataContentHandler.java, * javax/activation/DataContentHandlerFactory.java, * javax/activation/DataHandler.java, * javax/activation/DataHandlerDataSource.java, * javax/activation/DataSource.java, * javax/activation/DataSourceDataContentHandler.java, * javax/activation/FileDataSource.java, * javax/activation/FileTypeMap.java, * javax/activation/MailcapCommandMap.java, * javax/activation/MimeType.java, * javax/activation/MimeTypeParameterList.java, * javax/activation/MimeTypeParseException.java, * javax/activation/MimetypesFileTypeMap.java, * javax/activation/ObjectDataContentHandler.java, * javax/activation/URLDataSource.java, * javax/activation/UnsupportedDataTypeException.java, * javax/activation/package.html, * resource/META-INF/mailcap.default, * resource/META-INF/mimetypes.default: Import GNU JAF CVS as of 17/08/2008. 2006-04-25 Archit Shah * javax/activation/MimeTypeParameterList.java: Insert ';' separator before parameter list. 2005-06-29 Xavier Poinsard * javax/activation/ObjectDataContentHandler.java: Fixed typo. 2005-05-28 Chris Burdess * javax/activation/CommandMap.java, * javax/activation/MailcapCommandMap.java: Updated to JAF 1.1. 2004-06-09 Chris Burdess * javax/activation/MailcapCommandMap.java: Fixed bug whereby x-java prefix was not attempted. 2008-08-17 Andrew John Hughes * AUTHORS: Added Laszlo. 2008-04-20 Andrew John Hughes PR classpath/30436: * java/util/Scanner.java: Fix package to be java.util and correct indentation. 2007-07-25 Laszlo Andras Hernadi PR classpath/30436: * java/util/Scanner.java: Initial implementation. 2008-08-17 Andrew John Hughes * java/util/regex/Matcher.java: (toMatchResult()): Implemented. 2008-08-13 Joshua Sumali * doc/Makefile.am (gjdoc.pod): Generate gjdoc pod from cp-tools.texinfo instead of invoke.texi. Remove invoke.texi from EXTRA_DIST. * doc/invoke.texi: Removed and merged into ... * doc/cp-tools.texinfo: Here 2008-08-12 Robert Schuster * native/jni/java-net/local.c (local_bind): Removed fprintf call, fixed access outside of array bounds. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141271 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/vm/reference/java/io/VMFile.java | 26 +- .../reference/java/lang/reflect/Constructor.java | 420 ------------- .../vm/reference/java/lang/reflect/Field.java | 661 --------------------- .../vm/reference/java/lang/reflect/Method.java | 489 --------------- .../reference/java/lang/reflect/VMConstructor.java | 169 ++++++ .../vm/reference/java/lang/reflect/VMField.java | 549 +++++++++++++++++ .../vm/reference/java/lang/reflect/VMMethod.java | 209 +++++++ .../vm/reference/java/net/VMNetworkInterface.java | 17 +- 8 files changed, 951 insertions(+), 1589 deletions(-) delete mode 100644 libjava/classpath/vm/reference/java/lang/reflect/Constructor.java delete mode 100644 libjava/classpath/vm/reference/java/lang/reflect/Field.java delete mode 100644 libjava/classpath/vm/reference/java/lang/reflect/Method.java create mode 100644 libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java create mode 100644 libjava/classpath/vm/reference/java/lang/reflect/VMField.java create mode 100644 libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java (limited to 'libjava/classpath/vm/reference/java') diff --git a/libjava/classpath/vm/reference/java/io/VMFile.java b/libjava/classpath/vm/reference/java/io/VMFile.java index 2a2751765ec..9f584af239e 100644 --- a/libjava/classpath/vm/reference/java/io/VMFile.java +++ b/libjava/classpath/vm/reference/java/io/VMFile.java @@ -58,10 +58,10 @@ final class VMFile { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javaio"); + System.loadLibrary("javaio"); } } - + /* * This native method does the actual work of getting the last file * modification time. It also does the existence check to avoid the @@ -167,19 +167,7 @@ final class VMFile /** * This methods checks if a directory can be written to. */ - static boolean canWriteDirectory(File dir) - { - try - { - String filename = IS_DOS_8_3 ? "tst" : "test-dir-write"; - File test = File.createTempFile(filename, null, dir); - return (test != null && test.delete()); - } - catch (IOException ioe) - { - return false; - } - } + static native boolean canWriteDirectory(String path); /** * This native method checks file permissions for reading @@ -198,6 +186,14 @@ final class VMFile */ static native boolean isDirectory(String dirpath); + /** + * This methods checks if a directory can be written to. + */ + static boolean canWriteDirectory(File path) + { + return canWriteDirectory(path.getAbsolutePath()); + } + /** * This method returns an array of filesystem roots. Some operating systems * have volume oriented filesystem. This method provides a mechanism for diff --git a/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java b/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java deleted file mode 100644 index 8c604ccc9a6..00000000000 --- a/libjava/classpath/vm/reference/java/lang/reflect/Constructor.java +++ /dev/null @@ -1,420 +0,0 @@ -/* java.lang.reflect.Constructor - reflection of Java constructors - Copyright (C) 1998, 2001, 2004, 2005 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 java.lang.reflect; - -import gnu.java.lang.ClassHelper; - -import gnu.java.lang.reflect.MethodSignatureParser; - -import java.lang.annotation.Annotation; -import java.util.Arrays; - -/** - * The Constructor class represents a constructor of a class. It also allows - * dynamic creation of an object, via reflection. Invocation on Constructor - * objects knows how to do widening conversions, but throws - * {@link IllegalArgumentException} if a narrowing conversion would be - * necessary. You can query for information on this Constructor regardless - * of location, but construction access may be limited by Java language - * access controls. If you can't do it in the compiler, you can't normally - * do it here either.

- * - * Note: This class returns and accepts types as Classes, even - * primitive types; there are Class types defined that represent each - * different primitive type. They are java.lang.Boolean.TYPE, - * java.lang.Byte.TYPE,, also available as boolean.class, - * byte.class, etc. These are not to be confused with the - * classes java.lang.Boolean, java.lang.Byte, etc., which are - * real classes.

- * - * Also note that this is not a serializable class. It is entirely feasible - * to make it serializable using the Externalizable interface, but this is - * on Sun, not me. - * - * @author John Keiser - * @author Eric Blake - * @see Member - * @see Class - * @see java.lang.Class#getConstructor(Class[]) - * @see java.lang.Class#getDeclaredConstructor(Class[]) - * @see java.lang.Class#getConstructors() - * @see java.lang.Class#getDeclaredConstructors() - * @since 1.1 - * @status updated to 1.4 - */ -public final class Constructor - extends AccessibleObject - implements GenericDeclaration, Member -{ - private Class clazz; - private int slot; - - private static final int CONSTRUCTOR_MODIFIERS - = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC; - - /** - * This class is uninstantiable except from native code. - */ - private Constructor(Class declaringClass,int slot) - { - this.clazz = declaringClass; - this.slot = slot; - } - - private Constructor() - { - } - - /** - * Gets the class that declared this constructor. - * @return the class that declared this member - */ - public Class getDeclaringClass() - { - return clazz; - } - - /** - * Gets the name of this constructor (the non-qualified name of the class - * it was declared in). - * @return the name of this constructor - */ - public String getName() - { - return getDeclaringClass().getName(); - } - - /** - * Return the raw modifiers for this constructor. In particular - * this will include the synthetic and varargs bits. - * @return the constructor's modifiers - */ - private native int getModifiersInternal(); - - /** - * Gets the modifiers this constructor uses. Use the Modifier - * class to interpret the values. A constructor can only have a subset of the - * following modifiers: public, private, protected. - * - * @return an integer representing the modifiers to this Member - * @see Modifier - */ - public int getModifiers() - { - return getModifiersInternal() & CONSTRUCTOR_MODIFIERS; - } - - /** - * Return true if this constructor is synthetic, false otherwise. - * A synthetic member is one which is created by the compiler, - * and which does not appear in the user's source code. - * @since 1.5 - */ - public boolean isSynthetic() - { - return (getModifiersInternal() & Modifier.SYNTHETIC) != 0; - } - - /** - * Return true if this is a varargs constructor, that is if - * the constructor takes a variable number of arguments. - * @since 1.5 - */ - public boolean isVarArgs() - { - return (getModifiersInternal() & Modifier.VARARGS) != 0; - } - - /** - * Get the parameter list for this constructor, in declaration order. If the - * constructor takes no parameters, returns a 0-length array (not null). - * - * @return a list of the types of the constructor's parameters - */ - public native Class[] getParameterTypes(); - - /** - * Get the exception types this constructor says it throws, in no particular - * order. If the constructor has no throws clause, returns a 0-length array - * (not null). - * - * @return a list of the types in the constructor's throws clause - */ - public native Class[] getExceptionTypes(); - - /** - * Compare two objects to see if they are semantically equivalent. - * Two Constructors are semantically equivalent if they have the same - * declaring class and the same parameter list. This ignores different - * exception clauses, but since you can't create a Method except through the - * VM, this is just the == relation. - * - * @param o the object to compare to - * @return true if they are equal; false if not. - */ - public boolean equals(Object o) - { - if (!(o instanceof Constructor)) - return false; - Constructor that = (Constructor)o; - if (this.getDeclaringClass() != that.getDeclaringClass()) - return false; - if (!Arrays.equals(this.getParameterTypes(), that.getParameterTypes())) - return false; - return true; - } - - /** - * Get the hash code for the Constructor. The Constructor hash code is the - * hash code of the declaring class's name. - * - * @return the hash code for the object - */ - public int hashCode() - { - return getDeclaringClass().getName().hashCode(); - } - - /** - * Get a String representation of the Constructor. A Constructor's String - * representation is "<modifier> <classname>(<paramtypes>) - * throws <exceptions>", where everything after ')' is omitted if - * there are no exceptions.
Example: - * public java.io.FileInputStream(java.lang.Runnable) - * throws java.io.FileNotFoundException - * - * @return the String representation of the Constructor - */ - public String toString() - { - // 128 is a reasonable buffer initial size for constructor - StringBuilder sb = new StringBuilder(128); - Modifier.toString(getModifiers(), sb).append(' '); - sb.append(getDeclaringClass().getName()).append('('); - Class[] c = getParameterTypes(); - if (c.length > 0) - { - sb.append(ClassHelper.getUserName(c[0])); - for (int i = 1; i < c.length; i++) - sb.append(',').append(ClassHelper.getUserName(c[i])); - } - sb.append(')'); - c = getExceptionTypes(); - if (c.length > 0) - { - sb.append(" throws ").append(c[0].getName()); - for (int i = 1; i < c.length; i++) - sb.append(',').append(c[i].getName()); - } - return sb.toString(); - } - - static - void addTypeParameters(StringBuilder sb, TypeVariable[] typeArgs) - { - if (typeArgs.length == 0) - return; - sb.append('<'); - for (int i = 0; i < typeArgs.length; ++i) - { - if (i > 0) - sb.append(','); - sb.append(typeArgs[i]); - } - sb.append("> "); - } - - public String toGenericString() - { - StringBuilder sb = new StringBuilder(128); - Modifier.toString(getModifiers(), sb).append(' '); - addTypeParameters(sb, getTypeParameters()); - sb.append(getDeclaringClass().getName()).append('('); - Type[] types = getGenericParameterTypes(); - if (types.length > 0) - { - sb.append(types[0]); - for (int i = 1; i < types.length; ++i) - sb.append(',').append(types[i]); - } - sb.append(')'); - types = getGenericExceptionTypes(); - if (types.length > 0) - { - sb.append(" throws ").append(types[0]); - for (int i = 1; i < types.length; i++) - sb.append(',').append(types[i]); - } - return sb.toString(); - } - - /** - * Create a new instance by invoking the constructor. Arguments are - * automatically unwrapped and widened, if needed.

- * - * If this class is abstract, you will get an - * InstantiationException. If the constructor takes 0 - * arguments, you may use null or a 0-length array for args.

- * - * If this Constructor enforces access control, your runtime context is - * evaluated, and you may have an IllegalAccessException if - * you could not create this object in similar compiled code. If the class - * is uninitialized, you trigger class initialization, which may end in a - * ExceptionInInitializerError.

- * - * Then, the constructor is invoked. If it completes normally, the return - * value will be the new object. If it completes abruptly, the exception is - * wrapped in an InvocationTargetException. - * - * @param args the arguments to the constructor - * @return the newly created object - * @throws IllegalAccessException if the constructor could not normally be - * called by the Java code (i.e. it is not public) - * @throws IllegalArgumentException if the number of arguments is incorrect; - * or if the arguments types are wrong even with a widening - * conversion - * @throws InstantiationException if the class is abstract - * @throws InvocationTargetException if the constructor throws an exception - * @throws ExceptionInInitializerError if construction triggered class - * initialization, which then failed - */ - public T newInstance(Object... args) - throws InstantiationException, IllegalAccessException, - InvocationTargetException - { - return constructNative(args, clazz, slot); - } - - private native T constructNative(Object[] args, Class declaringClass, - int slot) - throws InstantiationException, IllegalAccessException, - InvocationTargetException; - - /** - * Returns an array of TypeVariable objects that represents - * the type variables declared by this constructor, in declaration order. - * An array of size zero is returned if this constructor has no type - * variables. - * - * @return the type variables associated with this constructor. - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public TypeVariable>[] getTypeParameters() - { - String sig = getSignature(); - if (sig == null) - return new TypeVariable[0]; - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getTypeParameters(); - } - - /** - * Return the String in the Signature attribute for this constructor. If there - * is no Signature attribute, return null. - */ - private native String getSignature(); - - /** - * Returns an array of Type objects that represents - * the exception types declared by this constructor, in declaration order. - * An array of size zero is returned if this constructor declares no - * exceptions. - * - * @return the exception types declared by this constructor. - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type[] getGenericExceptionTypes() - { - String sig = getSignature(); - if (sig == null) - return getExceptionTypes(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericExceptionTypes(); - } - - /** - * Returns an array of Type objects that represents - * the parameter list for this constructor, in declaration order. - * An array of size zero is returned if this constructor takes no - * parameters. - * - * @return a list of the types of the constructor's parameters - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type[] getGenericParameterTypes() - { - String sig = getSignature(); - if (sig == null) - return getParameterTypes(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericParameterTypes(); - } - - /** - *

- * Return an array of arrays representing the annotations on each - * of the constructor's parameters. The outer array is aligned against - * the parameters of the constructors and is thus equal in length to - * the number of parameters (thus having a length zero if there are none). - * Each array element in the outer array contains an inner array which - * holds the annotations. This array has a length of zero if the parameter - * has no annotations. - *

- *

- * The returned annotations are serialized. Changing the annotations has - * no affect on the return value of future calls to this method. - *

- * - * @return an array of arrays which represents the annotations used on the - * parameters of this constructor. The order of the array elements - * matches the declaration order of the parameters. - * @since 1.5 - */ - public native Annotation[][] getParameterAnnotations(); - -} diff --git a/libjava/classpath/vm/reference/java/lang/reflect/Field.java b/libjava/classpath/vm/reference/java/lang/reflect/Field.java deleted file mode 100644 index 5db1fa3ecc1..00000000000 --- a/libjava/classpath/vm/reference/java/lang/reflect/Field.java +++ /dev/null @@ -1,661 +0,0 @@ -/* java.lang.reflect.Field - reflection of Java fields - Copyright (C) 1998, 2001, 2005 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 java.lang.reflect; - -import gnu.java.lang.ClassHelper; - -import gnu.java.lang.reflect.FieldSignatureParser; - -/** - * The Field class represents a member variable of a class. It also allows - * dynamic access to a member, via reflection. This works for both - * static and instance fields. Operations on Field objects know how to - * do widening conversions, but throw {@link IllegalArgumentException} if - * a narrowing conversion would be necessary. You can query for information - * on this Field regardless of location, but get and set access may be limited - * by Java language access controls. If you can't do it in the compiler, you - * can't normally do it here either.

- * - * Note: This class returns and accepts types as Classes, even - * primitive types; there are Class types defined that represent each - * different primitive type. They are java.lang.Boolean.TYPE, - * java.lang.Byte.TYPE,, also available as boolean.class, - * byte.class, etc. These are not to be confused with the - * classes java.lang.Boolean, java.lang.Byte, etc., which are - * real classes.

- * - * Also note that this is not a serializable class. It is entirely feasible - * to make it serializable using the Externalizable interface, but this is - * on Sun, not me. - * - * @author John Keiser - * @author Eric Blake - * @see Member - * @see Class - * @see Class#getField(String) - * @see Class#getDeclaredField(String) - * @see Class#getFields() - * @see Class#getDeclaredFields() - * @since 1.1 - * @status updated to 1.4 - */ -public final class Field -extends AccessibleObject implements Member -{ - private Class declaringClass; - private String name; - private int slot; - - private static final int FIELD_MODIFIERS - = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED - | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT - | Modifier.VOLATILE; - - /** - * This class is uninstantiable except natively. - */ - private Field(Class declaringClass, String name, int slot) - { - this.declaringClass = declaringClass; - this.name = name; - this.slot = slot; - } - - /** - * Gets the class that declared this field, or the class where this field - * is a non-inherited member. - * @return the class that declared this member - */ - public Class getDeclaringClass() - { - return declaringClass; - } - - /** - * Gets the name of this field. - * @return the name of this field - */ - public String getName() - { - return name; - } - - /** - * Return the raw modifiers for this field. - * @return the field's modifiers - */ - private native int getModifiersInternal(); - - /** - * Gets the modifiers this field uses. Use the Modifier - * class to interpret the values. A field can only have a subset of the - * following modifiers: public, private, protected, static, final, - * transient, and volatile. - * - * @return an integer representing the modifiers to this Member - * @see Modifier - */ - public int getModifiers() - { - return getModifiersInternal() & FIELD_MODIFIERS; - } - - /** - * Return true if this field is synthetic, false otherwise. - * @since 1.5 - */ - public boolean isSynthetic() - { - return (getModifiersInternal() & Modifier.SYNTHETIC) != 0; - } - - /** - * Return true if this field represents an enum constant, - * false otherwise. - * @since 1.5 - */ - public boolean isEnumConstant() - { - return (getModifiersInternal() & Modifier.ENUM) != 0; - } - - /** - * Gets the type of this field. - * @return the type of this field - */ - public native Class getType(); - - /** - * Compare two objects to see if they are semantically equivalent. - * Two Fields are semantically equivalent if they have the same declaring - * class, name, and type. Since you can't creat a Field except through - * the VM, this is just the == relation. - * - * @param o the object to compare to - * @return true if they are equal; false if not - */ - public boolean equals(Object o) - { - if (!(o instanceof Field)) - return false; - Field that = (Field)o; - if (this.getDeclaringClass() != that.getDeclaringClass()) - return false; - if (!this.getName().equals(that.getName())) - return false; - if (this.getType() != that.getType()) - return false; - return true; - } - - /** - * Get the hash code for the Field. The Field hash code is the hash code - * of its name XOR'd with the hash code of its class name. - * - * @return the hash code for the object. - */ - public int hashCode() - { - return getDeclaringClass().getName().hashCode() ^ getName().hashCode(); - } - - /** - * Get a String representation of the Field. A Field's String - * representation is "<modifiers> <type> - * <class>.<fieldname>".
Example: - * public transient boolean gnu.parse.Parser.parseComplete - * - * @return the String representation of the Field - */ - public String toString() - { - // 64 is a reasonable buffer initial size for field - StringBuilder sb = new StringBuilder(64); - Modifier.toString(getModifiers(), sb).append(' '); - sb.append(ClassHelper.getUserName(getType())).append(' '); - sb.append(getDeclaringClass().getName()).append('.'); - sb.append(getName()); - return sb.toString(); - } - - public String toGenericString() - { - StringBuilder sb = new StringBuilder(64); - Modifier.toString(getModifiers(), sb).append(' '); - sb.append(getGenericType()).append(' '); - sb.append(getDeclaringClass().getName()).append('.'); - sb.append(getName()); - return sb.toString(); - } - - /** - * Get the value of this Field. If it is primitive, it will be wrapped - * in the appropriate wrapper type (boolean = java.lang.Boolean).

- * - * If the field is static, o will be ignored. Otherwise, if - * o is null, you get a NullPointerException, - * and if it is incompatible with the declaring class of the field, you - * get an IllegalArgumentException.

- * - * Next, if this Field enforces access control, your runtime context is - * evaluated, and you may have an IllegalAccessException if - * you could not access this field in similar compiled code. If the field - * is static, and its class is uninitialized, you trigger class - * initialization, which may end in a - * ExceptionInInitializerError.

- * - * Finally, the field is accessed, and primitives are wrapped (but not - * necessarily in new objects). This method accesses the field of the - * declaring class, even if the instance passed in belongs to a subclass - * which declares another field to hide this one. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if o is not an instance of - * the class or interface declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #getBoolean(Object) - * @see #getByte(Object) - * @see #getChar(Object) - * @see #getShort(Object) - * @see #getInt(Object) - * @see #getLong(Object) - * @see #getFloat(Object) - * @see #getDouble(Object) - */ - public native Object get(Object o) - throws IllegalAccessException; - - /** - * Get the value of this boolean Field. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a boolean field of - * o, or if o is not an instance of the - * declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native boolean getBoolean(Object o) - throws IllegalAccessException; - - /** - * Get the value of this byte Field. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte field of - * o, or if o is not an instance of the - * declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native byte getByte(Object o) - throws IllegalAccessException; - - /** - * Get the value of this Field as a char. If the field is static, - * o will be ignored. - * - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a char field of - * o, or if o is not an instance - * of the declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native char getChar(Object o) - throws IllegalAccessException; - - /** - * Get the value of this Field as a short. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte or short - * field of o, or if o is not an instance - * of the declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native short getShort(Object o) - throws IllegalAccessException; - - /** - * Get the value of this Field as an int. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, or - * int field of o, or if o is not an - * instance of the declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native int getInt(Object o) - throws IllegalAccessException; - - /** - * Get the value of this Field as a long. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, int, - * or long field of o, or if o is not an - * instance of the declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native long getLong(Object o) - throws IllegalAccessException; - - /** - * Get the value of this Field as a float. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, int, - * long, or float field of o, or if o is - * not an instance of the declaring class of this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native float getFloat(Object o) - throws IllegalAccessException; - - /** - * Get the value of this Field as a double. If the field is static, - * o will be ignored. - * - * @param o the object to get the value of this Field from - * @return the value of the Field - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, char, int, - * long, float, or double field of o, or if - * o is not an instance of the declaring class of this - * field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #get(Object) - */ - public native double getDouble(Object o) - throws IllegalAccessException; - - /** - * Set the value of this Field. If it is a primitive field, the value - * will be unwrapped from the passed object (boolean = java.lang.Boolean).

- * - * If the field is static, o will be ignored. Otherwise, if - * o is null, you get a NullPointerException, - * and if it is incompatible with the declaring class of the field, you - * get an IllegalArgumentException.

- * - * Next, if this Field enforces access control, your runtime context is - * evaluated, and you may have an IllegalAccessException if - * you could not access this field in similar compiled code. This also - * occurs whether or not there is access control if the field is final. - * If the field is primitive, and unwrapping your argument fails, you will - * get an IllegalArgumentException; likewise, this error - * happens if value cannot be cast to the correct object type. - * If the field is static, and its class is uninitialized, you trigger class - * initialization, which may end in a - * ExceptionInInitializerError.

- * - * Finally, the field is set with the widened value. This method accesses - * the field of the declaring class, even if the instance passed in belongs - * to a subclass which declares another field to hide this one. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if value cannot be - * converted by a widening conversion to the underlying type of - * the Field, or if o is not an instance of the class - * declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #setBoolean(Object, boolean) - * @see #setByte(Object, byte) - * @see #setChar(Object, char) - * @see #setShort(Object, short) - * @see #setInt(Object, int) - * @see #setLong(Object, long) - * @see #setFloat(Object, float) - * @see #setDouble(Object, double) - */ - public native void set(Object o, Object value) - throws IllegalAccessException; - - /** - * Set this boolean Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a boolean field, or if - * o is not an instance of the class declaring this - * field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setBoolean(Object o, boolean value) - throws IllegalAccessException; - - /** - * Set this byte Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a byte, short, int, long, - * float, or double field, or if o is not an instance - * of the class declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setByte(Object o, byte value) - throws IllegalAccessException; - - /** - * Set this char Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a char, int, long, - * float, or double field, or if o is not an instance - * of the class declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setChar(Object o, char value) - throws IllegalAccessException; - - /** - * Set this short Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a short, int, long, - * float, or double field, or if o is not an instance - * of the class declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setShort(Object o, short value) - throws IllegalAccessException; - - /** - * Set this int Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not an int, long, float, or - * double field, or if o is not an instance of the - * class declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setInt(Object o, int value) - throws IllegalAccessException; - - /** - * Set this long Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a long, float, or double - * field, or if o is not an instance of the class - * declaring this field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setLong(Object o, long value) - throws IllegalAccessException; - - /** - * Set this float Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a float or long field, or - * if o is not an instance of the class declaring this - * field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setFloat(Object o, float value) - throws IllegalAccessException; - - /** - * Set this double Field. If the field is static, o will be - * ignored. - * - * @param o the object to set this Field on - * @param value the value to set this Field to - * @throws IllegalAccessException if you could not normally access this field - * (i.e. it is not public) - * @throws IllegalArgumentException if this is not a double field, or if - * o is not an instance of the class declaring this - * field - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static field triggered - * class initialization, which then failed - * @see #set(Object, Object) - */ - public native void setDouble(Object o, double value) - throws IllegalAccessException; - - /** - * Return the generic type of the field. If the field type is not a generic - * type, the method returns the same as getType(). - * - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type getGenericType() - { - String signature = getSignature(); - if (signature == null) - return getType(); - FieldSignatureParser p = new FieldSignatureParser(getDeclaringClass(), - signature); - return p.getFieldType(); - } - - /** - * Return the String in the Signature attribute for this field. If there - * is no Signature attribute, return null. - */ - private native String getSignature(); -} diff --git a/libjava/classpath/vm/reference/java/lang/reflect/Method.java b/libjava/classpath/vm/reference/java/lang/reflect/Method.java deleted file mode 100644 index d797d4fda18..00000000000 --- a/libjava/classpath/vm/reference/java/lang/reflect/Method.java +++ /dev/null @@ -1,489 +0,0 @@ -/* java.lang.reflect.Method - reflection of Java methods - Copyright (C) 1998, 2001, 2002, 2005, 2007 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 java.lang.reflect; - -import gnu.java.lang.ClassHelper; - -import gnu.java.lang.reflect.MethodSignatureParser; - -import java.lang.annotation.Annotation; -import java.util.Arrays; - -/** - * The Method class represents a member method of a class. It also allows - * dynamic invocation, via reflection. This works for both static and - * instance methods. Invocation on Method objects knows how to do - * widening conversions, but throws {@link IllegalArgumentException} if - * a narrowing conversion would be necessary. You can query for information - * on this Method regardless of location, but invocation access may be limited - * by Java language access controls. If you can't do it in the compiler, you - * can't normally do it here either.

- * - * Note: This class returns and accepts types as Classes, even - * primitive types; there are Class types defined that represent each - * different primitive type. They are java.lang.Boolean.TYPE, - * java.lang.Byte.TYPE,, also available as boolean.class, - * byte.class, etc. These are not to be confused with the - * classes java.lang.Boolean, java.lang.Byte, etc., which are - * real classes.

- * - * Also note that this is not a serializable class. It is entirely feasible - * to make it serializable using the Externalizable interface, but this is - * on Sun, not me. - * - * @author John Keiser - * @author Eric Blake - * @see Member - * @see Class - * @see java.lang.Class#getMethod(String,Class[]) - * @see java.lang.Class#getDeclaredMethod(String,Class[]) - * @see java.lang.Class#getMethods() - * @see java.lang.Class#getDeclaredMethods() - * @since 1.1 - * @status updated to 1.4 - */ -public final class Method -extends AccessibleObject implements Member, GenericDeclaration -{ - Class declaringClass; - String name; - int slot; - - private static final int METHOD_MODIFIERS - = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE - | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC - | Modifier.STATIC | Modifier.STRICT | Modifier.SYNCHRONIZED; - - /** - * This class is uninstantiable. - */ - private Method(Class declaringClass, String name, int slot) - { - this.declaringClass = declaringClass; - this.name = name; - this.slot = slot; - } - - /** - * Gets the class that declared this method, or the class where this method - * is a non-inherited member. - * @return the class that declared this member - */ - public Class getDeclaringClass() - { - return declaringClass; - } - - /** - * Gets the name of this method. - * @return the name of this method - */ - public String getName() - { - return name; - } - - /** - * Return the raw modifiers for this method. - * @return the method's modifiers - */ - private native int getModifiersInternal(); - - /** - * Gets the modifiers this method uses. Use the Modifier - * class to interpret the values. A method can only have a subset of the - * following modifiers: public, private, protected, abstract, static, - * final, synchronized, native, and strictfp. - * - * @return an integer representing the modifiers to this Member - * @see Modifier - */ - public int getModifiers() - { - return getModifiersInternal() & METHOD_MODIFIERS; - } - - /** - * Return true if this method is a bridge method. A bridge method - * is generated by the compiler in some situations involving - * generics and inheritance. - * @since 1.5 - */ - public boolean isBridge() - { - return (getModifiersInternal() & Modifier.BRIDGE) != 0; - } - - /** - * Return true if this method is synthetic, false otherwise. - * @since 1.5 - */ - public boolean isSynthetic() - { - return (getModifiersInternal() & Modifier.SYNTHETIC) != 0; - } - - /** - * Return true if this is a varargs method, that is if - * the method takes a variable number of arguments. - * @since 1.5 - */ - public boolean isVarArgs() - { - return (getModifiersInternal() & Modifier.VARARGS) != 0; - } - - /** - * Gets the return type of this method. - * @return the type of this method - */ - public native Class getReturnType(); - - /** - * Get the parameter list for this method, in declaration order. If the - * method takes no parameters, returns a 0-length array (not null). - * - * @return a list of the types of the method's parameters - */ - public native Class[] getParameterTypes(); - - /** - * Get the exception types this method says it throws, in no particular - * order. If the method has no throws clause, returns a 0-length array - * (not null). - * - * @return a list of the types in the method's throws clause - */ - public native Class[] getExceptionTypes(); - - /** - * Compare two objects to see if they are semantically equivalent. - * Two Methods are semantically equivalent if they have the same declaring - * class, name, parameter list, and return type. - * - * @param o the object to compare to - * @return true if they are equal; false if not - */ - public boolean equals(Object o) - { - // Implementation note: - // The following is a correct but possibly slow implementation. - // - // This class has a private field 'slot' that could be used by - // the VM implementation to "link" a particular method to a Class. - // In that case equals could be simply implemented as: - // - // if (o instanceof Method) - // { - // Method m = (Method)o; - // return m.declaringClass == this.declaringClass - // && m.slot == this.slot; - // } - // return false; - // - // If a VM uses the Method class as their native/internal representation - // then just using the following would be optimal: - // - // return this == o; - // - if (!(o instanceof Method)) - return false; - Method that = (Method)o; - if (this.getDeclaringClass() != that.getDeclaringClass()) - return false; - if (!this.getName().equals(that.getName())) - return false; - if (this.getReturnType() != that.getReturnType()) - return false; - if (!Arrays.equals(this.getParameterTypes(), that.getParameterTypes())) - return false; - return true; - } - - /** - * Get the hash code for the Method. The Method hash code is the hash code - * of its name XOR'd with the hash code of its class name. - * - * @return the hash code for the object - */ - public int hashCode() - { - return getDeclaringClass().getName().hashCode() ^ getName().hashCode(); - } - - /** - * Get a String representation of the Method. A Method's String - * representation is "<modifiers> <returntype> - * <methodname>(<paramtypes>) throws <exceptions>", where - * everything after ')' is omitted if there are no exceptions.
Example: - * public static int run(java.lang.Runnable,int) - * - * @return the String representation of the Method - */ - public String toString() - { - // 128 is a reasonable buffer initial size for constructor - StringBuilder sb = new StringBuilder(128); - Modifier.toString(getModifiers(), sb).append(' '); - sb.append(ClassHelper.getUserName(getReturnType())).append(' '); - sb.append(getDeclaringClass().getName()).append('.'); - sb.append(getName()).append('('); - Class[] c = getParameterTypes(); - if (c.length > 0) - { - sb.append(ClassHelper.getUserName(c[0])); - for (int i = 1; i < c.length; i++) - sb.append(',').append(ClassHelper.getUserName(c[i])); - } - sb.append(')'); - c = getExceptionTypes(); - if (c.length > 0) - { - sb.append(" throws ").append(c[0].getName()); - for (int i = 1; i < c.length; i++) - sb.append(',').append(c[i].getName()); - } - return sb.toString(); - } - - public String toGenericString() - { - // 128 is a reasonable buffer initial size for constructor - StringBuilder sb = new StringBuilder(128); - Modifier.toString(getModifiers(), sb).append(' '); - Constructor.addTypeParameters(sb, getTypeParameters()); - sb.append(getGenericReturnType()).append(' '); - sb.append(getDeclaringClass().getName()).append('.'); - sb.append(getName()).append('('); - Type[] types = getGenericParameterTypes(); - if (types.length > 0) - { - sb.append(types[0]); - for (int i = 1; i < types.length; i++) - sb.append(',').append(types[i]); - } - sb.append(')'); - types = getGenericExceptionTypes(); - if (types.length > 0) - { - sb.append(" throws ").append(types[0]); - for (int i = 1; i < types.length; i++) - sb.append(',').append(types[i]); - } - return sb.toString(); - } - - /** - * Invoke the method. Arguments are automatically unwrapped and widened, - * and the result is automatically wrapped, if needed.

- * - * If the method is static, o will be ignored. Otherwise, - * the method uses dynamic lookup as described in JLS 15.12.4.4. You cannot - * mimic the behavior of nonvirtual lookup (as in super.foo()). This means - * you will get a NullPointerException if o is - * null, and an IllegalArgumentException if it is incompatible - * with the declaring class of the method. If the method takes 0 arguments, - * you may use null or a 0-length array for args.

- * - * Next, if this Method enforces access control, your runtime context is - * evaluated, and you may have an IllegalAccessException if - * you could not acces this method in similar compiled code. If the method - * is static, and its class is uninitialized, you trigger class - * initialization, which may end in a - * ExceptionInInitializerError.

- * - * Finally, the method is invoked. If it completes normally, the return value - * will be null for a void method, a wrapped object for a primitive return - * method, or the actual return of an Object method. If it completes - * abruptly, the exception is wrapped in an - * InvocationTargetException. - * - * @param o the object to invoke the method on - * @param args the arguments to the method - * @return the return value of the method, wrapped in the appropriate - * wrapper if it is primitive - * @throws IllegalAccessException if the method could not normally be called - * by the Java code (i.e. it is not public) - * @throws IllegalArgumentException if the number of arguments is incorrect; - * if the arguments types are wrong even with a widening conversion; - * or if o is not an instance of the class or interface - * declaring this method - * @throws InvocationTargetException if the method throws an exception - * @throws NullPointerException if o is null and this field - * requires an instance - * @throws ExceptionInInitializerError if accessing a static method triggered - * class initialization, which then failed - */ - public Object invoke(Object o, Object... args) - throws IllegalAccessException, InvocationTargetException - { - return invokeNative(o, args, declaringClass, slot); - } - - /* - * NATIVE HELPERS - */ - - private native Object invokeNative(Object o, Object[] args, - Class declaringClass, int slot) - throws IllegalAccessException, InvocationTargetException; - - /** - * Returns an array of TypeVariable objects that represents - * the type variables declared by this constructor, in declaration order. - * An array of size zero is returned if this class has no type - * variables. - * - * @return the type variables associated with this class. - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public TypeVariable[] getTypeParameters() - { - String sig = getSignature(); - if (sig == null) - return new TypeVariable[0]; - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getTypeParameters(); - } - - /** - * Return the String in the Signature attribute for this method. If there - * is no Signature attribute, return null. - */ - private native String getSignature(); - - /** - * Returns an array of Type objects that represents - * the exception types declared by this method, in declaration order. - * An array of size zero is returned if this method declares no - * exceptions. - * - * @return the exception types declared by this method. - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type[] getGenericExceptionTypes() - { - String sig = getSignature(); - if (sig == null) - return getExceptionTypes(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericExceptionTypes(); - } - - /** - * Returns an array of Type objects that represents - * the parameter list for this method, in declaration order. - * An array of size zero is returned if this method takes no - * parameters. - * - * @return a list of the types of the method's parameters - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type[] getGenericParameterTypes() - { - String sig = getSignature(); - if (sig == null) - return getParameterTypes(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericParameterTypes(); - } - - /** - * Returns the return type of this method. - * - * @return the return type of this method - * @throws GenericSignatureFormatError if the generic signature does - * not conform to the format specified in the Virtual Machine - * specification, version 3. - * @since 1.5 - */ - public Type getGenericReturnType() - { - String sig = getSignature(); - if (sig == null) - return getReturnType(); - MethodSignatureParser p = new MethodSignatureParser(this, sig); - return p.getGenericReturnType(); - } - - /** - * If this method is an annotation method, returns the default - * value for the method. If there is no default value, or if the - * method is not a member of an annotation type, returns null. - * Primitive types are wrapped. - * - * @throws TypeNotPresentException if the method returns a Class, - * and the class cannot be found - * - * @since 1.5 - */ - public native Object getDefaultValue(); - - /** - *

- * Return an array of arrays representing the annotations on each - * of the method's parameters. The outer array is aligned against - * the parameters of the method and is thus equal in length to - * the number of parameters (thus having a length zero if there are none). - * Each array element in the outer array contains an inner array which - * holds the annotations. This array has a length of zero if the parameter - * has no annotations. - *

- *

- * The returned annotations are serialized. Changing the annotations has - * no affect on the return value of future calls to this method. - *

- * - * @return an array of arrays which represents the annotations used on the - * parameters of this method. The order of the array elements - * matches the declaration order of the parameters. - * @since 1.5 - */ - public native Annotation[][] getParameterAnnotations(); - -} diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java b/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java new file mode 100644 index 00000000000..dbed90388a3 --- /dev/null +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMConstructor.java @@ -0,0 +1,169 @@ +/* java.lang.reflect.VMConstructor - VM interface for reflection of Java constructors + Copyright (C) 1998, 2001, 2004, 2005 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 java.lang.reflect; + +import java.lang.annotation.Annotation; + +import java.util.Arrays; + +final class VMConstructor +{ + Class clazz; + int slot; + + /** + * This field allows us to refer back to the main constructor instance. + * It is set by the constructor of Constructor. + */ + Constructor cons; + + VMConstructor(Class clazz, int slot) + { + this.clazz = clazz; + this.slot = slot; + } + + public Class getDeclaringClass() + { + return clazz; + } + + /** + * Return the raw modifiers for this constructor. In particular + * this will include the synthetic and varargs bits. + * @return the constructor's modifiers + */ + native int getModifiersInternal(); + + /** + * Get the parameter list for this constructor, in declaration order. If the + * constructor takes no parameters, returns a 0-length array (not null). + * + * @return a list of the types of the constructor's parameters + */ + native Class[] getParameterTypes(); + + /** + * Get the exception types this constructor says it throws, in no particular + * order. If the constructor has no throws clause, returns a 0-length array + * (not null). + * + * @return a list of the types in the constructor's throws clause + */ + native Class[] getExceptionTypes(); + + native Object construct(Object[] args) + throws InstantiationException, IllegalAccessException, + InvocationTargetException; + + /** + * Return the String in the Signature attribute for this constructor. If there + * is no Signature attribute, return null. + */ + native String getSignature(); + + /** + *

+ * Return an array of arrays representing the annotations on each + * of the constructor's parameters. The outer array is aligned against + * the parameters of the constructors and is thus equal in length to + * the number of parameters (thus having a length zero if there are none). + * Each array element in the outer array contains an inner array which + * holds the annotations. This array has a length of zero if the parameter + * has no annotations. + *

+ *

+ * The returned annotations are serialized. Changing the annotations has + * no affect on the return value of future calls to this method. + *

+ * + * @return an array of arrays which represents the annotations used on the + * parameters of this constructor. The order of the array elements + * matches the declaration order of the parameters. + * @since 1.5 + */ + native Annotation[][] getParameterAnnotations(); + + /** + * Compare two objects to see if they are semantically equivalent. + * Two Constructors are semantically equivalent if they have the same + * declaring class and the same parameter list. This ignores different + * exception clauses, but since you can't create a Method except through the + * VM, this is just the == relation. + * + * @param o the object to compare to + * @return true if they are equal; false if not. + */ + public boolean equals(Object o) + { + if (!(o instanceof Constructor)) + return false; + Constructor that = (Constructor)o; + if (clazz != that.getDeclaringClass()) + return false; + if (!Arrays.equals(getParameterTypes(), that.getParameterTypes())) + return false; + return true; + } + + /** + * Returns the element's annotation for the specified annotation type, + * or null if no such annotation exists. + * + * @param annotationClass the type of annotation to look for. + * @return this element's annotation for the specified type, or + * null if no such annotation exists. + * @throws NullPointerException if the annotation class is null. + */ + native Annotation getAnnotation(Class annotationClass); + + /** + * Returns all annotations directly defined by the element. If there are + * no annotations directly associated with the element, then a zero-length + * array will be returned. The returned array may be modified by the client + * code, but this will have no effect on the annotation content of this + * class, and hence no effect on the return value of this method for + * future callers. + * + * @return the annotations directly defined by the element. + * @since 1.5 + */ + native Annotation[] getDeclaredAnnotations(); + +} diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMField.java b/libjava/classpath/vm/reference/java/lang/reflect/VMField.java new file mode 100644 index 00000000000..53f38474952 --- /dev/null +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMField.java @@ -0,0 +1,549 @@ +/* java.lang.reflect.Field - VM interface for reflection of Java fields + Copyright (C) 1998, 2001, 2005, 2008 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 java.lang.reflect; + +import java.lang.annotation.Annotation; + +final class VMField +{ + Class clazz; + String name; + int slot; + + /** + * This field allows us to refer back to the main constructor instance. + * It is set by the constructor of Field. + */ + Field f; + + VMField(Class clazz, String name, int slot) + { + this.clazz = clazz; + this.name = name; + this.slot = slot; + } + + public Class getDeclaringClass() + { + return clazz; + } + + public String getName() + { + return name; + } + + /** + * Return the raw modifiers for this field. + * @return the field's modifiers + */ + native int getModifiersInternal(); + + /** + * Gets the type of this field. + * @return the type of this field + */ + native Class getType(); + + /** + * Get the value of this Field. If it is primitive, it will be wrapped + * in the appropriate wrapper type (boolean = java.lang.Boolean).

+ * + * If the field is static, o will be ignored. Otherwise, if + * o is null, you get a NullPointerException, + * and if it is incompatible with the declaring class of the field, you + * get an IllegalArgumentException.

+ * + * Next, if this Field enforces access control, your runtime context is + * evaluated, and you may have an IllegalAccessException if + * you could not access this field in similar compiled code. If the field + * is static, and its class is uninitialized, you trigger class + * initialization, which may end in a + * ExceptionInInitializerError.

+ * + * Finally, the field is accessed, and primitives are wrapped (but not + * necessarily in new objects). This method accesses the field of the + * declaring class, even if the instance passed in belongs to a subclass + * which declares another field to hide this one. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if o is not an instance of + * the class or interface declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #getBoolean(Object) + * @see #getByte(Object) + * @see #getChar(Object) + * @see #getShort(Object) + * @see #getInt(Object) + * @see #getLong(Object) + * @see #getFloat(Object) + * @see #getDouble(Object) + */ + native Object get(Object o) + throws IllegalAccessException; + + /** + * Get the value of this boolean Field. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a boolean field of + * o, or if o is not an instance of the + * declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native boolean getBoolean(Object o) + throws IllegalAccessException; + + /** + * Get the value of this byte Field. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte field of + * o, or if o is not an instance of the + * declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native byte getByte(Object o) + throws IllegalAccessException; + + /** + * Get the value of this Field as a char. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a char field of + * o, or if o is not an instance + * of the declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native char getChar(Object o) + throws IllegalAccessException; + + /** + * Get the value of this Field as a short. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte or short + * field of o, or if o is not an instance + * of the declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native short getShort(Object o) + throws IllegalAccessException; + + /** + * Get the value of this Field as an int. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte, short, char, or + * int field of o, or if o is not an + * instance of the declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native int getInt(Object o) + throws IllegalAccessException; + + /** + * Get the value of this Field as a long. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte, short, char, int, + * or long field of o, or if o is not an + * instance of the declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native long getLong(Object o) + throws IllegalAccessException; + + /** + * Get the value of this Field as a float. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte, short, char, int, + * long, or float field of o, or if o is + * not an instance of the declaring class of this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native float getFloat(Object o) + throws IllegalAccessException; + + /** + * Get the value of this Field as a double. If the field is static, + * o will be ignored. + * + * @param o the object to get the value of this Field from + * @return the value of the Field + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte, short, char, int, + * long, float, or double field of o, or if + * o is not an instance of the declaring class of this + * field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #get(Object) + */ + native double getDouble(Object o) + throws IllegalAccessException; + + /** + * Set the value of this Field. If it is a primitive field, the value + * will be unwrapped from the passed object (boolean = java.lang.Boolean).

+ * + * If the field is static, o will be ignored. Otherwise, if + * o is null, you get a NullPointerException, + * and if it is incompatible with the declaring class of the field, you + * get an IllegalArgumentException.

+ * + * Next, if this Field enforces access control, your runtime context is + * evaluated, and you may have an IllegalAccessException if + * you could not access this field in similar compiled code. This also + * occurs whether or not there is access control if the field is final. + * If the field is primitive, and unwrapping your argument fails, you will + * get an IllegalArgumentException; likewise, this error + * happens if value cannot be cast to the correct object type. + * If the field is static, and its class is uninitialized, you trigger class + * initialization, which may end in a + * ExceptionInInitializerError.

+ * + * Finally, the field is set with the widened value. This method accesses + * the field of the declaring class, even if the instance passed in belongs + * to a subclass which declares another field to hide this one. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if value cannot be + * converted by a widening conversion to the underlying type of + * the Field, or if o is not an instance of the class + * declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #setBoolean(Object, boolean) + * @see #setByte(Object, byte) + * @see #setChar(Object, char) + * @see #setShort(Object, short) + * @see #setInt(Object, int) + * @see #setLong(Object, long) + * @see #setFloat(Object, float) + * @see #setDouble(Object, double) + */ + native void set(Object o, Object value) + throws IllegalAccessException; + + /** + * Set this boolean Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a boolean field, or if + * o is not an instance of the class declaring this + * field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setBoolean(Object o, boolean value) + throws IllegalAccessException; + + /** + * Set this byte Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a byte, short, int, long, + * float, or double field, or if o is not an instance + * of the class declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setByte(Object o, byte value) + throws IllegalAccessException; + + /** + * Set this char Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a char, int, long, + * float, or double field, or if o is not an instance + * of the class declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setChar(Object o, char value) + throws IllegalAccessException; + + /** + * Set this short Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a short, int, long, + * float, or double field, or if o is not an instance + * of the class declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setShort(Object o, short value) + throws IllegalAccessException; + + /** + * Set this int Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not an int, long, float, or + * double field, or if o is not an instance of the + * class declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setInt(Object o, int value) + throws IllegalAccessException; + + /** + * Set this long Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a long, float, or double + * field, or if o is not an instance of the class + * declaring this field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setLong(Object o, long value) + throws IllegalAccessException; + + /** + * Set this float Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a float or long field, or + * if o is not an instance of the class declaring this + * field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setFloat(Object o, float value) + throws IllegalAccessException; + + /** + * Set this double Field. If the field is static, o will be + * ignored. + * + * @param o the object to set this Field on + * @param value the value to set this Field to + * @throws IllegalAccessException if you could not normally access this field + * (i.e. it is not public) + * @throws IllegalArgumentException if this is not a double field, or if + * o is not an instance of the class declaring this + * field + * @throws NullPointerException if o is null and this field + * requires an instance + * @throws ExceptionInInitializerError if accessing a static field triggered + * class initialization, which then failed + * @see #set(Object, Object) + */ + native void setDouble(Object o, double value) + throws IllegalAccessException; + + /** + * Return the String in the Signature attribute for this field. If there + * is no Signature attribute, return null. + * + */ + native String getSignature(); + + /** + * Compare two objects to see if they are semantically equivalent. + * Two Fields are semantically equivalent if they have the same declaring + * class, name, and type. Since you can't create a Field except through + * the VM, this is just the == relation. + * + * @param o the object to compare to + * @return true if they are equal; false if not + */ + public boolean equals(Object o) + { + if (!(o instanceof Field)) + return false; + Field that = (Field)o; + if (clazz != that.getDeclaringClass()) + return false; + if (!name.equals(that.getName())) + return false; + if (getType() != that.getType()) + return false; + return true; + } + + /** + * Returns the element's annotation for the specified annotation type, + * or null if no such annotation exists. + * + * @param annotationClass the type of annotation to look for. + * @return this element's annotation for the specified type, or + * null if no such annotation exists. + * @throws NullPointerException if the annotation class is null. + */ + native Annotation getAnnotation(Class annotationClass); + + /** + * Returns all annotations directly defined by the element. If there are + * no annotations directly associated with the element, then a zero-length + * array will be returned. The returned array may be modified by the client + * code, but this will have no effect on the annotation content of this + * class, and hence no effect on the return value of this method for + * future callers. + * + * @return the annotations directly defined by the element. + * @since 1.5 + */ + native Annotation[] getDeclaredAnnotations(); + +} diff --git a/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java b/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java new file mode 100644 index 00000000000..f8574cd87a2 --- /dev/null +++ b/libjava/classpath/vm/reference/java/lang/reflect/VMMethod.java @@ -0,0 +1,209 @@ +/* java.lang.reflect.VMMethod - VM interface for reflection of Java methods + Copyright (C) 1998, 2001, 2002, 2005, 2007, 2008 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 java.lang.reflect; + +import java.lang.annotation.Annotation; + +import java.util.Arrays; + +final class VMMethod +{ + Class clazz; + String name; + int slot; + + /** + * This field allows us to refer back to the main constructor instance. + * It is set by the constructor of Field. + */ + Method m; + + public Class getDeclaringClass() + { + return clazz; + } + + public String getName() + { + return name; + } + + /** + * Return the raw modifiers for this method. + * @return the method's modifiers + */ + native int getModifiersInternal(); + + /** + * Gets the return type of this method. + * @return the type of this method + */ + native Class getReturnType(); + + /** + * Get the parameter list for this method, in declaration order. If the + * method takes no parameters, returns a 0-length array (not null). + * + * @return a list of the types of the method's parameters + */ + native Class[] getParameterTypes(); + + /** + * Get the exception types this method says it throws, in no particular + * order. If the method has no throws clause, returns a 0-length array + * (not null). + * + * @return a list of the types in the method's throws clause + */ + native Class[] getExceptionTypes(); + + native Object invoke(Object o, Object[] args) + throws IllegalAccessException, InvocationTargetException; + + /** + * Return the String in the Signature attribute for this method. If there + * is no Signature attribute, return null. + */ + native String getSignature(); + + /** + * If this method is an annotation method, returns the default + * value for the method. If there is no default value, or if the + * method is not a member of an annotation type, returns null. + * Primitive types are wrapped. + * + * @throws TypeNotPresentException if the method returns a Class, + * and the class cannot be found + * + * @since 1.5 + */ + native Object getDefaultValue(); + + /** + *

+ * Return an array of arrays representing the annotations on each + * of the method's parameters. The outer array is aligned against + * the parameters of the method and is thus equal in length to + * the number of parameters (thus having a length zero if there are none). + * Each array element in the outer array contains an inner array which + * holds the annotations. This array has a length of zero if the parameter + * has no annotations. + *

+ *

+ * The returned annotations are serialized. Changing the annotations has + * no affect on the return value of future calls to this method. + *

+ * + * @return an array of arrays which represents the annotations used on the + * parameters of this method. The order of the array elements + * matches the declaration order of the parameters. + * @since 1.5 + */ + native Annotation[][] getParameterAnnotations(); + + /** + * Compare two objects to see if they are semantically equivalent. + * Two Methods are semantically equivalent if they have the same declaring + * class, name, parameter list, and return type. + * + * @param o the object to compare to + * @return true if they are equal; false if not + */ + public boolean equals(Object o) + { + // Implementation note: + // The following is a correct but possibly slow implementation. + // + // This class has a private field 'slot' that could be used by + // the VM implementation to "link" a particular method to a Class. + // In that case equals could be simply implemented as: + // + // if (o instanceof Method) + // { + // Method m = (Method)o; + // return m.declaringClass == this.declaringClass + // && m.slot == this.slot; + // } + // return false; + // + // If a VM uses the Method class as their native/internal representation + // then just using the following would be optimal: + // + // return this == o; + // + if (!(o instanceof Method)) + return false; + Method that = (Method)o; + if (clazz != that.getDeclaringClass()) + return false; + if (!name.equals(that.getName())) + return false; + if (getReturnType() != that.getReturnType()) + return false; + if (!Arrays.equals(getParameterTypes(), that.getParameterTypes())) + return false; + return true; + } + + /** + * Returns the element's annotation for the specified annotation type, + * or null if no such annotation exists. + * + * @param annotationClass the type of annotation to look for. + * @return this element's annotation for the specified type, or + * null if no such annotation exists. + * @throws NullPointerException if the annotation class is null. + */ + native Annotation getAnnotation(Class annotationClass); + + /** + * Returns all annotations directly defined by the element. If there are + * no annotations directly associated with the element, then a zero-length + * array will be returned. The returned array may be modified by the client + * code, but this will have no effect on the annotation content of this + * class, and hence no effect on the return value of this method for + * future callers. + * + * @return the annotations directly defined by the element. + * @since 1.5 + */ + native Annotation[] getDeclaredAnnotations(); + +} + diff --git a/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java b/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java index e28e6161a58..63a29b16ba5 100644 --- a/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java +++ b/libjava/classpath/vm/reference/java/net/VMNetworkInterface.java @@ -1,5 +1,5 @@ /* VMNetworkInterface.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2008 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -57,12 +57,12 @@ import java.util.Set; final class VMNetworkInterface { String name; - Set addresses; + Set addresses; VMNetworkInterface(String name) { this.name = name; - addresses = new HashSet(); + addresses = new HashSet(); } /** @@ -71,7 +71,7 @@ final class VMNetworkInterface */ public VMNetworkInterface() { - addresses = new HashSet(); + addresses = new HashSet(); try { addresses.add(InetAddress.getByName("0.0.0.0")); @@ -119,4 +119,13 @@ final class VMNetworkInterface else throw new SocketException("invalid interface address"); } + + static native boolean isUp(String name) throws SocketException; + + static native boolean isLoopback(String name) throws SocketException; + + static native boolean isPointToPoint(String name) throws SocketException; + + static native boolean supportsMulticast(String name) throws SocketException; + } -- cgit v1.2.3