This is the mail archive of the
mauve-patches@sources.redhat.com
mailing list for the Mauve project.
java.lang.Thread.priority patch
- From: Ingo Prötel <proetel at aicas dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Wed, 13 Aug 2003 15:20:28 +0200
- Subject: java.lang.Thread.priority patch
Hi;
I would like to propose the attached patch.
The background for this is that there are systems that allow for more
than ten priorities. But since javac in-lines constants, these systems
cannot change Thread.MAX_PRIORITY to reflect the actual max priority of
the system. My patch would allow such systems to override the
getMaxPriority of ThreadGroup. I have checked with kissme that this
change should not affect 'normal' VMs.
Thanks.
--ingo
diff -Naur mauve.org/gnu/testlet/java/lang/Thread/priority.java Mauve/gnu/testlet/java/lang/Thread/priority.java
--- mauve.org/gnu/testlet/java/lang/Thread/priority.java 2002-10-05 23:46:07.000000000 +0200
+++ Mauve/gnu/testlet/java/lang/Thread/priority.java 2003-08-13 15:13:19.000000000 +0200
@@ -27,6 +27,20 @@
public class priority implements Testlet, Runnable
{
+ static final int max_priority;
+
+ static
+ {
+ // asking the ThreadGroup for the max priority allows systems that support
+ // a higher max priority (e.g. real-time implementations)to pass this test
+ ThreadGroup group = Thread.currentThread().getThreadGroup();
+ while(group.getParent() != null)
+ {
+ group = group.getParent();
+ }
+ max_priority = group.getMaxPriority();
+ }
+
private static TestHarness harness;
private void test_set_prio(Thread t, String test_name)
@@ -75,14 +89,14 @@
illegal_exception = false;
try
{
- t.setPriority(Thread.MAX_PRIORITY+1);
+ t.setPriority(max_priority+1);
}
catch (IllegalArgumentException iae)
{
illegal_exception = true;
}
harness.check(illegal_exception,
- test_name + " cannot set prio to more then MAX_PRIORITY");
+ test_name + " cannot set prio to more then the max priority of the system");
harness.check(t.getPriority() == Thread.NORM_PRIORITY,
test_name + " prio doesn't change when set to illegal max");
}