
libjava/ChangeLog: 2008-10-21 Andrew John Hughes <gnu_andrew@member.fsf.org> * sources.am, Makfile.in: Regenerate. 2008-10-17 Matthias Klose <doko@ubuntu.com> * configure.ac: Fix bashisms. * configure: Regenerate. 2008-10-15 Matthias Klose <doko@ubuntu.com> * 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 <gnu_andrew@member.fsf.org> * 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 <aph@redhat.com> * 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 <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <doko@ubuntu.com> * configure.ac: Search for antlr.jar, if not configured. * configure: Regenerate. 2008-09-24 Matthias Klose <doko@ubuntu.com> * 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 <aph@redhat.com> * java/lang/String.java (toString(char[], int, int)): New method. 2008-09-14 Matthias Klose <doko@ubuntu.com> 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 <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * Makefile.in: Updated location of Configuration.java. * classpath/lib/gnu/java/locale/LocaleData.class: Regenerated. 2008-08-18 Andrew John Hughes <gnu_andrew@member.fsf.org> * 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 <doko@ubuntu.com> 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 <doko@ubuntu.com> * 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 <gnu_andrew@member.fsf.org> * tools/Makefile.am: Always generate parser in the srcdir. 2008-10-21 Matthias Klose <doko@ubuntu.com> * doc/Makefile.am (MAINTAINERCLEANFILES): Add gjdoc.1. * doc/Makefile.in: Regenerate. 2008-10-20 Matthias Klose <doko@ubuntu.com> * configure.ac: Don't check for working java, if not configured with --enable-java-maintainer-mode. * configure: Regenerate. 2008-10-19 Matthias Klose <doko@ubuntu.com> * m4/ac_prog_java.m4: Revert previous change. * m4/ac_prog_javac.m4: Apply it here. * configure: Regenerate. 2008-10-19 Matthias Klose <doko@ubuntu.com> * 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 <doko@ubuntu.com> * m4/ac_prog_antlr.m4: Check for cantlr binary as well. 2008-09-29 Matthias Klose <doko@ubuntu.com> * m4/ac_prog_antlr.m4: Check for antlr binary as well. 2008-09-28 Matthias Klose <doko@ubuntu.com> * PR libgcj/37636. Revert: 2008-02-20 Matthias Klose <doko@ubuntu.com> * 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 <doko@ubuntu.com> * 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 <doko@ubuntu.com> Revert: Daniel Frampton <zyridium at zyridium.net> * 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 <doko@ubuntu.com> * m4/acinclude.m4 (CLASSPATH_JAVAC_MEM_CHECK): Remove unknown args for javac. libjava/classpath/ChangeLog: 2008-10-20 Andrew John Hughes <gnu_andrew@member.fsf.org> * m4/ac_prog_antlr.m4: Remove redundant checks. * tools/Makefile.am: Use gjdoc_gendir when calling antlr. 2008-10-15 Andrew John Hughes <gnu_andrew@member.fsf.org> * configure.ac: Remove superfluous AC_PROG_JAVA call. 2008-10-06 Andrew John Hughes <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <zyridium@zyridium.net> * 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 <ian.rogers@manchester.ac.uk> * 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 <gnu_andrew@member.fsf.org> * 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 <robertschuster@fsfe.org> * 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 <robertschuster@fsfe.org> * java/text/DecimalFormat.java: (scanFix): Use 'i + 1' when looking at following character. (scanNegativePattern): Dito. 2008-09-02 Andrew John Hughes <gnu_andrew@member.fsf.org> * 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 <neugens@aicas.com> * 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 <neugens@aicas.com> * 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_andrew@member.fsf.org> * 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_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * javax/tools/FileObject.java: (openReader(boolean)): Document new parameter. 2008-03-27 Michael Franz <mvfranz@gmail.com> PR classpath/35690: * javax/tools/FileObject.java: (toUri()): Fix case from toURI. (openReader(boolean)): Add missing boolean argument. 2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org> 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_andrew@member.fsf.org> * gnu/javax/management/Server.java: Genericised. 2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org> * gnu/javax/management/Translator.java: Genericised. 2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> * 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 <neugens@aicas.com> * gnu/javax/rmi/CORBA/RmiUtilities.java (readValue): check if sender is null to avoid NPE. 2008-08-22 Mario Torre <neugens@aicas.com> * gnu/CORBA/OrbFunctional.java (set_parameters): Fix NullPointerException checking when param is null. 2008-08-23 Andrew John Hughes <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> 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 <gnu_andrew@member.fsf.org> PR classpath/32028: * m4/acinclude.m4: (CLASSPATH_WITH_GJDOC): Ensure version 0.7.9 is being used. 2008-08-20 Andrew John Hughes <gnu_andrew@member.fsf.org> * tools/Makefile.am: Add taglets subdirectory to list of excluded paths when GJDoc is not compiled. 2008-08-19 David P Grove <groved@us.ibm.com> * scripts/check_jni_methods.sh.in: Fix build issue on AIX by splitting generation of method list. 2008-08-18 Andrew John Hughes <gnu_andrew@member.fsf.org> * 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 <gnu_andrew@member.fsf.org> 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 <gnu_andrew@member.fsf.org> * 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_andrew@member.fsf.org> * 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 <ashah@redhat.com> * javax/activation/MimeTypeParameterList.java: Insert ';' separator before parameter list. 2005-06-29 Xavier Poinsard <xpoinsard@openpricer.com> * javax/activation/ObjectDataContentHandler.java: Fixed typo. 2005-05-28 Chris Burdess <dog@bluezoo.org> * javax/activation/CommandMap.java, * javax/activation/MailcapCommandMap.java: Updated to JAF 1.1. 2004-06-09 Chris Burdess <dog@bluezoo.org> * javax/activation/MailcapCommandMap.java: Fixed bug whereby x-java prefix was not attempted. 2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org> * AUTHORS: Added Laszlo. 2008-04-20 Andrew John Hughes <gnu_andrew@member.fsf.org> PR classpath/30436: * java/util/Scanner.java: Fix package to be java.util and correct indentation. 2007-07-25 Laszlo Andras Hernadi <e0327023@student.tuwien.ac.at> PR classpath/30436: * java/util/Scanner.java: Initial implementation. 2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org> * java/util/regex/Matcher.java: (toMatchResult()): Implemented. 2008-08-13 Joshua Sumali <jsumali@redhat.com> * 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 <robertschuster@fsfe.org> * native/jni/java-net/local.c (local_bind): Removed fprintf call, fixed access outside of array bounds. From-SVN: r141271
1193 lines
41 KiB
Java
1193 lines
41 KiB
Java
/* Logger.java -- a class for logging messages
|
|
Copyright (C) 2002, 2004, 2006, 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.util.logging;
|
|
|
|
import gnu.java.lang.CPStringBuilder;
|
|
|
|
import java.util.List;
|
|
import java.util.MissingResourceException;
|
|
import java.util.ResourceBundle;
|
|
import java.security.AccessController;
|
|
import java.security.PrivilegedAction;
|
|
|
|
/**
|
|
* A Logger is used for logging information about events. Usually, there is a
|
|
* seprate logger for each subsystem or component, although there is a shared
|
|
* instance for components that make only occasional use of the logging
|
|
* framework.
|
|
* <p>
|
|
* It is common to name a logger after the name of a corresponding Java package.
|
|
* Loggers are organized into a hierarchical namespace; for example, the logger
|
|
* <code>"org.gnu.foo"</code> is the <em>parent</em> of logger
|
|
* <code>"org.gnu.foo.bar"</code>.
|
|
* <p>
|
|
* A logger for a named subsystem can be obtained through {@link
|
|
* java.util.logging.Logger#getLogger(java.lang.String)}. However, only code
|
|
* which has been granted the permission to control the logging infrastructure
|
|
* will be allowed to customize that logger. Untrusted code can obtain a
|
|
* private, anonymous logger through {@link #getAnonymousLogger()} if it wants
|
|
* to perform any modifications to the logger.
|
|
* <p>
|
|
* FIXME: Write more documentation.
|
|
*
|
|
* @author Sascha Brawer (brawer@acm.org)
|
|
*/
|
|
public class Logger
|
|
{
|
|
static final Logger root = new Logger("", null);
|
|
|
|
/**
|
|
* A logger provided to applications that make only occasional use of the
|
|
* logging framework, typically early prototypes. Serious products are
|
|
* supposed to create and use their own Loggers, so they can be controlled
|
|
* individually.
|
|
*/
|
|
public static final Logger global;
|
|
|
|
/**
|
|
* Use to lock methods on this class instead of calling synchronize on methods
|
|
* to avoid deadlocks. Yeah, no kidding, we got them :)
|
|
*/
|
|
private static final Object[] lock = new Object[0];
|
|
|
|
static
|
|
{
|
|
// Our class might be initialized from an unprivileged context
|
|
global = (Logger) AccessController.doPrivileged(new PrivilegedAction()
|
|
{
|
|
public Object run()
|
|
{
|
|
return getLogger("global");
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The name of the Logger, or <code>null</code> if the logger is anonymous.
|
|
* <p>
|
|
* A previous version of the GNU Classpath implementation granted untrusted
|
|
* code the permission to control any logger whose name was null. However,
|
|
* test code revealed that the Sun J2SE 1.4 reference implementation enforces
|
|
* the security control for any logger that was not created through
|
|
* getAnonymousLogger, even if it has a null name. Therefore, a separate flag
|
|
* {@link Logger#anonymous} was introduced.
|
|
*/
|
|
private final String name;
|
|
|
|
/**
|
|
* The name of the resource bundle used for localization.
|
|
* <p>
|
|
* This variable cannot be declared as <code>final</code> because its value
|
|
* can change as a result of calling getLogger(String,String).
|
|
*/
|
|
private String resourceBundleName;
|
|
|
|
/**
|
|
* The resource bundle used for localization.
|
|
* <p>
|
|
* This variable cannot be declared as <code>final</code> because its value
|
|
* can change as a result of calling getLogger(String,String).
|
|
*/
|
|
private ResourceBundle resourceBundle;
|
|
|
|
private Filter filter;
|
|
|
|
private final List handlerList = new java.util.ArrayList(4);
|
|
|
|
private Handler[] handlers = new Handler[0];
|
|
|
|
/**
|
|
* Indicates whether or not this logger is anonymous. While a
|
|
* LoggingPermission is required for any modifications to a normal logger,
|
|
* untrusted code can obtain an anonymous logger and modify it according to
|
|
* its needs.
|
|
* <p>
|
|
* A previous version of the GNU Classpath implementation granted access to
|
|
* every logger whose name was null. However, test code revealed that the Sun
|
|
* J2SE 1.4 reference implementation enforces the security control for any
|
|
* logger that was not created through getAnonymousLogger, even if it has a
|
|
* null name.
|
|
*/
|
|
private boolean anonymous;
|
|
|
|
private boolean useParentHandlers;
|
|
|
|
private Level level;
|
|
|
|
private Logger parent;
|
|
|
|
/**
|
|
* Constructs a Logger for a subsystem. Most applications do not need to
|
|
* create new Loggers explicitly; instead, they should call the static factory
|
|
* methods {@link #getLogger(java.lang.String,java.lang.String) getLogger}
|
|
* (with ResourceBundle for localization) or
|
|
* {@link #getLogger(java.lang.String) getLogger} (without ResourceBundle),
|
|
* respectively.
|
|
*
|
|
* @param name the name for the logger, for example "java.awt" or
|
|
* "com.foo.bar". The name should be based on the name of the
|
|
* package issuing log records and consist of dot-separated Java
|
|
* identifiers.
|
|
* @param resourceBundleName the name of a resource bundle for localizing
|
|
* messages, or <code>null</code> to indicate that messages do
|
|
* not need to be localized.
|
|
* @throws java.util.MissingResourceException if
|
|
* <code>resourceBundleName</code> is not <code>null</code>
|
|
* and no such bundle could be located.
|
|
*/
|
|
protected Logger(String name, String resourceBundleName)
|
|
throws MissingResourceException
|
|
{
|
|
this.name = name;
|
|
this.resourceBundleName = resourceBundleName;
|
|
|
|
if (resourceBundleName == null)
|
|
resourceBundle = null;
|
|
else
|
|
resourceBundle = ResourceBundle.getBundle(resourceBundleName);
|
|
|
|
level = null;
|
|
|
|
/*
|
|
* This is null when the root logger is being constructed, and the root
|
|
* logger afterwards.
|
|
*/
|
|
parent = root;
|
|
|
|
useParentHandlers = (parent != null);
|
|
}
|
|
|
|
/**
|
|
* Finds a registered logger for a subsystem, or creates one in case no logger
|
|
* has been registered yet.
|
|
*
|
|
* @param name the name for the logger, for example "java.awt" or
|
|
* "com.foo.bar". The name should be based on the name of the
|
|
* package issuing log records and consist of dot-separated Java
|
|
* identifiers.
|
|
* @throws IllegalArgumentException if a logger for the subsystem identified
|
|
* by <code>name</code> has already been created, but uses a a
|
|
* resource bundle for localizing messages.
|
|
* @throws NullPointerException if <code>name</code> is <code>null</code>.
|
|
* @return a logger for the subsystem specified by <code>name</code> that
|
|
* does not localize messages.
|
|
*/
|
|
public static Logger getLogger(String name)
|
|
{
|
|
return getLogger(name, null);
|
|
}
|
|
|
|
/**
|
|
* Finds a registered logger for a subsystem, or creates one in case no logger
|
|
* has been registered yet.
|
|
* <p>
|
|
* If a logger with the specified name has already been registered, the
|
|
* behavior depends on the resource bundle that is currently associated with
|
|
* the existing logger.
|
|
* <ul>
|
|
* <li>If the existing logger uses the same resource bundle as specified by
|
|
* <code>resourceBundleName</code>, the existing logger is returned.</li>
|
|
* <li>If the existing logger currently does not localize messages, the
|
|
* existing logger is modified to use the bundle specified by
|
|
* <code>resourceBundleName</code>. The existing logger is then returned.
|
|
* Therefore, all subsystems currently using this logger will produce
|
|
* localized messages from now on.</li>
|
|
* <li>If the existing logger already has an associated resource bundle, but
|
|
* a different one than specified by <code>resourceBundleName</code>, an
|
|
* <code>IllegalArgumentException</code> is thrown.</li>
|
|
* </ul>
|
|
*
|
|
* @param name the name for the logger, for example "java.awt" or
|
|
* "org.gnu.foo". The name should be based on the name of the
|
|
* package issuing log records and consist of dot-separated Java
|
|
* identifiers.
|
|
* @param resourceBundleName the name of a resource bundle for localizing
|
|
* messages, or <code>null</code> to indicate that messages do
|
|
* not need to be localized.
|
|
* @return a logger for the subsystem specified by <code>name</code>.
|
|
* @throws java.util.MissingResourceException if
|
|
* <code>resourceBundleName</code> is not <code>null</code>
|
|
* and no such bundle could be located.
|
|
* @throws IllegalArgumentException if a logger for the subsystem identified
|
|
* by <code>name</code> has already been created, but uses a
|
|
* different resource bundle for localizing messages.
|
|
* @throws NullPointerException if <code>name</code> is <code>null</code>.
|
|
*/
|
|
public static Logger getLogger(String name, String resourceBundleName)
|
|
{
|
|
LogManager lm = LogManager.getLogManager();
|
|
Logger result;
|
|
|
|
if (name == null)
|
|
throw new NullPointerException();
|
|
|
|
/*
|
|
* Without synchronized(lm), it could happen that another thread would
|
|
* create a logger between our calls to getLogger and addLogger. While
|
|
* addLogger would indicate this by returning false, we could not be sure
|
|
* that this other logger was still existing when we called getLogger a
|
|
* second time in order to retrieve it -- note that LogManager is only
|
|
* allowed to keep weak references to registered loggers, so Loggers can be
|
|
* garbage collected at any time in general, and between our call to
|
|
* addLogger and our second call go getLogger in particular. Of course, we
|
|
* assume here that LogManager.addLogger etc. are synchronizing on the
|
|
* global LogManager object. There is a comment in the implementation of
|
|
* LogManager.addLogger referring to this comment here, so that any change
|
|
* in the synchronization of LogManager will be reflected here.
|
|
*/
|
|
synchronized (lock)
|
|
{
|
|
synchronized (lm)
|
|
{
|
|
result = lm.getLogger(name);
|
|
if (result == null)
|
|
{
|
|
boolean couldBeAdded;
|
|
|
|
result = new Logger(name, resourceBundleName);
|
|
couldBeAdded = lm.addLogger(result);
|
|
if (! couldBeAdded)
|
|
throw new IllegalStateException("cannot register new logger");
|
|
}
|
|
else
|
|
{
|
|
/*
|
|
* The logger already exists. Make sure it uses the same
|
|
* resource bundle for localizing messages.
|
|
*/
|
|
String existingBundleName = result.getResourceBundleName();
|
|
|
|
/*
|
|
* The Sun J2SE 1.4 reference implementation will return the
|
|
* registered logger object, even if it does not have a resource
|
|
* bundle associated with it. However, it seems to change the
|
|
* resourceBundle of the registered logger to the bundle whose
|
|
* name was passed to getLogger.
|
|
*/
|
|
if ((existingBundleName == null) &&
|
|
(resourceBundleName != null))
|
|
{
|
|
/*
|
|
* If ResourceBundle.getBundle throws an exception, the
|
|
* existing logger will be unchanged. This would be
|
|
* different if the assignment to resourceBundleName came
|
|
* first.
|
|
*/
|
|
result.resourceBundle =
|
|
ResourceBundle.getBundle(resourceBundleName);
|
|
|
|
result.resourceBundleName = resourceBundleName;
|
|
return result;
|
|
}
|
|
|
|
if ((existingBundleName != resourceBundleName)
|
|
&& ((existingBundleName == null)
|
|
|| !existingBundleName.equals(resourceBundleName)))
|
|
{
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a new, unnamed logger. Unnamed loggers are not registered in the
|
|
* namespace of the LogManager, and no special security permission is required
|
|
* for changing their state. Therefore, untrusted applets are able to modify
|
|
* their private logger instance obtained through this method.
|
|
* <p>
|
|
* The parent of the newly created logger will the the root logger, from which
|
|
* the level threshold and the handlers are inherited.
|
|
*/
|
|
public static Logger getAnonymousLogger()
|
|
{
|
|
return getAnonymousLogger(null);
|
|
}
|
|
|
|
/**
|
|
* Creates a new, unnamed logger. Unnamed loggers are not registered in the
|
|
* namespace of the LogManager, and no special security permission is required
|
|
* for changing their state. Therefore, untrusted applets are able to modify
|
|
* their private logger instance obtained through this method.
|
|
* <p>
|
|
* The parent of the newly created logger will the the root logger, from which
|
|
* the level threshold and the handlers are inherited.
|
|
*
|
|
* @param resourceBundleName the name of a resource bundle for localizing
|
|
* messages, or <code>null</code> to indicate that messages do
|
|
* not need to be localized.
|
|
* @throws java.util.MissingResourceException if
|
|
* <code>resourceBundleName</code> is not <code>null</code>
|
|
* and no such bundle could be located.
|
|
*/
|
|
public static Logger getAnonymousLogger(String resourceBundleName)
|
|
throws MissingResourceException
|
|
{
|
|
Logger result;
|
|
|
|
result = new Logger(null, resourceBundleName);
|
|
result.anonymous = true;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Returns the name of the resource bundle that is being used for localizing
|
|
* messages.
|
|
*
|
|
* @return the name of the resource bundle used for localizing messages, or
|
|
* <code>null</code> if the parent's resource bundle is used for
|
|
* this purpose.
|
|
*/
|
|
public String getResourceBundleName()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
return resourceBundleName;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the resource bundle that is being used for localizing messages.
|
|
*
|
|
* @return the resource bundle used for localizing messages, or
|
|
* <code>null</code> if the parent's resource bundle is used for
|
|
* this purpose.
|
|
*/
|
|
public ResourceBundle getResourceBundle()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
return resourceBundle;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the severity level threshold for this <code>Handler</code>. All
|
|
* log records with a lower severity level will be discarded; a log record of
|
|
* the same or a higher level will be published unless an installed
|
|
* <code>Filter</code> decides to discard it.
|
|
*
|
|
* @return the severity level below which all log messages will be discarded,
|
|
* or <code>null</code> if the logger inherits the threshold from
|
|
* its parent.
|
|
*/
|
|
public Level getLevel()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
return level;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns whether or not a message of the specified level would be logged by
|
|
* this logger.
|
|
*
|
|
* @throws NullPointerException if <code>level</code> is <code>null</code>.
|
|
*/
|
|
public boolean isLoggable(Level level)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (this.level != null)
|
|
return this.level.intValue() <= level.intValue();
|
|
|
|
if (parent != null)
|
|
return parent.isLoggable(level);
|
|
else
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets the severity level threshold for this <code>Handler</code>. All log
|
|
* records with a lower severity level will be discarded immediately. A log
|
|
* record of the same or a higher level will be published unless an installed
|
|
* <code>Filter</code> decides to discard it.
|
|
*
|
|
* @param level the severity level below which all log messages will be
|
|
* discarded, or <code>null</code> to indicate that the logger
|
|
* should inherit the threshold from its parent.
|
|
* @throws SecurityException if this logger is not anonymous, a security
|
|
* manager exists, and the caller is not granted the permission to
|
|
* control the logging infrastructure by having
|
|
* LoggingPermission("control"). Untrusted code can obtain an
|
|
* anonymous logger through the static factory method
|
|
* {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
|
|
*/
|
|
public void setLevel(Level level)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
/*
|
|
* An application is allowed to control an anonymous logger without
|
|
* having the permission to control the logging infrastructure.
|
|
*/
|
|
if (! anonymous)
|
|
LogManager.getLogManager().checkAccess();
|
|
|
|
this.level = level;
|
|
}
|
|
}
|
|
|
|
public Filter getFilter()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
return filter;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @throws SecurityException if this logger is not anonymous, a security
|
|
* manager exists, and the caller is not granted the permission to
|
|
* control the logging infrastructure by having
|
|
* LoggingPermission("control"). Untrusted code can obtain an
|
|
* anonymous logger through the static factory method
|
|
* {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
|
|
*/
|
|
public void setFilter(Filter filter) throws SecurityException
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
/*
|
|
* An application is allowed to control an anonymous logger without
|
|
* having the permission to control the logging infrastructure.
|
|
*/
|
|
if (! anonymous)
|
|
LogManager.getLogManager().checkAccess();
|
|
|
|
this.filter = filter;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the name of this logger.
|
|
*
|
|
* @return the name of this logger, or <code>null</code> if the logger is
|
|
* anonymous.
|
|
*/
|
|
public String getName()
|
|
{
|
|
/*
|
|
* Note that the name of a logger cannot be changed during its lifetime, so
|
|
* no synchronization is needed.
|
|
*/
|
|
return name;
|
|
}
|
|
|
|
/**
|
|
* Passes a record to registered handlers, provided the record is considered
|
|
* as loggable both by {@link #isLoggable(Level)} and a possibly installed
|
|
* custom {@link #setFilter(Filter) filter}.
|
|
* <p>
|
|
* If the logger has been configured to use parent handlers, the record will
|
|
* be forwarded to the parent of this logger in addition to being processed by
|
|
* the handlers registered with this logger.
|
|
* <p>
|
|
* The other logging methods in this class are convenience methods that merely
|
|
* create a new LogRecord and pass it to this method. Therefore, subclasses
|
|
* usually just need to override this single method for customizing the
|
|
* logging behavior.
|
|
*
|
|
* @param record the log record to be inspected and possibly forwarded.
|
|
*/
|
|
public void log(LogRecord record)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (!isLoggable(record.getLevel()))
|
|
return;
|
|
|
|
if ((filter != null) && ! filter.isLoggable(record))
|
|
return;
|
|
|
|
/*
|
|
* If no logger name has been set for the log record, use the name of
|
|
* this logger.
|
|
*/
|
|
if (record.getLoggerName() == null)
|
|
record.setLoggerName(name);
|
|
|
|
/*
|
|
* Avoid that some other thread is changing the logger hierarchy while
|
|
* we are traversing it.
|
|
*/
|
|
synchronized (LogManager.getLogManager())
|
|
{
|
|
Logger curLogger = this;
|
|
|
|
do
|
|
{
|
|
/*
|
|
* The Sun J2SE 1.4 reference implementation seems to call the
|
|
* filter only for the logger whose log method is called, never
|
|
* for any of its parents. Also, parent loggers publish log
|
|
* record whatever their level might be. This is pretty weird,
|
|
* but GNU Classpath tries to be as compatible as possible to
|
|
* the reference implementation.
|
|
*/
|
|
for (int i = 0; i < curLogger.handlers.length; i++)
|
|
curLogger.handlers[i].publish(record);
|
|
|
|
if (curLogger.getUseParentHandlers() == false)
|
|
break;
|
|
|
|
curLogger = curLogger.getParent();
|
|
}
|
|
while (parent != null);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void log(Level level, String message)
|
|
{
|
|
if (isLoggable(level))
|
|
log(level, message, (Object[]) null);
|
|
}
|
|
|
|
public void log(Level level, String message, Object param)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(level))
|
|
{
|
|
StackTraceElement caller = getCallerStackFrame();
|
|
logp(level, caller != null ? caller.getClassName() : "<unknown>",
|
|
caller != null ? caller.getMethodName() : "<unknown>",
|
|
message, param);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void log(Level level, String message, Object[] params)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(level))
|
|
{
|
|
StackTraceElement caller = getCallerStackFrame();
|
|
logp(level, caller != null ? caller.getClassName() : "<unknown>",
|
|
caller != null ? caller.getMethodName() : "<unknown>",
|
|
message, params);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public void log(Level level, String message, Throwable thrown)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(level))
|
|
{
|
|
StackTraceElement caller = getCallerStackFrame();
|
|
logp(level, caller != null ? caller.getClassName() : "<unknown>",
|
|
caller != null ? caller.getMethodName() : "<unknown>",
|
|
message, thrown);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void logp(Level level, String sourceClass, String sourceMethod,
|
|
String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
logp(level, sourceClass, sourceMethod, message, (Object[]) null);
|
|
}
|
|
}
|
|
|
|
public void logp(Level level, String sourceClass, String sourceMethod,
|
|
String message, Object param)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
logp(level, sourceClass, sourceMethod, message, new Object[] { param });
|
|
}
|
|
|
|
}
|
|
|
|
private ResourceBundle findResourceBundle()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (resourceBundle != null)
|
|
return resourceBundle;
|
|
|
|
if (parent != null)
|
|
return parent.findResourceBundle();
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private void logImpl(Level level, String sourceClass, String sourceMethod,
|
|
String message, Object[] params)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
LogRecord rec = new LogRecord(level, message);
|
|
|
|
rec.setResourceBundle(findResourceBundle());
|
|
rec.setSourceClassName(sourceClass);
|
|
rec.setSourceMethodName(sourceMethod);
|
|
rec.setParameters(params);
|
|
|
|
log(rec);
|
|
}
|
|
}
|
|
|
|
public void logp(Level level, String sourceClass, String sourceMethod,
|
|
String message, Object[] params)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
logImpl(level, sourceClass, sourceMethod, message, params);
|
|
}
|
|
}
|
|
|
|
public void logp(Level level, String sourceClass, String sourceMethod,
|
|
String message, Throwable thrown)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
LogRecord rec = new LogRecord(level, message);
|
|
|
|
rec.setResourceBundle(resourceBundle);
|
|
rec.setSourceClassName(sourceClass);
|
|
rec.setSourceMethodName(sourceMethod);
|
|
rec.setThrown(thrown);
|
|
|
|
log(rec);
|
|
}
|
|
}
|
|
|
|
public void logrb(Level level, String sourceClass, String sourceMethod,
|
|
String bundleName, String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
logrb(level, sourceClass, sourceMethod, bundleName, message,
|
|
(Object[]) null);
|
|
}
|
|
}
|
|
|
|
public void logrb(Level level, String sourceClass, String sourceMethod,
|
|
String bundleName, String message, Object param)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
logrb(level, sourceClass, sourceMethod, bundleName, message,
|
|
new Object[] { param });
|
|
}
|
|
}
|
|
|
|
public void logrb(Level level, String sourceClass, String sourceMethod,
|
|
String bundleName, String message, Object[] params)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
LogRecord rec = new LogRecord(level, message);
|
|
|
|
rec.setResourceBundleName(bundleName);
|
|
rec.setSourceClassName(sourceClass);
|
|
rec.setSourceMethodName(sourceMethod);
|
|
rec.setParameters(params);
|
|
|
|
log(rec);
|
|
}
|
|
}
|
|
|
|
public void logrb(Level level, String sourceClass, String sourceMethod,
|
|
String bundleName, String message, Throwable thrown)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
LogRecord rec = new LogRecord(level, message);
|
|
|
|
rec.setResourceBundleName(bundleName);
|
|
rec.setSourceClassName(sourceClass);
|
|
rec.setSourceMethodName(sourceMethod);
|
|
rec.setThrown(thrown);
|
|
|
|
log(rec);
|
|
}
|
|
}
|
|
|
|
public void entering(String sourceClass, String sourceMethod)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");
|
|
}
|
|
}
|
|
|
|
public void entering(String sourceClass, String sourceMethod, Object param)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", param);
|
|
}
|
|
}
|
|
|
|
public void entering(String sourceClass, String sourceMethod, Object[] params)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
{
|
|
CPStringBuilder buf = new CPStringBuilder(80);
|
|
buf.append("ENTRY");
|
|
for (int i = 0; i < params.length; i++)
|
|
{
|
|
buf.append(" {");
|
|
buf.append(i);
|
|
buf.append('}');
|
|
}
|
|
|
|
logp(Level.FINER, sourceClass, sourceMethod, buf.toString(), params);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void exiting(String sourceClass, String sourceMethod)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
logp(Level.FINER, sourceClass, sourceMethod, "RETURN");
|
|
}
|
|
}
|
|
|
|
public void exiting(String sourceClass, String sourceMethod, Object result)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);
|
|
}
|
|
}
|
|
|
|
public void throwing(String sourceClass, String sourceMethod, Throwable thrown)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
logp(Level.FINER, sourceClass, sourceMethod, "THROW", thrown);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level SEVERE, indicating a serious failure
|
|
* that prevents normal program execution. Messages at this level should be
|
|
* understandable to an inexperienced, non-technical end user. Ideally, they
|
|
* explain in simple words what actions the user can take in order to resolve
|
|
* the problem.
|
|
*
|
|
* @see Level#SEVERE
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void severe(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.SEVERE))
|
|
log(Level.SEVERE, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level WARNING, indicating a potential problem
|
|
* that does not prevent normal program execution. Messages at this level
|
|
* should be understandable to an inexperienced, non-technical end user.
|
|
* Ideally, they explain in simple words what actions the user can take in
|
|
* order to resolve the problem.
|
|
*
|
|
* @see Level#WARNING
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void warning(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.WARNING))
|
|
log(Level.WARNING, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level INFO. {@link Level#INFO} is intended for
|
|
* purely informational messages that do not indicate error or warning
|
|
* situations. In the default logging configuration, INFO messages will be
|
|
* written to the system console. For this reason, the INFO level should be
|
|
* used only for messages that are important to end users and system
|
|
* administrators. Messages at this level should be understandable to an
|
|
* inexperienced, non-technical user.
|
|
*
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void info(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.INFO))
|
|
log(Level.INFO, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level CONFIG. {@link Level#CONFIG} is intended
|
|
* for static configuration messages, for example about the windowing
|
|
* environment, the operating system version, etc.
|
|
*
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void config(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.CONFIG))
|
|
log(Level.CONFIG, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level FINE. {@link Level#FINE} is intended for
|
|
* messages that are relevant for developers using the component generating
|
|
* log messages. Examples include minor, recoverable failures, or possible
|
|
* inefficiencies.
|
|
*
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void fine(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINE))
|
|
log(Level.FINE, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level FINER. {@link Level#FINER} is intended
|
|
* for rather detailed tracing, for example entering a method, returning from
|
|
* a method, or throwing an exception.
|
|
*
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void finer(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINER))
|
|
log(Level.FINER, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a message with severity level FINEST. {@link Level#FINEST} is intended
|
|
* for highly detailed tracing, for example reaching a certain point inside
|
|
* the body of a method.
|
|
*
|
|
* @param message the message text, also used as look-up key if the logger is
|
|
* localizing messages with a resource bundle. While it is possible
|
|
* to pass <code>null</code>, this is not recommended, since a
|
|
* logging message without text is unlikely to be helpful.
|
|
*/
|
|
public void finest(String message)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (isLoggable(Level.FINEST))
|
|
log(Level.FINEST, message);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Adds a handler to the set of handlers that get notified when a log record
|
|
* is to be published.
|
|
*
|
|
* @param handler the handler to be added.
|
|
* @throws NullPointerException if <code>handler</code> is <code>null</code>.
|
|
* @throws SecurityException if this logger is not anonymous, a security
|
|
* manager exists, and the caller is not granted the permission to
|
|
* control the logging infrastructure by having
|
|
* LoggingPermission("control"). Untrusted code can obtain an
|
|
* anonymous logger through the static factory method
|
|
* {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
|
|
*/
|
|
public void addHandler(Handler handler) throws SecurityException
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (handler == null)
|
|
throw new NullPointerException();
|
|
|
|
/*
|
|
* An application is allowed to control an anonymous logger without
|
|
* having the permission to control the logging infrastructure.
|
|
*/
|
|
if (! anonymous)
|
|
LogManager.getLogManager().checkAccess();
|
|
|
|
if (! handlerList.contains(handler))
|
|
{
|
|
handlerList.add(handler);
|
|
handlers = getHandlers();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Removes a handler from the set of handlers that get notified when a log
|
|
* record is to be published.
|
|
*
|
|
* @param handler the handler to be removed.
|
|
* @throws SecurityException if this logger is not anonymous, a security
|
|
* manager exists, and the caller is not granted the permission to
|
|
* control the logging infrastructure by having
|
|
* LoggingPermission("control"). Untrusted code can obtain an
|
|
* anonymous logger through the static factory method {@link
|
|
* #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
|
|
* @throws NullPointerException if <code>handler</code> is <code>null</code>.
|
|
*/
|
|
public void removeHandler(Handler handler) throws SecurityException
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
/*
|
|
* An application is allowed to control an anonymous logger without
|
|
* having the permission to control the logging infrastructure.
|
|
*/
|
|
if (! anonymous)
|
|
LogManager.getLogManager().checkAccess();
|
|
|
|
if (handler == null)
|
|
throw new NullPointerException();
|
|
|
|
handlerList.remove(handler);
|
|
handlers = getHandlers();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the handlers currently registered for this Logger. When a log
|
|
* record has been deemed as being loggable, it will be passed to all
|
|
* registered handlers for publication. In addition, if the logger uses parent
|
|
* handlers (see {@link #getUseParentHandlers() getUseParentHandlers} and
|
|
* {@link #setUseParentHandlers(boolean) setUseParentHandlers}, the log
|
|
* record will be passed to the parent's handlers.
|
|
*/
|
|
public Handler[] getHandlers()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
/*
|
|
* We cannot return our internal handlers array because we do not have
|
|
* any guarantee that the caller would not change the array entries.
|
|
*/
|
|
return (Handler[]) handlerList.toArray(new Handler[handlerList.size()]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns whether or not this Logger forwards log records to handlers
|
|
* registered for its parent loggers.
|
|
*
|
|
* @return <code>false</code> if this Logger sends log records merely to
|
|
* Handlers registered with itself; <code>true</code> if this Logger
|
|
* sends log records not only to Handlers registered with itself, but
|
|
* also to those Handlers registered with parent loggers.
|
|
*/
|
|
public boolean getUseParentHandlers()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
return useParentHandlers;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets whether or not this Logger forwards log records to handlers registered
|
|
* for its parent loggers.
|
|
*
|
|
* @param useParentHandlers <code>false</code> to let this Logger send log
|
|
* records merely to Handlers registered with itself;
|
|
* <code>true</code> to let this Logger send log records not only
|
|
* to Handlers registered with itself, but also to those Handlers
|
|
* registered with parent loggers.
|
|
* @throws SecurityException if this logger is not anonymous, a security
|
|
* manager exists, and the caller is not granted the permission to
|
|
* control the logging infrastructure by having
|
|
* LoggingPermission("control"). Untrusted code can obtain an
|
|
* anonymous logger through the static factory method
|
|
* {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
|
|
*/
|
|
public void setUseParentHandlers(boolean useParentHandlers)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
/*
|
|
* An application is allowed to control an anonymous logger without
|
|
* having the permission to control the logging infrastructure.
|
|
*/
|
|
if (! anonymous)
|
|
LogManager.getLogManager().checkAccess();
|
|
|
|
this.useParentHandlers = useParentHandlers;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the parent of this logger. By default, the parent is assigned by
|
|
* the LogManager by inspecting the logger's name.
|
|
*
|
|
* @return the parent of this logger (as detemined by the LogManager by
|
|
* inspecting logger names), the root logger if no other logger has a
|
|
* name which is a prefix of this logger's name, or <code>null</code>
|
|
* for the root logger.
|
|
*/
|
|
public Logger getParent()
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
return parent;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets the parent of this logger. Usually, applications do not call this
|
|
* method directly. Instead, the LogManager will ensure that the tree of
|
|
* loggers reflects the hierarchical logger namespace. Basically, this method
|
|
* should not be public at all, but the GNU implementation follows the API
|
|
* specification.
|
|
*
|
|
* @throws NullPointerException if <code>parent</code> is <code>null</code>.
|
|
* @throws SecurityException if this logger is not anonymous, a security
|
|
* manager exists, and the caller is not granted the permission to
|
|
* control the logging infrastructure by having
|
|
* LoggingPermission("control"). Untrusted code can obtain an
|
|
* anonymous logger through the static factory method
|
|
* {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
|
|
*/
|
|
public void setParent(Logger parent)
|
|
{
|
|
synchronized (lock)
|
|
{
|
|
if (parent == null)
|
|
throw new NullPointerException();
|
|
|
|
if (this == root)
|
|
throw new IllegalArgumentException(
|
|
"the root logger can only have a null parent");
|
|
|
|
/*
|
|
* An application is allowed to control an anonymous logger without
|
|
* having the permission to control the logging infrastructure.
|
|
*/
|
|
if (! anonymous)
|
|
LogManager.getLogManager().checkAccess();
|
|
|
|
this.parent = parent;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets the StackTraceElement of the first class that is not this class. That
|
|
* should be the initial caller of a logging method.
|
|
*
|
|
* @return caller of the initial logging method or null if unknown.
|
|
*/
|
|
private StackTraceElement getCallerStackFrame()
|
|
{
|
|
Throwable t = new Throwable();
|
|
StackTraceElement[] stackTrace = t.getStackTrace();
|
|
int index = 0;
|
|
|
|
// skip to stackentries until this class
|
|
while (index < stackTrace.length
|
|
&& ! stackTrace[index].getClassName().equals(getClass().getName()))
|
|
index++;
|
|
|
|
// skip the stackentries of this class
|
|
while (index < stackTrace.length
|
|
&& stackTrace[index].getClassName().equals(getClass().getName()))
|
|
index++;
|
|
|
|
return index < stackTrace.length ? stackTrace[index] : null;
|
|
}
|
|
|
|
/**
|
|
* Reset and close handlers attached to this logger. This function is package
|
|
* private because it must only be available to the LogManager.
|
|
*/
|
|
void resetLogger()
|
|
{
|
|
for (int i = 0; i < handlers.length; i++)
|
|
{
|
|
handlers[i].close();
|
|
handlerList.remove(handlers[i]);
|
|
}
|
|
handlers = getHandlers();
|
|
}
|
|
}
|