Check-in [c07a6ae36d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Throw the correct exception.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-midlevel
Files: files | file ages | folders
SHA1: c07a6ae36d0fae94d0bf1717b74391c9793cba2a
User & Date: stephanie.gawroriski 2020-06-30 01:35:31
Context
2020-06-30
01:55
Some MLE call corrections; Enable JUnit XML and HTML reports in the tests (if this has an effect). check-in: 847b28b792 user: stephanie.gawroriski tags: wip-midlevel
01:35
Throw the correct exception. check-in: c07a6ae36d user: stephanie.gawroriski tags: wip-midlevel
01:28
More test fixes and functionality; Cleanup threads which have been terminated; Hide the terminated variable; Change order of thread initialization, enter main then create the thread instance so we are not quickly terminated this is so that threads are only terminated once. check-in: b3686a37ce user: stephanie.gawroriski tags: wip-midlevel
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/MLEThread.java.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
...
409
410
411
412
413
414
415

416
417
418
419
420
421
422
423
424

425
426
427
428
429
430
431
432
...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

import cc.squirreljme.jvm.mle.ThreadShelf;
import cc.squirreljme.jvm.mle.brackets.VMThreadBracket;
import cc.squirreljme.jvm.mle.exceptions.MLECallError;
import cc.squirreljme.vm.springcoat.brackets.VMThreadObject;
import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * Functions for {@link ThreadShelf}.
................................................................................
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int ms = (int)__args[0];
			int ns = (int)__args[1];
			
			if (ms < 0 || ns < 0 || ns > 1000000000)
				throw new MLECallError("Out of range time.");
			
			if (ms == 0 && ns == 0)
				Thread.yield();
			else
				try
				{
					Thread.sleep(ms, ns);
................................................................................
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			SpringThread thread = MLEThread.__vmThread(__args[0]).getThread();
			int priority = (int)__args[1];
			
			if (priority < Thread.MIN_PRIORITY ||
				priority > Thread.MAX_PRIORITY)

				throw new MLECallError("Thread priority out of bounds.");
			
			// Try to set the priority
			try
			{
				thread._worker.setPriority(priority);
			}
			catch (IllegalArgumentException|SecurityException e)
			{

				throw new MLECallError("Could not set priority.", e);
			}
			
			return null;
		}
	}, 
	
	/** {@link ThreadShelf#vmThreadStart(VMThreadBracket)}. */
................................................................................
		@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int ms = (int)__args[0];
			
			if (ms < 0)
				throw new MLECallError("Negative milliseconds");
			
			// Waiting for nothing? just give up our slice
			if (ms == 0)
			{
				Thread.yield();
				return false;
			}







<







 







|







 







>
|








>
|







 







|







7
8
9
10
11
12
13

14
15
16
17
18
19
20
...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
...
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.vm.springcoat;

import cc.squirreljme.jvm.mle.ThreadShelf;
import cc.squirreljme.jvm.mle.brackets.VMThreadBracket;

import cc.squirreljme.vm.springcoat.brackets.VMThreadObject;
import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;
import net.multiphasicapps.classfile.ClassName;
import net.multiphasicapps.classfile.MethodNameAndType;

/**
 * Functions for {@link ThreadShelf}.
................................................................................
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int ms = (int)__args[0];
			int ns = (int)__args[1];
			
			if (ms < 0 || ns < 0 || ns > 1000000000)
				throw new SpringMLECallError("Out of range time.");
			
			if (ms == 0 && ns == 0)
				Thread.yield();
			else
				try
				{
					Thread.sleep(ms, ns);
................................................................................
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			SpringThread thread = MLEThread.__vmThread(__args[0]).getThread();
			int priority = (int)__args[1];
			
			if (priority < Thread.MIN_PRIORITY ||
				priority > Thread.MAX_PRIORITY)
				throw new SpringMLECallError(
					"Thread priority out of range.");
			
			// Try to set the priority
			try
			{
				thread._worker.setPriority(priority);
			}
			catch (IllegalArgumentException|SecurityException e)
			{
				throw new SpringMLECallError(
					"Could not set priority.", e);
			}
			
			return null;
		}
	}, 
	
	/** {@link ThreadShelf#vmThreadStart(VMThreadBracket)}. */
................................................................................
		@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int ms = (int)__args[0];
			
			if (ms < 0)
				throw new SpringMLECallError("Negative milliseconds");
			
			// Waiting for nothing? just give up our slice
			if (ms == 0)
			{
				Thread.yield();
				return false;
			}