This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, This merges the Throwable initialization and security check fixups from GNU Classpath. 2004-09-26 Mark Wielaard <mark@klomp.org> * java/lang/Throwable.java (StaticData.nl): Make package private. * java/lang/System.java (properties): Make package private. * java/lang/Throwable.java (StaticData.nl): Initialize through directly accessing System.properties.getProperty(). * java/lang/Throwable.java (nl): Remove static field. (StaticData): New private static inner class. (stackTraceStringBuffer): Use StaticData.nl. The new private static inner class makes sure that the nl field is only initialized when a stack trace is actually printed. And by using the System.properties field directly we avoid a security check. Committed to mainline. Cheers, Mark
Index: java/lang/System.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/lang/System.java,v retrieving revision 1.19 diff -u -r1.19 System.java --- java/lang/System.java 9 Sep 2004 10:19:29 -0000 1.19 +++ java/lang/System.java 26 Sep 2004 16:30:09 -0000 @@ -133,7 +133,7 @@ */ // Note that we use clone here and not new. Some programs assume // that the system properties do not have a parent. - private static Properties properties + static Properties properties = (Properties) Runtime.defaultProperties.clone(); /** Index: java/lang/Throwable.java =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/lang/Throwable.java,v retrieving revision 1.16 diff -u -r1.16 Throwable.java --- java/lang/Throwable.java 3 May 2004 19:52:29 -0000 1.16 +++ java/lang/Throwable.java 26 Sep 2004 16:30:09 -0000 @@ -1,5 +1,5 @@ /* java.lang.Throwable -- Root class for all Exceptions and Errors - Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -396,7 +396,21 @@ pw.print(stackTraceString()); } - private static final String nl = System.getProperty("line.separator"); + /* + * We use inner class to avoid a static initializer in this basic class. + */ + private static class StaticData + { + + final static String nl; + + static + { + // Access package private properties field to prevent Security check. + nl = System.properties.getProperty("line.separator"); + } + } + // Create whole stack trace in a stringbuffer so we don't have to print // it line by line. This prevents printing multiple stack traces from // different threads to get mixed up when written to the same PrintWriter. @@ -449,6 +463,7 @@ private static void stackTraceStringBuffer(StringBuffer sb, String name, StackTraceElement[] stack, int equal) { + String nl = StaticData.nl; // (finish) first line sb.append(name); sb.append(nl);
Attachment:
signature.asc
Description: This is a digitally signed message part
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |