|
From: <fd...@us...> - 2010-05-16 16:49:09
|
Revision: 5750
http://jnode.svn.sourceforge.net/jnode/?rev=5750&view=rev
Author: fduminy
Date: 2010-05-16 16:48:59 +0000 (Sun, 16 May 2010)
Log Message:
-----------
removed package/plugin dependency cycle org.jnode.vm <-> org.jnode.system by refactoring BootLog :
- become an interface in its own plugin and doesn't depend on the (org.jnode.vm.)Unsafe class
Signed-off-by: Fabien DUMINY <fab...@we...>
Modified Paths:
--------------
trunk/all/conf/system-plugin-list.xml
trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java
trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java
trunk/core/src/core/org/jnode/boot/InitJarProcessor.java
trunk/core/src/core/org/jnode/boot/Main.java
trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java
trunk/core/src/core/org/jnode/plugin/Plugin.java
trunk/core/src/core/org/jnode/plugin/PluginManager.java
trunk/core/src/core/org/jnode/plugin/PluginUtils.java
trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java
trunk/core/src/core/org/jnode/plugin/model/FragmentDescriptorModel.java
trunk/core/src/core/org/jnode/plugin/model/PluginClassLoaderImpl.java
trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java
trunk/core/src/core/org/jnode/protocol/ProtocolHandlerFactoryPlugin.java
trunk/core/src/core/org/jnode/security/JNodePolicy.java
trunk/core/src/core/org/jnode/util/ByteQueueProcessorThread.java
trunk/core/src/core/org/jnode/util/QueueProcessorThread.java
trunk/core/src/core/org/jnode/vm/MemoryBlockManager.java
trunk/core/src/core/org/jnode/vm/VmSystem.java
trunk/core/src/core/org/jnode/vm/VmSystemClassLoader.java
trunk/core/src/core/org/jnode/vm/bytecode/BasicBlockFinder.java
trunk/core/src/core/org/jnode/vm/bytecode/DeadBlockFinder.java
trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java
trunk/core/src/core/org/jnode/vm/classmgr/VmType.java
trunk/core/src/core/org/jnode/vm/memmgr/def/FinalizerThread.java
trunk/core/src/core/org/jnode/vm/x86/MPConfigTable.java
trunk/core/src/core/org/jnode/vm/x86/MPFloatingPointerStructure.java
trunk/core/src/core/org/jnode/vm/x86/VmX86Architecture.java
trunk/core/src/core/org/jnode/vm/x86/VmX86Processor.java
trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/FPCompilerFPU.java
trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java
trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/FPCompilerFPU.java
trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java
trunk/core/src/core/org/jnode/work/WorkUtils.java
trunk/core/src/driver/org/jnode/driver/AbstractDeviceManager.java
trunk/core/src/driver/org/jnode/driver/DefaultDeviceManager.java
trunk/core/src/driver/org/jnode/driver/Device.java
trunk/core/src/driver/org/jnode/driver/Driver.java
trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java
trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java
trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java
trunk/core/src/mmtk-vm/org/jnode/vm/memmgr/mmtk/BaseMmtkHeapManager.java
trunk/core/src/mmtk-vm/org/mmtk/vm/Assert.java
trunk/core/src/mmtk-vm/org/mmtk/vm/Options.java
trunk/core/src/test/org/jnode/test/framework/TestRunnerPlugin.java
trunk/fs/src/driver/org/jnode/driver/block/ide/disk/IDEDiskDriver.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Volume.java
trunk/fs/src/fs/org/jnode/fs/iso9660/SupplementaryVolumeDescriptor.java
trunk/fs/src/test/org/jnode/test/support/MockObjectFactory.java
trunk/net/src/net/org/jnode/net/util/AbstractDatagramSocketImpl.java
Added Paths:
-----------
trunk/core/descriptors/org.jnode.runtime.core.bootlog.xml
trunk/core/src/core/org/jnode/bootlog/
trunk/core/src/core/org/jnode/bootlog/BootLog.java
trunk/core/src/core/org/jnode/bootlog/BootLogInstance.java
trunk/core/src/core/org/jnode/bootlog/package.html
trunk/core/src/core/org/jnode/vm/BootLogImpl.java
Removed Paths:
-------------
trunk/core/src/core/org/jnode/system/BootLog.java
Property Changed:
----------------
trunk/core/src/test/org/jnode/test/framework/TestRunnerPlugin.java
Modified: trunk/all/conf/system-plugin-list.xml
===================================================================
--- trunk/all/conf/system-plugin-list.xml 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/all/conf/system-plugin-list.xml 2010-05-16 16:48:59 UTC (rev 5750)
@@ -13,6 +13,7 @@
<plugin id="org.jnode.runtime"/>
<plugin id="org.jnode.runtime.core"/>
+ <plugin id="org.jnode.runtime.core.bootlog"/>
<plugin id="org.jnode.security"/>
<plugin id="org.jnode.util"/>
<plugin id="org.jnode.vm"/>
Modified: trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java
===================================================================
--- trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -25,6 +25,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.net.URL;
@@ -47,6 +48,8 @@
import org.jnode.assembler.UnresolvedObjectRefException;
import org.jnode.assembler.NativeStream.ObjectRef;
import org.jnode.assembler.x86.X86BinaryAssembler;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginException;
import org.jnode.plugin.PluginRegistry;
@@ -791,14 +794,84 @@
throws ClassNotFoundException;
public final void execute() throws BuildException {
- // Create the image
- doExecute();
- // Remove all garbage objects
- cleanup();
- System.gc();
- // Make sure that all finalizers are called, in order to remove tmp
- // files.
- Runtime.getRuntime().runFinalization();
+ try {
+ BootLogInstance.set(new BootLog() {
+ @Override
+ public void warn(String msg) {
+ System.out.println(msg);
+ }
+
+ @Override
+ public void warn(String msg, Throwable ex) {
+ System.out.println(msg);
+ ex.printStackTrace(System.out);
+ }
+
+ @Override
+ public void setDebugOut(PrintStream out) {
+ // ignore
+ }
+
+ @Override
+ public void info(String msg, Throwable ex) {
+ System.out.println(msg);
+ ex.printStackTrace(System.out);
+ }
+
+ @Override
+ public void info(String msg) {
+ System.out.println(msg);
+ }
+
+ @Override
+ public void fatal(String msg, Throwable ex) {
+ System.out.println(msg);
+ ex.printStackTrace(System.out);
+ }
+
+ @Override
+ public void fatal(String msg) {
+ System.out.println(msg);
+ }
+
+ @Override
+ public void error(String msg, Throwable ex) {
+ System.out.println(msg);
+ ex.printStackTrace(System.out);
+ }
+
+ @Override
+ public void error(String msg) {
+ System.out.println(msg);
+ }
+
+ @Override
+ public void debug(String msg, Throwable ex) {
+ System.out.println(msg);
+ ex.printStackTrace(System.out);
+ }
+
+ @Override
+ public void debug(String msg) {
+ System.out.println(msg);
+ }
+ });
+
+ // Create the image
+ doExecute();
+ // Remove all garbage objects
+ cleanup();
+ System.gc();
+ // Make sure that all finalizers are called, in order to remove tmp
+ // files.
+ Runtime.getRuntime().runFinalization();
+ } catch (BuildException be) {
+ be.printStackTrace();
+ throw be;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new BuildException(t);
+ }
}
/**
@@ -1368,6 +1441,7 @@
addCompileHighOptLevel("org.jnode.assembler");
addCompileHighOptLevel("org.jnode.boot");
+ addCompileHighOptLevel("org.jnode.bootlog");
addCompileHighOptLevel("org.jnode.naming");
addCompileHighOptLevel("org.jnode.plugin");
addCompileHighOptLevel("org.jnode.plugin.manager");
Modified: trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java
===================================================================
--- trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/builder/src/builder/org/jnode/build/ObjectEmitter.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -26,11 +26,12 @@
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Set;
+
import org.jnode.assembler.BootImageNativeStream;
import org.jnode.assembler.Label;
import org.jnode.assembler.NativeStream;
import org.jnode.assembler.x86.X86BinaryAssembler;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.vm.BootableObject;
import org.jnode.vm.VmSystemObject;
import org.jnode.vm.classmgr.VmArrayClass;
@@ -191,7 +192,7 @@
throw new BuildException(ex);
}
if (!fieldInfo.isExact()) {
- BootLog.warn("Use of in-exact matching class (" + clsName
+ BootLogInstance.get().warn("Use of in-exact matching class (" + clsName
+ ") in bootimage at " + location);
}
legalInstanceClasses.add(clsName);
@@ -460,7 +461,7 @@
+ jdkField.getName() + " of class "
+ cls.getName(), ex);
} catch (JNodeClassNotFoundException ex) {
- BootLog
+ BootLogInstance.get()
.warn("JNode class not found "
+ ex.getMessage());
value = null;
Added: trunk/core/descriptors/org.jnode.runtime.core.bootlog.xml
===================================================================
--- trunk/core/descriptors/org.jnode.runtime.core.bootlog.xml (rev 0)
+++ trunk/core/descriptors/org.jnode.runtime.core.bootlog.xml 2010-05-16 16:48:59 UTC (rev 5750)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plugin SYSTEM "jnode.dtd">
+
+<plugin id="org.jnode.runtime.core.bootlog"
+ name="JNode boot log interface"
+ version="@VERSION@"
+ system="true"
+ license-name="lgpl"
+ provider-name="JNode.org">
+
+ <runtime>
+ <library name="jnode-core.jar">
+ <export name="org.jnode.bootlog.*"/>
+ </library>
+ </runtime>
+
+</plugin>
\ No newline at end of file
Modified: trunk/core/src/core/org/jnode/boot/InitJarProcessor.java
===================================================================
--- trunk/core/src/core/org/jnode/boot/InitJarProcessor.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/boot/InitJarProcessor.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -30,11 +30,12 @@
import java.util.jar.Attributes;
import java.util.jar.Manifest;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginException;
import org.jnode.plugin.PluginLoader;
import org.jnode.plugin.PluginRegistry;
-import org.jnode.system.BootLog;
import org.jnode.system.MemoryResource;
import org.jnode.util.JarBuffer;
@@ -60,7 +61,7 @@
jbuf = new JarBuffer(initJarRes.asByteBuffer());
mf = jbuf.getManifest();
} catch (IOException ex) {
- BootLog.error("Cannot instantiate initjar", ex);
+ BootLogInstance.get().error("Cannot instantiate initjar", ex);
}
}
this.jbuf = jbuf;
@@ -89,7 +90,7 @@
loader, "", "", false); //resolve=false
descriptors.add(descr);
} catch (PluginException ex) {
- BootLog.error("Cannot load " + name, ex);
+ BootLogInstance.get().error("Cannot load " + name, ex);
}
}
}
Modified: trunk/core/src/core/org/jnode/boot/Main.java
===================================================================
--- trunk/core/src/core/org/jnode/boot/Main.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/boot/Main.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -26,11 +26,11 @@
import org.jnode.annotation.LoadStatics;
import org.jnode.annotation.SharedStatics;
import org.jnode.annotation.Uninterruptible;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginManager;
import org.jnode.plugin.PluginRegistry;
import org.jnode.plugin.manager.DefaultPluginManager;
-import org.jnode.system.BootLog;
import org.jnode.vm.Unsafe;
import org.jnode.vm.VmSystem;
@@ -66,13 +66,13 @@
Unsafe.debug("VmSystem.initialize\n");
VmSystem.initialize();
-
+
// Load the plugins from the initjar
- BootLog.info("Loading initjar plugins");
+ BootLogInstance.get().info("Loading initjar plugins");
final InitJarProcessor proc = new InitJarProcessor(VmSystem.getInitJar());
List<PluginDescriptor> descriptors = proc.loadPlugins(pluginRegistry);
- BootLog.info("Starting PluginManager");
+ BootLogInstance.get().info("Starting PluginManager");
final PluginManager piMgr = new DefaultPluginManager(pluginRegistry);
piMgr.startSystemPlugins(descriptors);
@@ -82,7 +82,7 @@
if (mainClassName != null) {
mainClass = loader.loadClass(mainClassName);
} else {
- BootLog.warn("No Main-Class found");
+ BootLogInstance.get().warn("No Main-Class found");
mainClass = null;
}
final long end = VmSystem.currentKernelMillis();
@@ -98,12 +98,12 @@
if (insatnce instanceof Runnable) {
((Runnable) insatnce).run();
} else {
- BootLog.warn("No valid Main-Class found");
+ BootLogInstance.get().warn("No valid Main-Class found");
}
}
}
} catch (Throwable ex) {
- BootLog.error("Error in bootstrap", ex);
+ BootLogInstance.get().error("Error in bootstrap", ex);
Unsafe.debugStackTrace(ex);
sleepForever();
return -2;
Added: trunk/core/src/core/org/jnode/bootlog/BootLog.java
===================================================================
--- trunk/core/src/core/org/jnode/bootlog/BootLog.java (rev 0)
+++ trunk/core/src/core/org/jnode/bootlog/BootLog.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -0,0 +1,119 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2010 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.bootlog;
+
+import java.io.PrintStream;
+
+/**
+ * Logging class used during bootstrap.
+ *
+ * @author Ewout Prangsma (ep...@us...)
+ *
+ */
+public interface BootLog {
+ public static final int DEBUG = 1;
+ public static final int INFO = 2;
+ public static final int WARN = 3;
+ public static final int ERROR = 4;
+ public static final int FATAL = 5;
+
+ /**
+ * Log a debug message
+ *
+ * @param msg
+ */
+ void debug(String msg);
+
+ /**
+ * Log a debug message
+ *
+ * @param msg
+ * @param ex
+ */
+ void debug(String msg, Throwable ex);
+
+ /**
+ * Log an error message
+ *
+ * @param msg
+ */
+ void error(String msg);
+
+ /**
+ * Log an error message
+ *
+ * @param msg
+ * @param ex
+ */
+ void error(String msg, Throwable ex);
+
+ /**
+ * Log an fatal message
+ *
+ * @param msg
+ */
+ void fatal(String msg);
+
+ /**
+ * Log an fatal message
+ *
+ * @param msg
+ * @param ex
+ */
+ void fatal(String msg, Throwable ex);
+
+ /**
+ * Log an info message
+ *
+ * @param msg
+ */
+ void info(String msg);
+
+ /**
+ * Log an info message
+ *
+ * @param msg
+ * @param ex
+ */
+ void info(String msg, Throwable ex);
+
+ /**
+ * Log an warning message
+ *
+ * @param msg
+ * @param ex
+ */
+ void warn(String msg, Throwable ex);
+
+ /**
+ * Log an warning message
+ *
+ * @param msg
+ */
+ void warn(String msg);
+
+ /**
+ * Set the stream to use for debug logs.
+ *
+ * @param out
+ */
+ void setDebugOut(PrintStream out);
+}
Added: trunk/core/src/core/org/jnode/bootlog/BootLogInstance.java
===================================================================
--- trunk/core/src/core/org/jnode/bootlog/BootLogInstance.java (rev 0)
+++ trunk/core/src/core/org/jnode/bootlog/BootLogInstance.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -0,0 +1,35 @@
+package org.jnode.bootlog;
+
+
+/**
+ * Class holding the {@link BootLog} instance used by the system.
+ * <br/><h1>Implementation note :</h1> The reference to the actual instance of
+ * the BootLog can't be stored in the InitialNaming that use VmType, which is
+ * not fully initialized at build time (but BootLog is used). So, we are always
+ * holding the reference in that class.
+ *
+ * @author Fabien DUMINY
+ *
+ */
+public final class BootLogInstance {
+ private static BootLog BOOT_LOG_INSTANCE;
+
+ private BootLogInstance () {
+ }
+
+ /**
+ * Get the system's {@link BootLog}.
+ * @return the system's {@link BootLog}.
+ */
+ public static BootLog get() {
+ return BOOT_LOG_INSTANCE;
+ }
+
+ /**
+ * Set the system's {@link BootLog}.
+ * @param bootLog the system's {@link BootLog}.
+ */
+ public static void set(BootLog bootLog) {
+ BOOT_LOG_INSTANCE = bootLog;
+ }
+}
Added: trunk/core/src/core/org/jnode/bootlog/package.html
===================================================================
--- trunk/core/src/core/org/jnode/bootlog/package.html (rev 0)
+++ trunk/core/src/core/org/jnode/bootlog/package.html 2010-05-16 16:48:59 UTC (rev 5750)
@@ -0,0 +1,11 @@
+<html>
+<head>
+ <title>org.jnode.plugin</title>
+</head>
+<body>
+
+This package contains the interface with boot time log.
+It also contains the singleton instance implementing that interface.
+
+</body>
+</html>
\ No newline at end of file
Modified: trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java
===================================================================
--- trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/log4j/config/Log4jConfigurePlugin.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -30,6 +30,7 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.driver.console.ActiveTextConsole;
import org.jnode.driver.console.ConsoleManager;
import org.jnode.driver.console.TextConsole;
@@ -37,7 +38,6 @@
import org.jnode.plugin.Plugin;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginException;
-import org.jnode.system.BootLog;
import org.jnode.util.WriterOutputStream;
/**
@@ -79,7 +79,7 @@
final VirtualConsoleAppender debugApp =
new VirtualConsoleAppender(new PatternLayout(LAYOUT), console, false);
debugApp.setThreshold(Level.DEBUG);
- BootLog.setDebugOut(new PrintStream(new WriterOutputStream(console.getOut(), false), true));
+ BootLogInstance.get().setDebugOut(new PrintStream(new WriterOutputStream(console.getOut(), false), true));
TextConsole atc = new ActiveTextConsole(conMgr);
final VirtualConsoleAppender infoApp = new VirtualConsoleAppender(
Modified: trunk/core/src/core/org/jnode/plugin/Plugin.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/Plugin.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/Plugin.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -24,7 +24,8 @@
import java.security.PrivilegedAction;
import java.util.prefs.Preferences;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
/**
@@ -101,7 +102,7 @@
}
if (!started) {
if (descriptor.hasCustomPluginClass()) {
- BootLog.debug("Starting plugin: " + descriptor.getId());
+ BootLogInstance.get().debug("Starting plugin: " + descriptor.getId());
}
started = true;
try {
Modified: trunk/core/src/core/org/jnode/plugin/PluginManager.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/PluginManager.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/PluginManager.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -22,7 +22,8 @@
import java.util.List;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
/**
* Interface of manager of all plugins in the system.
@@ -75,10 +76,10 @@
try {
plugin.start();
} catch (PluginException ex) {
- BootLog.error("Error starting " + plugin.getDescriptor().getId());
+ BootLogInstance.get().error("Error starting " + plugin.getDescriptor().getId());
throw ex;
} catch (Throwable ex) {
- BootLog.error("Error starting " + plugin.getDescriptor().getId());
+ BootLogInstance.get().error("Error starting " + plugin.getDescriptor().getId());
throw new PluginException(ex);
}
}
@@ -93,14 +94,14 @@
protected final void stopSinglePlugin(Plugin plugin) throws PluginException {
try {
if (plugin.isActive()) {
- BootLog.info("Stopping " + plugin.getDescriptor().getId());
+ BootLogInstance.get().info("Stopping " + plugin.getDescriptor().getId());
plugin.stop();
}
} catch (PluginException ex) {
- BootLog.error("Error stopping " + plugin.getDescriptor().getId());
+ BootLogInstance.get().error("Error stopping " + plugin.getDescriptor().getId());
throw ex;
} catch (Throwable ex) {
- BootLog.error("Error stopping " + plugin.getDescriptor().getId());
+ BootLogInstance.get().error("Error stopping " + plugin.getDescriptor().getId());
throw new PluginException(ex);
}
}
Modified: trunk/core/src/core/org/jnode/plugin/PluginUtils.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/PluginUtils.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/PluginUtils.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -24,7 +24,8 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
/**
* Plugin utility methods.
@@ -72,22 +73,22 @@
String message = null;
try {
- BootLog.debug("messageKey=" + messageKey + ", trying with " + Locale.getDefault());
+ BootLogInstance.get().debug("messageKey=" + messageKey + ", trying with " + Locale.getDefault());
bundle = ResourceBundle.getBundle(fullName, Locale.getDefault(), loader);
} catch (MissingResourceException e) {
try {
- BootLog.debug("trying with " + Locale.ENGLISH);
+ BootLogInstance.get().debug("trying with " + Locale.ENGLISH);
bundle = ResourceBundle.getBundle(fullName, Locale.ENGLISH, loader);
} catch (MissingResourceException mre) {
if (!cleanFallback)
- BootLog.error("can't get message", mre);
+ BootLogInstance.get().error("can't get message", mre);
}
}
- BootLog.debug("bundle=" + bundle);
+ BootLogInstance.get().debug("bundle=" + bundle);
if (bundle != null) {
try {
- BootLog.debug("got bundle " + bundleName);
+ BootLogInstance.get().debug("got bundle " + bundleName);
message = bundle.getString(messageKey);
} catch (MissingResourceException mre) {
if (!cleanFallback)
@@ -96,7 +97,7 @@
}
if (message == null && !cleanFallback) {
- BootLog.error("can't get message from bundle " + bundleName + " with key " + messageKey);
+ BootLogInstance.get().error("can't get message from bundle " + bundleName + " with key " + messageKey);
}
return (message == null) ? (cleanFallback ? messageKey : ('?' + messageKey + '?')) : message;
Modified: trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/manager/DefaultPluginManager.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -35,6 +35,8 @@
import javax.naming.NamingException;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.naming.InitialNaming;
import org.jnode.plugin.Plugin;
import org.jnode.plugin.PluginDescriptor;
@@ -45,7 +47,6 @@
import org.jnode.plugin.PluginRegistry;
import org.jnode.plugin.model.PluginRegistryModel;
import org.jnode.security.JNodePermission;
-import org.jnode.system.BootLog;
/**
* @author epr
@@ -128,7 +129,7 @@
// 2 loops, first start all system plugins,
// then start all auto-start plugins
for (int type = 0; type < 2; type++) {
- BootLog.info("Starting " + ((type == 0) ? "system" : "auto-start") + " plugins");
+ BootLogInstance.get().info("Starting " + ((type == 0) ? "system" : "auto-start") + " plugins");
for (PluginDescriptor descr : descrList) {
try {
final boolean start;
@@ -145,7 +146,7 @@
startSinglePlugin(descr.getPlugin());
}
} catch (Throwable ex) {
- BootLog.error("Cannot start " + descr.getId(), ex);
+ BootLogInstance.get().error("Cannot start " + descr.getId(), ex);
if (debug) {
try {
Thread.sleep(5000);
@@ -159,7 +160,7 @@
// Wait a while until all plugins have finished their startup process
if (!isStartPluginsFinished()) {
- BootLog.info("Waiting for plugins to finished their startprocess");
+ BootLogInstance.get().info("Waiting for plugins to finished their startprocess");
final long start = System.currentTimeMillis();
long now = start;
int loop = 0;
@@ -202,9 +203,9 @@
//empty
}
}
- BootLog.info("Stopped all plugins");
+ BootLogInstance.get().info("Stopped all plugins");
} catch (PluginException ex) {
- BootLog.error("Cannot stop plugins", ex);
+ BootLogInstance.get().error("Cannot stop plugins", ex);
}
}
@@ -216,7 +217,7 @@
*/
public final void stopPlugin(PluginDescriptor d) throws PluginException {
final String id = d.getId();
- //BootLog.info("__Stopping " + id);
+ //BootLogInstance.get().info("__Stopping " + id);
for (PluginDescriptor descr : registry) {
if (descr.depends(id)) {
stopPlugin(descr);
@@ -245,7 +246,7 @@
for (Iterator<PluginDescriptor> i = all.values().iterator(); i.hasNext();) {
final PluginDescriptor descr = (PluginDescriptor) i.next();
if (!prerequisitesExist(descr, all)) {
- BootLog.info("Skipping plugin " + descr.getId());
+ BootLogInstance.get().info("Skipping plugin " + descr.getId());
all.remove(descr.getId());
systemSet.remove(descr.getId());
i = all.values().iterator();
@@ -351,7 +352,7 @@
final Plugin pi = descr.getPlugin();
if (pi.isActive()) {
if (!pi.isStartFinished()) {
- BootLog.error("Plugin " + descr.getId()
+ BootLogInstance.get().error("Plugin " + descr.getId()
+ " has not yet finished");
}
}
Modified: trunk/core/src/core/org/jnode/plugin/model/FragmentDescriptorModel.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/model/FragmentDescriptorModel.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/model/FragmentDescriptorModel.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -24,10 +24,11 @@
import java.nio.ByteBuffer;
import java.util.List;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.nanoxml.XMLElement;
import org.jnode.plugin.FragmentDescriptor;
import org.jnode.plugin.PluginException;
-import org.jnode.system.BootLog;
import org.jnode.vm.ResourceLoader;
/**
@@ -143,7 +144,7 @@
if (plugin == null) {
throw new PluginException("Plugin " + getPluginId() + " not found");
}
- BootLog.info("Resolve " + getId());
+ BootLogInstance.get().info("Resolve " + getId());
plugin.add(this);
}
@@ -155,7 +156,7 @@
plugin.remove(this);
plugin = null;
}
- BootLog.info("Unresolve " + getId());
+ BootLogInstance.get().info("Unresolve " + getId());
super.unresolve(registry);
}
Modified: trunk/core/src/core/org/jnode/plugin/model/PluginClassLoaderImpl.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/model/PluginClassLoaderImpl.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/model/PluginClassLoaderImpl.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -37,10 +37,11 @@
import java.util.List;
import java.util.Set;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.plugin.PluginClassLoader;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginException;
-import org.jnode.system.BootLog;
import org.jnode.vm.ResourceLoader;
import org.jnode.vm.classmgr.VmClassLoader;
@@ -198,7 +199,7 @@
fragment.startPlugin(registry);
}
} catch (PluginException ex) {
- BootLog.error("Error starting plugin", ex);
+ BootLogInstance.get().error("Error starting plugin", ex);
}
// Define package (if needed)
@@ -297,7 +298,7 @@
fragment.startPlugin(registry);
}
} catch (PluginException ex) {
- BootLog.error("Cannot start plugin", ex);
+ BootLogInstance.get().error("Cannot start plugin", ex);
}
}
return url;
@@ -331,7 +332,7 @@
startPlugin();
fragment.startPlugin(registry);
} catch (PluginException ex) {
- BootLog.error("Cannot start plugin", ex);
+ BootLogInstance.get().error("Cannot start plugin", ex);
}
System.err.println("adding " + url);
if (!urls.contains(url))
@@ -347,7 +348,7 @@
try {
startPlugin();
} catch (PluginException ex) {
- BootLog.error("Cannot start plugin", ex);
+ BootLogInstance.get().error("Cannot start plugin", ex);
}
System.err.println("adding " + url);
if (!urls.contains(url))
Modified: trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/plugin/model/PluginDescriptorModel.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -30,6 +30,8 @@
import java.util.Iterator;
import java.util.List;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.nanoxml.XMLElement;
import org.jnode.plugin.Extension;
import org.jnode.plugin.ExtensionPoint;
@@ -40,7 +42,6 @@
import org.jnode.plugin.PluginPrerequisite;
import org.jnode.plugin.PluginReference;
import org.jnode.plugin.Runtime;
-import org.jnode.system.BootLog;
import org.jnode.vm.VmSystem;
import org.jnode.vm.classmgr.VmClassLoader;
import org.jnode.vm.isolate.VmIsolateLocal;
@@ -629,7 +630,7 @@
throw new SecurityException("Cannot overwrite the registry");
}
if (!resolved) {
- // BootLog.info("Resolve " + id);
+ // BootLogInstance.get().info("Resolve " + id);
this.registry = registry;
registry.registerPlugin(this);
for (int i = 0; i < extensionPoints.length; i++) {
@@ -664,7 +665,7 @@
}
starting = true;
}
- // BootLog.info("Resolve on plugin " + getId());
+ // BootLogInstance.get().info("Resolve on plugin " + getId());
try {
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws PluginException {
@@ -672,20 +673,20 @@
final int reqMax = requires.length;
for (int i = 0; i < reqMax; i++) {
final String reqId = requires[i].getPluginId();
- // BootLog.info("Start dependency " + reqId);
+ // BootLogInstance.get().info("Start dependency " + reqId);
final PluginDescriptorModel reqDescr = (PluginDescriptorModel) registry
.getPluginDescriptor(reqId);
reqDescr.startPlugin(registry);
// Make sure that it is really started
reqDescr.waitUntilStarted();
}
- // BootLog.info("Start myself " + getId());
+ // BootLogInstance.get().info("Start myself " + getId());
getPlugin().start();
return null;
}
});
} catch (PrivilegedActionException ex) {
- BootLog.error("Error starting plugin", ex);
+ BootLogInstance.get().error("Error starting plugin", ex);
/*try {
Thread.sleep(10000);
} catch (InterruptedException ex1) {
Modified: trunk/core/src/core/org/jnode/protocol/ProtocolHandlerFactoryPlugin.java
===================================================================
--- trunk/core/src/core/org/jnode/protocol/ProtocolHandlerFactoryPlugin.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/protocol/ProtocolHandlerFactoryPlugin.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -27,6 +27,8 @@
import java.security.PrivilegedAction;
import java.util.HashMap;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.plugin.ConfigurationElement;
import org.jnode.plugin.Extension;
import org.jnode.plugin.ExtensionPoint;
@@ -34,7 +36,6 @@
import org.jnode.plugin.Plugin;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginException;
-import org.jnode.system.BootLog;
/**
* Plugin that installs itself as an URL Handler Factory.
@@ -68,7 +69,7 @@
try {
setHandlerFactory(this);
} catch (SecurityException ex) {
- BootLog.error("Cannot set URL Handler Factory");
+ BootLogInstance.get().error("Cannot set URL Handler Factory");
}
}
@@ -80,7 +81,7 @@
try {
setHandlerFactory(null);
} catch (SecurityException ex) {
- BootLog.error("Cannot reset URL Handler Factory");
+ BootLogInstance.get().error("Cannot reset URL Handler Factory");
}
}
@@ -93,9 +94,9 @@
try {
return (URLStreamHandler) cls.newInstance();
} catch (InstantiationException ex) {
- BootLog.error("Cannot instantiate " + cls.getName());
+ BootLogInstance.get().error("Cannot instantiate " + cls.getName());
} catch (IllegalAccessException ex) {
- BootLog.error("Illegal access to " + cls.getName());
+ BootLogInstance.get().error("Illegal access to " + cls.getName());
}
}
return null;
@@ -150,7 +151,7 @@
final Class<? extends URLStreamHandler> cls = cl.loadClass(className);
handlerClasses.put(protocol, cls);
} catch (ClassNotFoundException ex) {
- BootLog.error("Cannot load protocol handler class " + className);
+ BootLogInstance.get().error("Cannot load protocol handler class " + className);
}
}
}
Modified: trunk/core/src/core/org/jnode/security/JNodePolicy.java
===================================================================
--- trunk/core/src/core/org/jnode/security/JNodePolicy.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/security/JNodePolicy.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -36,10 +36,11 @@
import java.util.HashMap;
import java.util.Map;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.plugin.ConfigurationElement;
import org.jnode.plugin.Extension;
import org.jnode.plugin.ExtensionPoint;
-import org.jnode.system.BootLog;
/**
* Default policy implementation for JNode.
@@ -99,7 +100,7 @@
.entrySet()) {
final CodeSource cs = e.getKey();
if (cs.implies(codeSource)) {
- // BootLog.info(cs + " -> " + codeSource);
+ // BootLogInstance.get().info(cs + " -> " + codeSource);
final PermissionCollection pc = e.getValue();
for (Enumeration<?> ee = pc.elements(); ee.hasMoreElements();) {
perms.add((Permission) ee.nextElement());
@@ -147,7 +148,7 @@
final CodeSource cs = new CodeSource(url, (Certificate[]) null);
final Permissions perms = new Permissions();
codeSource2Permissions.put(cs, perms);
- // BootLog.debug("Adding permissions for " + cs);
+ // BootLogInstance.get().debug("Adding permissions for " + cs);
final ConfigurationElement[] elems = ext.getConfigurationElements();
final int count = elems.length;
for (int i = 0; i < count; i++) {
@@ -175,30 +176,30 @@
final Permission p = (Permission) perm;
perms.add(p);
} catch (ClassNotFoundException ex) {
- BootLog
+ BootLogInstance.get()
.error("Permission class " + type
+ " not found");
} catch (InstantiationException ex) {
- BootLog.error("Cannot instantiate permission class "
+ BootLogInstance.get().error("Cannot instantiate permission class "
+ type);
} catch (IllegalAccessException ex) {
- BootLog.error("Illegal access to permission class "
+ BootLogInstance.get().error("Illegal access to permission class "
+ type);
} catch (NoSuchMethodException ex) {
- BootLog
+ BootLogInstance.get()
.error("Constructor not found on permission class "
+ type + " in plugin " + id);
} catch (InvocationTargetException ex) {
- BootLog.error("Error constructing permission class "
+ BootLogInstance.get().error("Error constructing permission class "
+ type, ex);
} catch (ClassCastException ex) {
- BootLog.error("Permission class " + type
+ BootLogInstance.get().error("Permission class " + type
+ " not instance of Permission");
}
}
}
} catch (MalformedURLException ex) {
- BootLog.error("Cannot create plugin codesource", ex);
+ BootLogInstance.get().error("Cannot create plugin codesource", ex);
}
}
}
Deleted: trunk/core/src/core/org/jnode/system/BootLog.java
===================================================================
--- trunk/core/src/core/org/jnode/system/BootLog.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/system/BootLog.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -1,180 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2003-2010 JNode.org
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-package org.jnode.system;
-
-import java.io.PrintStream;
-
-import org.jnode.vm.Unsafe;
-
-/**
- * Logging class used during bootstrap.
- *
- * @author Ewout Prangsma (ep...@us...)
- */
-public class BootLog {
-
- public static final int DEBUG = 1;
- public static final int INFO = 2;
- public static final int WARN = 3;
- public static final int ERROR = 4;
- public static final int FATAL = 5;
-
- private static PrintStream debugOut;
-
- /**
- * Log a debug message
- *
- * @param msg
- */
- public static void debug(String msg) {
- final PrintStream out = (debugOut != null) ? debugOut : System.out;
- log(DEBUG, out, msg, null);
- }
-
- /**
- * Log a debug message
- *
- * @param msg
- * @param ex
- */
- public static void debug(String msg, Throwable ex) {
- final PrintStream out = (debugOut != null) ? debugOut : System.out;
- log(DEBUG, out, msg, ex);
- }
-
- /**
- * Log an error message
- *
- * @param msg
- */
- public static void error(String msg) {
- log(ERROR, System.err, msg, null);
- }
-
- /**
- * Log an error message
- *
- * @param msg
- * @param ex
- */
- public static void error(String msg, Throwable ex) {
- log(ERROR, System.err, msg, ex);
- /*try {
- Thread.sleep(2500);
- } catch (InterruptedException ex2) {
- // Ignore
- }*/
- }
-
- /**
- * Log an fatal message
- *
- * @param msg
- */
- public static void fatal(String msg) {
- log(FATAL, System.err, msg, null);
- }
-
- /**
- * Log an fatal message
- *
- * @param msg
- * @param ex
- */
- public static void fatal(String msg, Throwable ex) {
- log(FATAL, System.err, msg, ex);
- }
-
- /**
- * Log an info message
- *
- * @param msg
- */
- public static void info(String msg) {
- log(INFO, System.out, msg, null);
- }
-
- /**
- * Log an info message
- *
- * @param msg
- * @param ex
- */
- public static void info(String msg, Throwable ex) {
- log(INFO, System.out, msg, ex);
- }
-
- /**
- * Log an warning message
- *
- * @param msg
- * @param ex
- */
- public static void warn(String msg, Throwable ex) {
- log(WARN, System.out, msg, ex);
- }
-
- /**
- * Log an warning message
- *
- * @param msg
- */
- public static void warn(String msg) {
- log(WARN, System.out, msg, null);
- }
-
- /**
- * Set the stream to use for debug logs.
- *
- * @param out
- */
- public static void setDebugOut(PrintStream out) {
- debugOut = out;
- }
-
- /**
- * Log an error message
- *
- * @param level
- * @param ps
- * @param msg
- * @param ex
- */
- private static void log(int level, PrintStream ps, String msg, Throwable ex) {
- if (ps != null) {
- if (msg != null) {
- ps.println(msg);
- }
- if (ex != null) {
- ex.printStackTrace(ps);
- }
- } else {
- if (msg != null) {
- Unsafe.debug(msg);
- Unsafe.debug("\n");
- }
- if (ex != null) {
- Unsafe.debug(ex.toString());
- Unsafe.debug("\n");
- }
- }
- }
-}
Modified: trunk/core/src/core/org/jnode/util/ByteQueueProcessorThread.java
===================================================================
--- trunk/core/src/core/org/jnode/util/ByteQueueProcessorThread.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/util/ByteQueueProcessorThread.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -20,7 +20,8 @@
package org.jnode.util;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
/**
* @author Ewout Prangsma (ep...@us...)
@@ -76,7 +77,7 @@
* @param ex
*/
protected void handleException(Exception ex) {
- BootLog.error("Exception in ByteQueueProcessor: " + getName(), ex);
+ BootLogInstance.get().error("Exception in ByteQueueProcessor: " + getName(), ex);
}
/**
@@ -85,7 +86,7 @@
* @param ex
*/
protected void handleError(Error ex) {
- BootLog.error("Error in ByteQueueProcessor: " + getName(), ex);
+ BootLogInstance.get().error("Error in ByteQueueProcessor: " + getName(), ex);
}
/**
Modified: trunk/core/src/core/org/jnode/util/QueueProcessorThread.java
===================================================================
--- trunk/core/src/core/org/jnode/util/QueueProcessorThread.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/util/QueueProcessorThread.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -20,7 +20,8 @@
package org.jnode.util;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
/**
* @author epr
@@ -80,7 +81,7 @@
* @param ex
*/
protected void handleException(Exception ex) {
- BootLog.error("Exception in QueueProcessor: " + getName(), ex);
+ BootLogInstance.get().error("Exception in QueueProcessor: " + getName(), ex);
}
/**
@@ -89,7 +90,7 @@
* @param ex
*/
protected void handleError(Error ex) {
- BootLog.error("Error in QueueProcessor: " + getName(), ex);
+ BootLogInstance.get().error("Error in QueueProcessor: " + getName(), ex);
}
/**
Copied: trunk/core/src/core/org/jnode/vm/BootLogImpl.java (from rev 5749, trunk/core/src/core/org/jnode/system/BootLog.java)
===================================================================
--- trunk/core/src/core/org/jnode/vm/BootLogImpl.java (rev 0)
+++ trunk/core/src/core/org/jnode/vm/BootLogImpl.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -0,0 +1,153 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2003-2010 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package org.jnode.vm;
+
+import java.io.PrintStream;
+
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
+
+/**
+ * Logging class used during bootstrap.
+ *
+ * @author Ewout Prangsma (ep...@us...)
+ */
+class BootLogImpl implements BootLog, BootableObject {
+
+ private PrintStream debugOut;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(String msg) {
+ final PrintStream out = (debugOut != null) ? debugOut : System.out;
+ log(DEBUG, out, msg, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void debug(String msg, Throwable ex) {
+ final PrintStream out = (debugOut != null) ? debugOut : System.out;
+ log(DEBUG, out, msg, ex);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void error(String msg) {
+ log(ERROR, System.err, msg, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void error(String msg, Throwable ex) {
+ log(ERROR, System.err, msg, ex);
+ /*try {
+ Thread.sleep(2500);
+ } catch (InterruptedException ex2) {
+ // Ignore
+ }*/
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void fatal(String msg) {
+ log(FATAL, System.err, msg, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void fatal(String msg, Throwable ex) {
+ log(FATAL, System.err, msg, ex);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void info(String msg) {
+ log(INFO, System.out, msg, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void info(String msg, Throwable ex) {
+ log(INFO, System.out, msg, ex);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(String msg, Throwable ex) {
+ log(WARN, System.out, msg, ex);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void warn(String msg) {
+ log(WARN, System.out, msg, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDebugOut(PrintStream out) {
+ debugOut = out;
+ }
+
+ /**
+ * Log an error message
+ *
+ * @param level
+ * @param ps
+ * @param msg
+ * @param ex
+ */
+ private void log(int level, PrintStream ps, String msg, Throwable ex) {
+ if (ps != null) {
+ if (msg != null) {
+ ps.println(msg);
+ }
+ if (ex != null) {
+ ex.printStackTrace(ps);
+ }
+ } else {
+ if (msg != null) {
+ Unsafe.debug(msg);
+ Unsafe.debug("\n");
+ }
+ if (ex != null) {
+ Unsafe.debug(ex.toString());
+ Unsafe.debug("\n");
+ }
+ }
+ }
+
+ static void initialize() {
+ Unsafe.debug("Initialize BootLog\n");
+ BootLogInstance.set(new BootLogImpl());
+ }
+}
Modified: trunk/core/src/core/org/jnode/vm/MemoryBlockManager.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/MemoryBlockManager.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/vm/MemoryBlockManager.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -23,6 +23,7 @@
import org.jnode.annotation.MagicPermission;
import org.jnode.annotation.SharedStatics;
import org.jnode.annotation.Uninterruptible;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.vm.scheduler.VmProcessor;
import org.jnode.vm.scheduler.VmThread;
import org.vmmagic.unboxed.Address;
@@ -244,9 +245,8 @@
/**
* Initialize this manager.
*/
- private static void initialize() {
+ private static void initialize() {
Unsafe.debug("Initialize MemoryBlockManager\n");
-
startPtr = blockAlign(Unsafe.getMemoryStart().toWord(), true).toAddress();
endPtr = blockAlign(Unsafe.getMemoryEnd().toWord(), false).toAddress();
Modified: trunk/core/src/core/org/jnode/vm/VmSystem.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/VmSystem.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/vm/VmSystem.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -33,21 +33,21 @@
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
+import org.jnode.annotation.Internal;
+import org.jnode.annotation.KernelSpace;
+import org.jnode.annotation.MagicPermission;
+import org.jnode.annotation.PrivilegedActionPragma;
+import org.jnode.annotation.SharedStatics;
+import org.jnode.annotation.Uninterruptible;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.naming.InitialNaming;
import org.jnode.plugin.PluginManager;
import org.jnode.security.JNodePermission;
-import org.jnode.system.BootLog;
import org.jnode.system.MemoryResource;
import org.jnode.system.ResourceManager;
import org.jnode.system.ResourceNotFreeException;
import org.jnode.system.ResourceOwner;
import org.jnode.system.SimpleResourceOwner;
-import org.jnode.annotation.Internal;
-import org.jnode.annotation.KernelSpace;
-import org.jnode.annotation.MagicPermission;
-import org.jnode.annotation.PrivilegedActionPragma;
-import org.jnode.annotation.SharedStatics;
-import org.jnode.annotation.Uninterruptible;
import org.jnode.vm.classmgr.AbstractExceptionHandler;
import org.jnode.vm.classmgr.VmArray;
import org.jnode.vm.classmgr.VmByteCode;
@@ -118,11 +118,13 @@
* Initialize the Virtual Machine
*/
public static void initialize() {
- if (!inited) {
-
+ if (!inited) {
+ // Initialize BootLog
+ BootLogImpl.initialize();
+
// Initialize resource manager
final ResourceManager rm = ResourceManagerImpl.initialize();
-
+
/* Initialize the system classloader */
VmSystemClassLoader loader = (VmSystemClassLoader) (getVmClass(VmProcessor.current()).getLoader());
systemLoader = loader;
@@ -249,16 +251,16 @@
final Extent size = end.toWord().sub(start.toWord()).toExtent();
if (size.toWord().isZero()) {
// No initial jarfile
- BootLog.info("No initial jarfile found");
+ BootLogInstance.get().info("No initial jarfile found");
return null;
} else {
- BootLog.info("Found initial jarfile of " + size.toInt() + "b");
+ BootLogInstance.get().info("Found initial jarfile of " + size.toInt() + "b");
try {
final ResourceOwner owner = new SimpleResourceOwner("System");
return rm.claimMemoryResource(owner, start, size,
ResourceManager.MEMMODE_NORMAL);
} catch (ResourceNotFreeException ex) {
- BootLog.error("Cannot claim initjar resource", ex);
+ BootLogInstance.get().error("Cannot claim initjar resource", ex);
return null;
}
}
@@ -566,7 +568,7 @@
final VmType exClass = VmMagic.getObjectType(ex);
final VmMethod method = reader.getMethod(frame);
if (method == null) {
- Unsafe.debug("Unknown method");
+ Unsafe.debug("Unknown method in class " + ex.getClass().getName());
return null;
}
@@ -831,7 +833,7 @@
}
}
} catch (Exception ex) {
- BootLog.error("Error getting rtcIncrement ", ex);
+ BootLogInstance.get().error("Error getting rtcIncrement ", ex);
rtcIncrement = 1;
}
}
Modified: trunk/core/src/core/org/jnode/vm/VmSystemClassLoader.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/VmSystemClassLoader.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/vm/VmSystemClassLoader.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -323,7 +323,7 @@
throw new ClassNotFoundException(name);
}
- // BootLog.debug("load class" + name);
+ // BootLogInstance.get().debug("load class" + name);
if (name.indexOf('/') >= 0) {
//throw new IllegalArgumentException("name contains '/'");
Modified: trunk/core/src/core/org/jnode/vm/bytecode/BasicBlockFinder.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/bytecode/BasicBlockFinder.java 2010-05-12 10:31:48 UTC (rev 5749)
+++ trunk/core/src/core/org/jnode/vm/bytecode/BasicBlockFinder.java 2010-05-16 16:48:59 UTC (rev 5750)
@@ -23,7 +23,8 @@
import java.util.Comparator;
import java.util.TreeMap;
-import org.jnode.system.BootLog;
+import org.jnode.bootlog.BootLog;
+import org.jnode.bootlog.BootLogInstance;
import org.jnode.vm.JvmType;
import org.jnode.vm.classmgr.VmByteCode;
import org.jnode.vm.classmgr.VmConstClass;
@@ -380,7 +381,7 @@
*/
public void visit_ireturn() {
if (debug) {
- BootLog.debug("ireturn at " + curAddress + "; " + tstack);
+ BootLogInstance.get().debug("ireturn at " + curAddress + "; " + tstack);
}
tstack.pop(JvmType.INT);
endBB(false);
@@ -435,34 +436,34 @@
*/
public void startInstruction(int address) {
if (debug) {
- BootLog.debug("#" + address + "\t" + tstack);
+ BootLogInstance.get().debug("#" + address + "\t" + tstack);
}
curAddress = address;
super.startInstruction(address);
opcodeFlags[address] |= F_START_OF_INSTRUCTION;
if (nextIsStartOfBB) {
- if (debug) BootLog.debug("\tnextIsStartOfBB\t" + nextFollowsTypeStack);
+ if (debug) BootLogInstance.get().debug("\tnextIsStartOfBB\t" + nextFollowsTypeStack);
startBB(address, nextFollowsTypeStack, this.tstack);
nextIsStartOfBB =...
[truncated message content] |