forked from pmd/pmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pmd: reintroducing check whether multi threading is support (bugfix f…
…or 3565001) * created SystemUtils to check for multi-threading permission Revert "pmd: Remove hack related to multithreading in jdk5 with Eclipse - no longer relevant today" This reverts commit 720bb3d.
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
pmd/src/main/java/net/sourceforge/pmd/util/SystemUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html | ||
*/ | ||
package net.sourceforge.pmd.util; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
public final class SystemUtils { | ||
|
||
private SystemUtils() { | ||
// this is a utility class and cannot be instantiated | ||
} | ||
|
||
/** | ||
* Do we have proper permissions to use multithreading? | ||
*/ | ||
public static final boolean MT_SUPPORTED; | ||
static { | ||
boolean error = false; | ||
try { | ||
/* | ||
* ant task ran from Eclipse with jdk 1.5.0 raises an AccessControlException | ||
* when shutdown is called. Standalone pmd or ant from command line are fine. | ||
* | ||
* With jdk 1.6.0, ant task from Eclipse also works. | ||
* | ||
* Bugs related to this hack: | ||
* 3565001 | ||
* 1701832 | ||
*/ | ||
ExecutorService executor = Executors.newFixedThreadPool(1); | ||
executor.shutdown(); | ||
} catch (RuntimeException e) { | ||
error = true; | ||
System.err.println("Disabling multithreading - consider to upgrade to java 1.6"); | ||
System.err.println("See also: http://sourceforge.net/tracker/?func=detail&atid=479921&aid=1701832&group_id=56262"); | ||
} | ||
MT_SUPPORTED = !error; | ||
} | ||
} |