|
From: <ls...@us...> - 2008-11-17 13:53:57
|
Revision: 4707
http://jnode.svn.sourceforge.net/jnode/?rev=4707&view=rev
Author: lsantha
Date: 2008-11-17 13:53:52 +0000 (Mon, 17 Nov 2008)
Log Message:
-----------
Style fixes.
Modified Paths:
--------------
trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java
trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java
trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java
trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java
trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java
trunk/shell/src/shell/org/jnode/shell/help/EnhancedHelp.java
Modified: trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java 2008-11-17 13:46:59 UTC (rev 4706)
+++ trunk/core/src/core/org/jnode/vm/isolate/IsolateThreadFactory.java 2008-11-17 13:53:52 UTC (rev 4707)
@@ -3,12 +3,6 @@
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import org.jnode.vm.classmgr.VmIsolatedStatics;
-import org.jnode.vm.Vm;
-import org.jnode.vm.VmSystem;
-import org.jnode.plugin.PluginManager;
-import org.jnode.naming.InitialNaming;
-import javax.naming.NameNotFoundException;
-import javax.isolate.IsolateStartupException;
class IsolateThreadFactory implements ThreadFactory {
final ThreadGroup group;
@@ -29,11 +23,11 @@
}
}
- Thread t = new IsolateFactoryThread(group, namePrefix + threadNumber.getAndIncrement(), isolatedStatics){
+ Thread t = new IsolateFactoryThread(group, namePrefix + threadNumber.getAndIncrement(), isolatedStatics) {
public void start() {
- org.jnode.vm.Unsafe.debug("factory 1 thread start() " + this.getName() +"\n");
+ org.jnode.vm.Unsafe.debug("factory 1 thread start() " + this.getName() + "\n");
// getVmThread().switchToIsolate(isolatedStatics);
- super.start();
+ super.start();
}
};
/*
@@ -46,16 +40,14 @@
*/
//t.setContextClassLoader(piManager.getRegistry().getPluginsClassLoader());
// if (t.isDaemon())
- // t.setDaemon(false);
- // if (t.getPriority() != Thread.NORM_PRIORITY)
- // t.setPriority(Thread.NORM_PRIORITY + 2);
+ // t.setDaemon(false);
+ // if (t.getPriority() != Thread.NORM_PRIORITY)
+ // t.setPriority(Thread.NORM_PRIORITY + 2);
return t;
}
}
-
-
class IsolateThreadFactory2 implements ThreadFactory {
final ThreadGroup group;
final AtomicInteger threadNumber = new AtomicInteger(1);
@@ -70,18 +62,18 @@
group = isolate.getThreadGroup();
namePrefix = "isolate-" + isolate.getId() + "-executor-";
isolatedStatics = isolate.getIsolatedStaticsTable();
- factoryThread = new Thread(group, new Runnable(){
+ factoryThread = new Thread(group, new Runnable() {
public void run() {
- while(true) {
+ while (true) {
synchronized (lock) {
try {
- while(runnable == null) {
+ while (runnable == null) {
lock.wait();
}
- newThread = new Thread(group, runnable, namePrefix + threadNumber.getAndIncrement()){
+ newThread = new Thread(group, runnable, namePrefix + threadNumber.getAndIncrement()) {
public void start() {
- org.jnode.vm.Unsafe.debug("factory thread start() " + this.getName() +"\n");
+ org.jnode.vm.Unsafe.debug("factory thread start() " + this.getName() + "\n");
super.start();
}
};
@@ -93,7 +85,7 @@
}
}
}
- },"isolate-" + isolate.getId() + "-thread-factory-");
+ }, "isolate-" + isolate.getId() + "-thread-factory-");
factoryThread.start();
}
@@ -105,7 +97,7 @@
newThread = null;
runnable = r;
lock.notifyAll();
- while(newThread == null) {
+ while (newThread == null) {
try {
lock.wait();
} catch (InterruptedException x) {
@@ -178,7 +170,8 @@
}
- newThread = new IsolateFactoryThread(group, null, namePrefix + threadNumber.getAndIncrement(), null);
+ newThread = new IsolateFactoryThread(group, null, namePrefix +
+ threadNumber.getAndIncrement(), null);
} catch (Exception x) {
x.printStackTrace();
}
@@ -209,4 +202,4 @@
}
}
-*/
\ No newline at end of file
+*/
Modified: trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-11-17 13:46:59 UTC (rev 4706)
+++ trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java 2008-11-17 13:53:52 UTC (rev 4707)
@@ -48,12 +48,12 @@
import org.jnode.vm.VmIOContext;
import org.jnode.vm.VmMagic;
import org.jnode.vm.VmSystem;
-import org.jnode.vm.scheduler.VmThread;
import org.jnode.vm.annotation.MagicPermission;
import org.jnode.vm.annotation.PrivilegedActionPragma;
import org.jnode.vm.annotation.SharedStatics;
import org.jnode.vm.classmgr.VmIsolatedStatics;
import org.jnode.vm.classmgr.VmType;
+import org.jnode.vm.scheduler.VmThread;
/**
* VM specific implementation of the Isolate class.
@@ -304,9 +304,9 @@
this.isolatedStaticsTable = new VmIsolatedStatics(VmMagic.currentProcessor().getIsolatedStatics(),
arch, new Unsafe.UnsafeObjectResolver());
this.creator = currentIsolate();
- if(getRoot().executor == null && isRoot()) {
+ if (getRoot().executor == null && isRoot()) {
//initialize the root executor on the creation of the first child
- getRoot().invokeAndWait(new Runnable(){
+ getRoot().invokeAndWait(new Runnable() {
public void run() {
//org.jnode.vm.Unsafe.debug("Root executor ready\n");
}
@@ -418,7 +418,7 @@
//todo add similar checks to other exit modes too
synchronized (this) {
- if(!this.state.equals(State.STARTED))
+ if (!this.state.equals(State.STARTED))
return;
}
@@ -463,7 +463,7 @@
Thread thread = ta[i];
if (current != thread) {
thread.getVmThread().stopForced(null);
- } else {
+ } else {
found = true;
}
}
@@ -497,7 +497,7 @@
this.exitCode = status;
}
- if(vmThread.getName().indexOf("-AWT-stopper") > - 1) {
+ if (vmThread.getName().indexOf("-AWT-stopper") > -1) {
doExit();
} else {
disposeAppContext(true);
@@ -558,7 +558,7 @@
private void doExit() {
try {
- if(!threadGroup.isDestroyed())
+ if (!threadGroup.isDestroyed())
threadGroup.destroy();
} catch (Throwable t) {
t.printStackTrace();
@@ -714,28 +714,28 @@
*/
// public void invokeAndWait(final Runnable task) {
- //TODO implement VmIsolate.invokeAndWait(Runnable)
- /*
- if(this == StaticData.rootIsolate){
- task.run();
- return;
- }
+ //TODO implement VmIsolate.invokeAndWait(Runnable)
+ /*
+ if(this == StaticData.rootIsolate){
+ task.run();
+ return;
+ }
- synchronized(taskSync){
- taskList.add(task);
- taskSync.notifyAll();
- }
+ synchronized(taskSync){
+ taskList.add(task);
+ taskSync.notifyAll();
+ }
- synchronized(task){
- while(taskList.contains(task)){
- try {
- task.wait();
- }catch(InterruptedException e){
- //
- }
+ synchronized(task){
+ while(taskList.contains(task)){
+ try {
+ task.wait();
+ }catch(InterruptedException e){
+ //
}
}
- */
+ }
+ */
// }
/*
private class TaskExecutor implements Runnable{
@@ -780,14 +780,14 @@
* @param task the task as a Runnable object
*/
public synchronized void invokeAndWait(final Runnable task) {
- if(executor == null) {
+ if (executor == null) {
executor = java.util.concurrent.Executors.newSingleThreadExecutor(new IsolateThreadFactory2(this));
}
- if(task == null)
+ if (task == null)
return;
-
+
try {
- if(executor.submit(task).get() != null) {
+ if (executor.submit(task).get() != null) {
throw new RuntimeException("Execution failed!");
}
} catch (Exception x) {
@@ -802,11 +802,11 @@
*/
public synchronized void invokeLater(final Runnable task) {
org.jnode.vm.Unsafe.debug("invokeLater Called - 0\n");
- if(executor == null) {
+ if (executor == null) {
executor = java.util.concurrent.Executors.newSingleThreadExecutor(new IsolateThreadFactory(this));
org.jnode.vm.Unsafe.debug("invokeAndWait executor created - 0\n");
}
- if(task == null)
+ if (task == null)
return;
try {
@@ -817,28 +817,28 @@
}
}
- boolean isEDT(){
- if(appContext == null)
+ boolean isEDT() {
+ if (appContext == null)
return false;
try {
Object eq = appContext.getClass().getMethod("get", Object.class).
invoke(appContext, appContext.getClass().getField("EVENT_QUEUE_KEY").get(null));
- if(eq == null)
+ if (eq == null)
return false;
org.jnode.vm.Unsafe.debug("isEDT - 1\n");
Object t = eq.getClass().getField("dispatchThread").get(eq);
- if(t == null)
+ if (t == null)
return false;
org.jnode.vm.Unsafe.debug("isEDT edt=" + t + "\n");
org.jnode.vm.Unsafe.debug("isEDT currenThread=" + Thread.currentThread() + "\n");
return t == Thread.currentThread();
- }catch (Exception x) {
+ } catch (Exception x) {
throw new RuntimeException(x);
}
/*
@@ -850,13 +850,13 @@
}
*/
- // return false;
- }
+ // return false;
+ }
private Object appContext;
private void disposeAppContext(boolean intraIsolate) {
- if(appSupport != null) {
+ if (appSupport != null) {
appSupport.stop(intraIsolate);
} else {
stopAllThreads();
@@ -864,7 +864,6 @@
}
/**
- *
* @param intraIsolate
* @deprecated
*/
@@ -879,10 +878,10 @@
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 000\n");
org.jnode.vm.Unsafe.debugStackTrace();
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 000 " + intraIsolate + "\n");
- if(appContext != null) {
+ if (appContext != null) {
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0001\n");
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0002\n");
- if(intraIsolate && is_edt) {
+ if (intraIsolate && is_edt) {
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0003\n");
Thread t = new Thread(new Runnable() {
public void run() {
@@ -906,16 +905,18 @@
} else {
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0004\n");
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 0\n");
- getRoot().invokeAndWait(new Runnable(){
+ getRoot().invokeAndWait(new Runnable() {
public void run() {
try {
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 1\n");
org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext: " + appContext + "\n");
- org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext.getClass(): " + appContext.getClass() + "\n");
- org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext.getClass().dispose: " + appContext.getClass().getMethod("dispose") + "\n");
+ org.jnode.vm.Unsafe.debug(
+ "disposeAppContextCalled appcontext.getClass(): " + appContext.getClass() + "\n");
+ org.jnode.vm.Unsafe.debug("disposeAppContextCalled appcontext.getClass().dispose: " +
+ appContext.getClass().getMethod("dispose") + "\n");
appContext.getClass().getMethod("dispose").invoke(appContext);
org.jnode.vm.Unsafe.debug("disposeAppContextCalled - 2\n");
- }catch (Exception x) {
+ } catch (Exception x) {
x.printStackTrace();
}
}
@@ -1171,7 +1172,7 @@
}
public ThreadGroup getThreadGroup() {
- if(threadGroup == null) {
+ if (threadGroup == null) {
throw new IllegalStateException("Isolate not available");
}
return threadGroup;
@@ -1182,6 +1183,7 @@
@SharedStatics
private static class AppSupport {
private static boolean awtSupport;
+
static {
try {
Class.forName("java.awt.Toolkit");
@@ -1199,7 +1201,7 @@
}
boolean isAWTReady() {
- if(!awtSupport)
+ if (!awtSupport)
return false;
try {
@@ -1210,7 +1212,7 @@
}
void start() throws Exception {
- if(isAWTReady()) {
+ if (isAWTReady()) {
synchronized (this) {
appContext = Class.forName("sun.awt.SunToolkit").getMethod("createNewAppContext").invoke(null);
}
@@ -1219,91 +1221,91 @@
void stop(boolean intraIsolate) {
boolean done = false;
- if(awtSupport) {
+ if (awtSupport) {
synchronized (this) {
- if(appContext != null) {
+ if (appContext != null) {
disposeAppContext(intraIsolate);
done = true;
}
}
}
- if(!done) {
+ if (!done) {
vmIsolate.stopAllThreads();
vmIsolate.doExit();
}
}
- boolean isEDT(){
- if(appContext == null)
- return false;
+ boolean isEDT() {
+ if (appContext == null)
+ return false;
- try {
- Object eq = appContext.getClass().getMethod("get", Object.class).
- invoke(appContext, appContext.getClass().getField("EVENT_QUEUE_KEY").get(null));
- if(eq == null)
- return false;
+ try {
+ Object eq = appContext.getClass().getMethod("get", Object.class).
+ invoke(appContext, appContext.getClass().getField("EVENT_QUEUE_KEY").get(null));
+ if (eq == null)
+ return false;
- Object t = eq.getClass().getField("dispatchThread").get(eq);
- if(t == null)
- return false;
+ Object t = eq.getClass().getField("dispatchThread").get(eq);
+ if (t == null)
+ return false;
- return t == Thread.currentThread();
- }catch (Exception x) {
- throw new RuntimeException(x);
+ return t == Thread.currentThread();
+ } catch (Exception x) {
+ throw new RuntimeException(x);
+ }
+ /*
+ try {
+ return (Boolean) Class.forName("java.awt.EventQueue").
+ getMethod("isDispatchThread").invoke(null);
+ } catch (Exception x) {
+ throw new RuntimeException(x);
+
+ }
+ */
+ // return false;
}
- /*
- try {
- return (Boolean) Class.forName("java.awt.EventQueue").
- getMethod("isDispatchThread").invoke(null);
- } catch (Exception x) {
- throw new RuntimeException(x);
- }
- */
- // return false;
- }
-
- private void disposeAppContext(boolean intraIsolate) {
- final Object appContext;
- final boolean is_edt;
- synchronized (this) {
- is_edt = isEDT();
- appContext = this.appContext;
- this.appContext = null;
- }
- if(appContext != null) {
- if(intraIsolate && is_edt) {
- Thread t = new Thread(new Runnable() {
- public void run() {
- getRoot().invokeAndWait(new Runnable() {
- public void run() {
- try {
- appContext.getClass().getMethod("dispose").invoke(appContext);
- } catch (Exception x) {
- x.printStackTrace();
+ private void disposeAppContext(boolean intraIsolate) {
+ final Object appContext;
+ final boolean is_edt;
+ synchronized (this) {
+ is_edt = isEDT();
+ appContext = this.appContext;
+ this.appContext = null;
+ }
+ if (appContext != null) {
+ if (intraIsolate && is_edt) {
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ getRoot().invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ appContext.getClass().getMethod("dispose").invoke(appContext);
+ } catch (Exception x) {
+ x.printStackTrace();
+ }
}
+ });
+ vmIsolate.stopAllThreads();
+ vmIsolate.doExit();
+ }
+ }, "isolate-" + vmIsolate.getId() + "-AWT-stopper");
+ t.start();
+ } else {
+ getRoot().invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ appContext.getClass().getMethod("dispose").invoke(appContext);
+ } catch (Exception x) {
+ x.printStackTrace();
}
- });
- vmIsolate.stopAllThreads();
- vmIsolate.doExit();
- }
- }, "isolate-" + vmIsolate.getId() + "-AWT-stopper");
- t.start();
- } else {
- getRoot().invokeAndWait(new Runnable(){
- public void run() {
- try {
- appContext.getClass().getMethod("dispose").invoke(appContext);
- }catch (Exception x) {
- x.printStackTrace();
}
- }
- });
- vmIsolate.stopAllThreads();
+ });
+ vmIsolate.stopAllThreads();
+ }
}
}
}
- }
}
Modified: trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java 2008-11-17 13:46:59 UTC (rev 4706)
+++ trunk/core/src/core/org/jnode/vm/scheduler/Monitor.java 2008-11-17 13:53:52 UTC (rev 4707)
@@ -556,15 +556,15 @@
@Inline
private void addToOwner() {
Monitor lom = owner.getLastOwnedMonitor();
- if(lom == null) {
+ if (lom == null) {
//the first monitor
owner.setLastOwnedMonitor(this);
} else {
- if(lom.owner != this.owner) {
+ if (lom.owner != this.owner) {
//todo error
return;
} else {
- if(lom == this) {
+ if (lom == this) {
//no need to add it
return;
} else {
@@ -578,16 +578,16 @@
@Inline
private void dropFromOwner() {
- if(owner == null) {
+ if (owner == null) {
//error
return;
}
Monitor lom = owner.getLastOwnedMonitor();
- if(lom == null)
+ if (lom == null)
return;
- if(lom != this)
+ if (lom != this)
return;
owner.setLastOwnedMonitor(lom.previous);
Modified: trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java 2008-11-17 13:46:59 UTC (rev 4706)
+++ trunk/core/src/core/org/jnode/vm/scheduler/MonitorManager.java 2008-11-17 13:53:52 UTC (rev 4707)
@@ -102,7 +102,7 @@
// thin lock owned by another thread.
int ownerId = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.THREAD_ID_MASK)).toInt();
VmThread thread = VmMagic.currentProcessor().getScheduler().getThreadById(ownerId);
- if(thread == null) {
+ if (thread == null) {
//the owner of the lock was destroyed
//aquire the lock in fast fashion
statusPtr.store(statusFlags.or(tid));
@@ -283,7 +283,7 @@
int lockcount = 1 + oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.LOCK_COUNT_MASK)).
rshl(ObjectFlags.LOCK_COUNT_SHIFT).toInt();
int ownerId = oldlockword.and(Word.fromIntZeroExtend(ObjectFlags.THREAD_ID_MASK)).toInt();
- if(thread == null) {
+ if (thread == null) {
thread = VmMagic.currentProcessor().getScheduler().getThreadById(ownerId);
}
m.initialize(thread, lockcount);
Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-11-17 13:46:59 UTC (rev 4706)
+++ trunk/core/src/core/org/jnode/vm/scheduler/VmThread.java 2008-11-17 13:53:52 UTC (rev 4707)
@@ -440,7 +440,7 @@
private final void doStop() {
//release monitors
Monitor lom = lastOwnedMonitor;
- while(lom != null) {
+ while (lom != null) {
Monitor prev = lom.getPrevious();
lom.release(this);
if (prev == lom)
Modified: trunk/shell/src/shell/org/jnode/shell/help/EnhancedHelp.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/help/EnhancedHelp.java 2008-11-17 13:46:59 UTC (rev 4706)
+++ trunk/shell/src/shell/org/jnode/shell/help/EnhancedHelp.java 2008-11-17 13:53:52 UTC (rev 4707)
@@ -18,7 +18,7 @@
* 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.shell.help;
+package org.jnode.shell.help;
import java.io.PrintWriter;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|