System.java (setProperties): Only call init_properties() if properties is null.

2000-11-24  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/lang/System.java (setProperties): Only call init_properties()
	if properties is null.
	(getProperties): Ditto.
	(getProperty): Ditto.
	(setProperty): Call init_properties if properties are null.
	(prop_init): Remove field.
	* java/lang/natSystem.cc (init_properties): Synchronize the entire
	method. Check for null properties after synchronizing instead of
	prop_init flag. Set the properties field last for thread safety.

	* java/io/ObjectInputStream.java (ObjectInputStream): If DEBUG is set,
	test for gcj.dumpobjects property and enable object stream dumping
	if it is set.
	(dumpElement): No longer native.
	(dumpElementln): Ditto.
	(setDump): Do not define.
	* java/io/natObjectInputStream.cc (dumpElement): Removed.
	(dumpElementln): Removed.
	(setDump): Removed.

2000-11-24  Bryce McKinlay  <bryce@albatross.co.nz>

	* configure: Rebuilt.
	* Makefile.in: Rebuilt.
	* Makefile.am (built_java_source_files): Add Configuration.java.
	* configure.in: Add Configuration.java to CONFIG_FILES. Set
	LIBGCJDEBUG substitution if --enable-libgcj-debug is specified.
	Create `gnu' directory in the build tree.
	* gnu/classpath/Configuration.java.in: New file.

From-SVN: r37749
This commit is contained in:
Bryce McKinlay 2000-11-26 01:48:04 +00:00
parent 3645c4dc1c
commit 213858c013
9 changed files with 370 additions and 373 deletions

View File

@ -758,7 +758,8 @@ java/beans/Visibility.java
## Java files which are created by configure and thus are in the build
## directory.
built_java_source_files = java/lang/ConcreteProcess.java
built_java_source_files = java/lang/ConcreteProcess.java \
gnu/classpath/Configuration.java
## Java files in the core packages java.lang, java.io, and java.util.
## These are built before the other source files, in order to reduce

View File

@ -87,6 +87,7 @@ GCTESTSPEC = @GCTESTSPEC@
INCLTDL = @INCLTDL@
JC1GCSPEC = @JC1GCSPEC@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
LIBGCJDEBUG = @LIBGCJDEBUG@
LIBGCJTESTSPEC = @LIBGCJTESTSPEC@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
@ -510,7 +511,9 @@ java/beans/VetoableChangeSupport.java \
java/beans/Visibility.java
built_java_source_files = java/lang/ConcreteProcess.java
built_java_source_files = java/lang/ConcreteProcess.java \
gnu/classpath/Configuration.java
core_java_source_files = \
java/lang/AbstractMethodError.java \
@ -1181,8 +1184,9 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/awt/xlib/XGraphics.P \
.deps/gnu/awt/xlib/XGraphicsConfiguration.P \
.deps/gnu/awt/xlib/XPanelPeer.P .deps/gnu/awt/xlib/XToolkit.P \
.deps/gnu/gcj/RawData.P .deps/gnu/gcj/awt/BitMaskExtent.P \
.deps/gnu/gcj/awt/Buffers.P .deps/gnu/gcj/awt/ComponentDataBlitOp.P \
.deps/gnu/classpath/Configuration.P .deps/gnu/gcj/RawData.P \
.deps/gnu/gcj/awt/BitMaskExtent.P .deps/gnu/gcj/awt/Buffers.P \
.deps/gnu/gcj/awt/ComponentDataBlitOp.P \
.deps/gnu/gcj/awt/GLightweightPeer.P \
.deps/gnu/gcj/convert/BytesToUnicode.P .deps/gnu/gcj/convert/Convert.P \
.deps/gnu/gcj/convert/IOConverter.P \

582
libjava/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -65,10 +65,13 @@ if test "$enable_getenv_properties" = no; then
fi
dnl See if the user has requested runtime debugging.
LIBGCJDEBUG="false"
AC_SUBST(LIBGCJDEBUG)
AC_ARG_ENABLE(libgcj-debug,
[ --enable-libgcj-debug enable runtime debugging code],
if test "$enable_libgcj_debug" = yes; then
AC_DEFINE(DEBUG)
AC_DEFINE(DEBUG)
LIBGCJDEBUG="true"
fi)
dnl See if the user has the interpreter included.
@ -173,6 +176,7 @@ dnl Create the subdirectory for natFileDescriptor.cc, or the attempt
dnl to create the link will fail.
test -d java || mkdir java
test -d java/io || mkdir java/io
test -d gnu || mkdir gnu
AC_LINK_FILES(java/io/$FILE_DESCRIPTOR, java/io/natFileDescriptor.cc)
dnl Likewise for ConcreteProcess.java and natConcreteProcess.cc.
@ -770,7 +774,7 @@ here=`pwd`
AC_SUBST(here)
AC_OUTPUT(Makefile libgcj.spec libgcj-test.spec gcj/Makefile include/Makefile testsuite/Makefile,
AC_OUTPUT(Makefile libgcj.spec libgcj-test.spec gnu/classpath/Configuration.java gcj/Makefile include/Makefile testsuite/Makefile,
[if test -n "$CONFIG_FILES"; then
ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
fi

View File

@ -0,0 +1,14 @@
// This file defines compile-time constants that can be accessed by java code.
// It is pre-processed by configure.
package gnu.classpath;
public interface Configuration
{
// The value of DEBUG is substituted according to whether the
// "--enable-libgcj-debug" argument was passed to configure. Code
// which is made conditional based on the value of this flag will
// be removed by the optimizer in a non-debug build.
boolean DEBUG = @LIBGCJDEBUG@;
}

View File

@ -27,6 +27,8 @@ executable file might be covered by the GNU General Public License. */
package java.io;
import gnu.classpath.Configuration;
import java.lang.reflect.Array;
import java.lang.reflect.Modifier;
import java.util.Arrays;
@ -61,6 +63,21 @@ public class ObjectInputStream extends InputStream
public ObjectInputStream (InputStream in)
throws IOException, StreamCorruptedException
{
if (Configuration.DEBUG)
{
String val = System.getProperty("gcj.dumpobjects");
if (dump == false && val != null && !val.equals(""))
{
dump = true;
System.out.println ("Serialization debugging enabled");
}
else if (dump == true && (val == null || val.equals("")))
{
dump = false;
System.out.println ("Serialization debugging disabled");
}
}
this.resolveEnabled = false;
this.isDeserializing = false;
this.blockDataPosition = 0;
@ -1510,24 +1527,19 @@ public class ObjectInputStream extends InputStream
private boolean fieldsAlreadyRead;
private Vector validators;
private static boolean dump;
public native static void setDump (boolean dump);
private native void dumpElement (String msg);
private native void dumpElementln (String msg);
private static boolean dump;
/* FIXME: These 2 methods cause a build error on i686-pc-linux-gnu.
private void DEBUG (String msg)
private void dumpElement (String msg)
{
System.out.print (msg);
if (Configuration.DEBUG && dump)
System.out.print(msg);
}
private void DEBUGln (String msg)
private void dumpElementln (String msg)
{
System.out.println (msg);
if (Configuration.DEBUG && dump)
System.out.println(msg);
}
* end FIXME */
}

View File

@ -78,40 +78,3 @@ java::io::ObjectInputStream::getMethod (jclass klass, jstring name,
{
return klass->getPrivateMethod (name, arg_types);
}
#ifdef DEBUG
void
java::io::ObjectInputStream::setDump (jboolean dump)
{
java::io::ObjectInputStream::dump = dump;
}
void
java::io::ObjectInputStream::dumpElement (jstring msg)
{
if (dump)
java::lang::System::out->print (msg);
}
void
java::io::ObjectInputStream::dumpElementln (jstring msg)
{
if (dump)
java::lang::System::out->println (msg);
}
#else
void
java::io::ObjectInputStream::setDump (jboolean dump)
{
}
void
java::io::ObjectInputStream::dumpElement (jstring msg)
{
}
void
java::io::ObjectInputStream::dumpElementln (jstring msg)
{
}
#endif

View File

@ -63,7 +63,8 @@ public final class System
{
if (secman != null)
secman.checkPropertiesAccess();
init_properties ();
if (properties == null)
init_properties ();
return properties;
}
@ -71,7 +72,8 @@ public final class System
{
if (secman != null)
secman.checkPropertyAccess(property);
init_properties ();
if (properties == null)
init_properties ();
return properties.getProperty(property);
}
@ -79,7 +81,8 @@ public final class System
{
if (secman != null)
secman.checkPropertyAccess(property, defval);
init_properties ();
if (properties == null)
init_properties ();
return properties.getProperty(property, defval);
}
@ -128,15 +131,18 @@ public final class System
{
if (secman != null)
secman.checkPropertiesAccess();
// We might not have initialized yet.
prop_init = true;
properties = props;
synchronized (System.class)
{
properties = props;
}
}
public static String setProperty (String key, String value)
{
if (secman != null)
secman.checkPermission (new PropertyPermission (key, "write"));
if (properties == null)
init_properties ();
return (String) properties.setProperty (key, value);
}
@ -165,7 +171,4 @@ public final class System
// Private data.
private static SecurityManager secman = null;
private static Properties properties = null;
// This boolean is only required for 1.1 and earlier. After 1.1, a
// null properties should always be re-initialized.
private static boolean prop_init = false;
}

View File

@ -217,18 +217,16 @@ getpwuid_adaptor(T_passwd * (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r,
void
java::lang::System::init_properties (void)
{
{
// We only need to synchronize around this gatekeeper.
JvSynchronize sync (&java::lang::System::class$);
if (prop_init)
return;
prop_init = true;
}
JvSynchronize sync (&java::lang::System::class$);
if (properties != NULL)
return;
properties = new java::util::Properties ();
java::util::Properties* newprops = new java::util::Properties ();
// A convenience define.
#define SET(Prop,Val) \
properties->put(JvNewStringLatin1 (Prop), JvNewStringLatin1 (Val))
newprops->put(JvNewStringLatin1 (Prop), JvNewStringLatin1 (Val))
// A mixture of the Java Product Versioning Specification
// (introduced in 1.2), and earlier versioning properties.
@ -351,7 +349,7 @@ java::lang::System::init_properties (void)
;
jstring name = JvNewStringLatin1 (p, s - p);
jstring val = JvNewStringLatin1 (*s == '=' ? s + 1 : s);
properties->put (name, val);
newprops->put (name, val);
}
// Set the system properties from the user's environment.
@ -368,13 +366,13 @@ java::lang::System::init_properties (void)
}
if (_Jv_Jar_Class_Path)
properties->put(JvNewStringLatin1 ("java.class.path"),
JvNewStringLatin1 (_Jv_Jar_Class_Path));
newprops->put(JvNewStringLatin1 ("java.class.path"),
JvNewStringLatin1 (_Jv_Jar_Class_Path));
else
{
// FIXME: find libgcj.zip and append its path?
char *classpath = ::getenv("CLASSPATH");
jstring cp = properties->getProperty (JvNewStringLatin1("java.class.path"));
jstring cp = newprops->getProperty (JvNewStringLatin1("java.class.path"));
java::lang::StringBuffer *sb = new java::lang::StringBuffer ();
if (classpath)
@ -391,7 +389,11 @@ java::lang::System::init_properties (void)
else
sb->append ((jchar) '.');
properties->put(JvNewStringLatin1 ("java.class.path"),
newprops->put(JvNewStringLatin1 ("java.class.path"),
sb->toString ());
}
// Finally, set the field. This ensures that concurrent getProperty()
// calls will return initialized values without requiring them to be
// synchronized in the common case.
properties = newprops;
}