From: Frederic Suter Date: Mon, 20 Jun 2016 19:43:27 +0000 (+0200) Subject: a few smells in java X-Git-Tag: v3_14~925 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b71d1231ebd64aa1f1451a900e564a518f1e40be?ds=sidebyside a few smells in java --- diff --git a/examples/java/app/bittorrent/Main.java b/examples/java/app/bittorrent/Main.java index 021b1c54a8..8c7fb2cd22 100644 --- a/examples/java/app/bittorrent/Main.java +++ b/examples/java/app/bittorrent/Main.java @@ -18,7 +18,7 @@ class Main{ Msg.init(args); if(args.length < 2) { Msg.info("Usage : Bittorrent platform_file deployment_file"); - Msg.info("example : Bittorrent ../platforms/platform.xml bittorrent.xml"); + Msg.info("example : Bittorrent ../platforms/cluster.xml bittorrent.xml"); System.exit(1); } @@ -27,6 +27,6 @@ class Main{ Msg.deployApplication(args[1]); /* execute the simulation. */ - Msg.run(); + Msg.run(); } } diff --git a/examples/java/app/masterworker/Worker.java b/examples/java/app/masterworker/Worker.java index 4236ebdb55..dc7d44fb96 100644 --- a/examples/java/app/masterworker/Worker.java +++ b/examples/java/app/masterworker/Worker.java @@ -31,7 +31,7 @@ public class Worker extends Process { while(true) { Task task = Task.receive("worker_"+num); - if (task.getName().equals("finalize")) { + if ("finalize".equals(task.getName())) { break; } Msg.info("Received \"" + task.getName() + "\". Processing it."); diff --git a/examples/java/dht/kademlia/Bucket.java b/examples/java/dht/kademlia/Bucket.java index 51f6712b3f..1abceb15f0 100644 --- a/examples/java/dht/kademlia/Bucket.java +++ b/examples/java/dht/kademlia/Bucket.java @@ -12,7 +12,7 @@ public class Bucket { private int id; public Bucket(int id) { - this.nodes = new ArrayList(); + this.nodes = new ArrayList<>(); this.id = id; } @@ -46,8 +46,8 @@ public class Bucket { /* Add the content of the bucket into a answer object. */ public void addToAnswer(Answer answer, int destination) { - for (int id : this.nodes) { - answer.getNodes().add(new Contact(id,id ^ destination)); + for (int nodeId : this.nodes) { + answer.getNodes().add(new Contact(nodeId,nodeId ^ destination)); } } diff --git a/teshsuite/java/SemaphoreGC/SemaphoreGC.java b/teshsuite/java/SemaphoreGC/SemaphoreGC.java index 84d4f18a96..3939f28401 100644 --- a/teshsuite/java/SemaphoreGC/SemaphoreGC.java +++ b/teshsuite/java/SemaphoreGC/SemaphoreGC.java @@ -24,7 +24,7 @@ class SemCreator extends Process { Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each"); for(j = 1; j <= 50; j++) { sem = new Semaphore(0); - waitFor(10); + waitFor(10); System.gc(); } Msg.info("It worked, we survived. The test is passed."); @@ -32,6 +32,10 @@ class SemCreator extends Process { } public class SemaphoreGC { + private SemaphoreGC() { + throw new IllegalAccessError("Utility class"); + } + public static void main(String[] args) throws Exception { Msg.init(args); if (args.length < 1) {