From d2990e6ae897aeb38681ef24acfa01935acf8354 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Thu, 23 Jun 2016 10:52:08 +0200 Subject: [PATCH] modifiers in right order remove useless imports remove empty statements make constant static --- examples/java/app/bittorrent/Peer.java | 11 ++--- examples/java/app/centralizedmutex/Node.java | 2 +- examples/java/app/masterworker/Master.java | 2 +- examples/java/async/dsend/Receiver.java | 2 - examples/java/async/dsend/Sender.java | 2 - examples/java/cloud/migration/Main.java | 2 - .../java/cloud/migration/TestHostOnOff.java | 2 - examples/java/dht/chord/Common.java | 20 ++++---- examples/java/dht/kademlia/Common.java | 24 +++++----- examples/java/dht/kademlia/Node.java | 6 ++- .../java/process/suspend/DreamMaster.java | 1 - examples/java/trace/pingpong/Receiver.java | 5 +- src/bindings/java/org/simgrid/msg/As.java | 3 +- src/bindings/java/org/simgrid/msg/File.java | 6 +-- src/bindings/java/org/simgrid/msg/Host.java | 10 ++-- src/bindings/java/org/simgrid/msg/Msg.java | 4 +- .../java/org/simgrid/msg/Process.java | 2 +- .../java/org/simgrid/msg/Storage.java | 6 +-- .../java/org/simgrid/trace/Trace.java | 48 +++++++++---------- 19 files changed, 73 insertions(+), 85 deletions(-) diff --git a/examples/java/app/bittorrent/Peer.java b/examples/java/app/bittorrent/Peer.java index b7ce0c3899..f20881b15b 100644 --- a/examples/java/app/bittorrent/Peer.java +++ b/examples/java/app/bittorrent/Peer.java @@ -426,9 +426,9 @@ public class Peer extends Process { } else { //Random optimistic unchoking if (round == 0) { - int j = 0, i; + int j = 0; do { - i = 0; + int i = 0; int idChosen = stream.randInt(0,peers.size() - 1); for (Connection connection : peers.values()) { if (i == idChosen) { @@ -519,10 +519,9 @@ public class Peer extends Process { return; } for (Integer piece : currentPieces) { - //Getting the block to send. - int blockIndex = -1, blockLength = 0; - blockIndex = getFirstBlock(piece); - blockLength = Common.PIECES_BLOCKS - blockIndex ; + //Getting the block to send. + int blockIndex = getFirstBlock(piece); + int blockLength = Common.PIECES_BLOCKS - blockIndex ; blockLength = blockLength > Common.BLOCKS_REQUESTED ? Common.BLOCKS_REQUESTED : blockLength; if (remotePeer.bitfield[piece] == '1') { sendRequest(remotePeer.mailbox, piece, blockIndex, blockLength); diff --git a/examples/java/app/centralizedmutex/Node.java b/examples/java/app/centralizedmutex/Node.java index 511a95d96a..6d9a5daa46 100644 --- a/examples/java/app/centralizedmutex/Node.java +++ b/examples/java/app/centralizedmutex/Node.java @@ -18,7 +18,7 @@ public class Node extends Process { } public void request(double CStime) throws MsgException { RequestTask req = new RequestTask(getName()); - GrantTask grant= new GrantTask();; + GrantTask grant= new GrantTask(); Msg.info("Send a request to the coordinator"); req.send("coordinator"); Msg.info("Wait for a grant from the coordinator"); diff --git a/examples/java/app/masterworker/Master.java b/examples/java/app/masterworker/Master.java index 08abb74a34..6de1072d35 100644 --- a/examples/java/app/masterworker/Master.java +++ b/examples/java/app/masterworker/Master.java @@ -11,7 +11,7 @@ import org.simgrid.msg.Host; import org.simgrid.msg.Msg; import org.simgrid.msg.MsgException; import org.simgrid.msg.Task; -import org.simgrid.msg.Process;; +import org.simgrid.msg.Process; public class Master extends Process { public Master(Host host, String name, String[]args) { diff --git a/examples/java/async/dsend/Receiver.java b/examples/java/async/dsend/Receiver.java index 4f6c3f0a9d..162a15ee06 100644 --- a/examples/java/async/dsend/Receiver.java +++ b/examples/java/async/dsend/Receiver.java @@ -6,12 +6,10 @@ package async.dsend; import org.simgrid.msg.Msg; -import org.simgrid.msg.Comm; import org.simgrid.msg.Host; import org.simgrid.msg.Task; import org.simgrid.msg.Process; import org.simgrid.msg.HostFailureException; -import org.simgrid.msg.TaskCancelledException; import org.simgrid.msg.TimeoutException; import org.simgrid.msg.TransferFailureException; diff --git a/examples/java/async/dsend/Sender.java b/examples/java/async/dsend/Sender.java index 03e3f7a801..ea14a66178 100644 --- a/examples/java/async/dsend/Sender.java +++ b/examples/java/async/dsend/Sender.java @@ -5,10 +5,8 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ package async.dsend; -import java.util.ArrayList; import org.simgrid.msg.Msg; -import org.simgrid.msg.Comm; import org.simgrid.msg.Host; import org.simgrid.msg.Task; import org.simgrid.msg.Process; diff --git a/examples/java/cloud/migration/Main.java b/examples/java/cloud/migration/Main.java index 2ae9be046c..b03c4b465a 100644 --- a/examples/java/cloud/migration/Main.java +++ b/examples/java/cloud/migration/Main.java @@ -7,8 +7,6 @@ package cloud.migration; import org.simgrid.msg.Msg; -import org.simgrid.msg.Host; -import org.simgrid.msg.HostNotFoundException; import org.simgrid.msg.MsgException; public class Main { diff --git a/examples/java/cloud/migration/TestHostOnOff.java b/examples/java/cloud/migration/TestHostOnOff.java index 5fccb0bd75..5e8246f72a 100644 --- a/examples/java/cloud/migration/TestHostOnOff.java +++ b/examples/java/cloud/migration/TestHostOnOff.java @@ -6,8 +6,6 @@ package cloud.migration; -import java.util.Random; - import org.simgrid.msg.*; import org.simgrid.msg.Process; diff --git a/examples/java/dht/chord/Common.java b/examples/java/dht/chord/Common.java index 66c9109a49..08e312666c 100644 --- a/examples/java/dht/chord/Common.java +++ b/examples/java/dht/chord/Common.java @@ -7,17 +7,17 @@ package dht.chord; public class Common { - public final static int COMM_SIZE = 10; - public final static int COMP_SIZE = 0; + public static final int COMM_SIZE = 10; + public static final int COMP_SIZE = 0; - public final static int NB_BITS = 24; - public final static int NB_KEYS = 16777216; - public final static int TIMEOUT = 50; - public final static int MAX_SIMULATION_TIME = 1000; - public final static int PERIODIC_STABILIZE_DELAY = 20; - public final static int PERIODIC_FIX_FINGERS_DELAY = 120; - public final static int PERIODIC_CHECK_PREDECESSOR_DELAY = 120; - public final static int PERIODIC_LOOKUP_DELAY = 10; + public static final int NB_BITS = 24; + public static final int NB_KEYS = 16777216; + public static final int TIMEOUT = 50; + public static final int MAX_SIMULATION_TIME = 1000; + public static final int PERIODIC_STABILIZE_DELAY = 20; + public static final int PERIODIC_FIX_FINGERS_DELAY = 120; + public static final int PERIODIC_CHECK_PREDECESSOR_DELAY = 120; + public static final int PERIODIC_LOOKUP_DELAY = 10; private Common() { throw new IllegalAccessError("Utility class"); } diff --git a/examples/java/dht/kademlia/Common.java b/examples/java/dht/kademlia/Common.java index 890899f687..381cf386aa 100644 --- a/examples/java/dht/kademlia/Common.java +++ b/examples/java/dht/kademlia/Common.java @@ -8,27 +8,27 @@ package dht.kademlia; public class Common { /* Common constants used all over the simulation */ - public final static int COMM_SIZE = 1; - public final static int COMP_SIZE = 0; + public static final int COMM_SIZE = 1; + public static final int COMP_SIZE = 0; - public final static int RANDOM_LOOKUP_INTERVAL = 100; + public static final int RANDOM_LOOKUP_INTERVAL = 100; - public final static int alpha = 3; + public static final int alpha = 3; - public final static int IDENTIFIER_SIZE = 32; + public static final int IDENTIFIER_SIZE = 32; /* Maximum size of the buckets */ - public final static int BUCKET_SIZE = 20; + public static final int BUCKET_SIZE = 20; /* Maximum number of trials for the "JOIN" request */ - public final static int MAX_JOIN_TRIALS = 4; + public static final int MAX_JOIN_TRIALS = 4; /* Timeout for a "FIND_NODE" request to a node */ - public final static int FIND_NODE_TIMEOUT = 10; + public static final int FIND_NODE_TIMEOUT = 10; /* Global timeout for a FIND_NODE request */ - public final static int FIND_NODE_GLOBAL_TIMEOUT = 50; + public static final int FIND_NODE_GLOBAL_TIMEOUT = 50; /* Timeout for a "PING" request */ - public final static int PING_TIMEOUT = 35; + public static final int PING_TIMEOUT = 35; - public final static int MAX_STEPS = 10; - public final static int JOIN_BUCKETS_QUERIES = 1; + public static final int MAX_STEPS = 10; + public static final int JOIN_BUCKETS_QUERIES = 1; private Common() { throw new IllegalAccessError("Utility class"); } diff --git a/examples/java/dht/kademlia/Node.java b/examples/java/dht/kademlia/Node.java index 5b570ec166..25124b6408 100644 --- a/examples/java/dht/kademlia/Node.java +++ b/examples/java/dht/kademlia/Node.java @@ -153,12 +153,14 @@ public class Node extends Process { /* Send a request to find a node in the node's routing table. */ public boolean findNode(int destination, boolean counts) { - int queries, answers; + int queries; + int answers; int nodesAdded = 0; boolean destinationFound = false; int steps = 0; double timeBeginReceive; - double timeout, globalTimeout = Msg.getClock() + Common.FIND_NODE_GLOBAL_TIMEOUT; + double timeout; + double globalTimeout = Msg.getClock() + Common.FIND_NODE_GLOBAL_TIMEOUT; //Build a list of the closest nodes we already know. Answer nodeList = table.findClosest(destination); Msg.verb("Doing a FIND_NODE on " + destination); diff --git a/examples/java/process/suspend/DreamMaster.java b/examples/java/process/suspend/DreamMaster.java index 08459e4db5..d8013a5cd3 100644 --- a/examples/java/process/suspend/DreamMaster.java +++ b/examples/java/process/suspend/DreamMaster.java @@ -5,7 +5,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ package process.suspend; -import org.simgrid.msg.Host; import org.simgrid.msg.Msg; import org.simgrid.msg.Process; import org.simgrid.msg.MsgException; diff --git a/examples/java/trace/pingpong/Receiver.java b/examples/java/trace/pingpong/Receiver.java index 27716559d1..54f24df00f 100644 --- a/examples/java/trace/pingpong/Receiver.java +++ b/examples/java/trace/pingpong/Receiver.java @@ -5,7 +5,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ package trace.pingpong; -import org.simgrid.msg.Host; import org.simgrid.msg.Msg; import org.simgrid.msg.MsgException; import org.simgrid.msg.NativeException; @@ -15,8 +14,8 @@ import org.simgrid.msg.Process; import org.simgrid.trace.Trace; public class Receiver extends Process { - private final double commSizeLat = 1; - private final double commSizeBw = 100000000; + private static final double commSizeLat = 1; + private static final double commSizeBw = 100000000; public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{ super(hostname,name,args); diff --git a/src/bindings/java/org/simgrid/msg/As.java b/src/bindings/java/org/simgrid/msg/As.java index 16c6889b69..92ee06bc08 100644 --- a/src/bindings/java/org/simgrid/msg/As.java +++ b/src/bindings/java/org/simgrid/msg/As.java @@ -10,8 +10,7 @@ public class As { private long bind; - protected As() { - }; + protected As() {} @Override public String toString (){ diff --git a/src/bindings/java/org/simgrid/msg/File.java b/src/bindings/java/org/simgrid/msg/File.java index b1f13f9cb1..e37b1f4b17 100644 --- a/src/bindings/java/org/simgrid/msg/File.java +++ b/src/bindings/java/org/simgrid/msg/File.java @@ -7,9 +7,9 @@ package org.simgrid.msg; public class File { - public final int SEEK_SET = 0; - public final int SEEK_CUR = 1; - public final int SEEK_END = 2; + public static final int SEEK_SET = 0; + public static final int SEEK_CUR = 1; + public static final int SEEK_END = 2; /** * Represents the bind between the java comm and the * native C comm. You must never access it, since it is diff --git a/src/bindings/java/org/simgrid/msg/Host.java b/src/bindings/java/org/simgrid/msg/Host.java index 3dc1e5ecea..d4d336c72a 100644 --- a/src/bindings/java/org/simgrid/msg/Host.java +++ b/src/bindings/java/org/simgrid/msg/Host.java @@ -56,7 +56,7 @@ public class Host { protected Host() { this.bind = 0; this.data = null; - }; + } @Override public String toString (){ @@ -73,15 +73,15 @@ public class Host { * @exception HostNotFoundException if the name of the host is not valid. * NativeException if the native version of this method failed. */ - public native static Host getByName(String name) throws HostNotFoundException, NullPointerException; + public static native Host getByName(String name) throws HostNotFoundException, NullPointerException; /** Counts the installed hosts. */ - public native static int getCount(); + public static native int getCount(); /** Returns the host of the current process. */ - public native static Host currentHost(); + public static native Host currentHost(); /** Returns all hosts of the installed platform. */ - public native static Host[] all(); + public static native Host[] all(); /** * This static method sets a mailbox to receive in asynchronous mode. diff --git a/src/bindings/java/org/simgrid/msg/Msg.java b/src/bindings/java/org/simgrid/msg/Msg.java index 9c04644aed..b53f5b5f22 100644 --- a/src/bindings/java/org/simgrid/msg/Msg.java +++ b/src/bindings/java/org/simgrid/msg/Msg.java @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ package org.simgrid.msg; -import org.simgrid.NativeLib; - public final class Msg { @@ -63,7 +61,7 @@ public final class Msg { * @param args * @throws MsgException */ - static public void main(String[]args) throws MsgException { + public static void main(String[]args) throws MsgException { /* initialize the MSG simulation. Must be done before anything else (even logging). */ Msg.init(args); diff --git a/src/bindings/java/org/simgrid/msg/Process.java b/src/bindings/java/org/simgrid/msg/Process.java index d9b3b6e87e..d50a475b40 100644 --- a/src/bindings/java/org/simgrid/msg/Process.java +++ b/src/bindings/java/org/simgrid/msg/Process.java @@ -368,6 +368,6 @@ public abstract class Process implements Runnable { * * @return The count of the running processes */ - public native static int getCount(); + public static native int getCount(); } diff --git a/src/bindings/java/org/simgrid/msg/Storage.java b/src/bindings/java/org/simgrid/msg/Storage.java index b6953bc2ac..b4cac70932 100644 --- a/src/bindings/java/org/simgrid/msg/Storage.java +++ b/src/bindings/java/org/simgrid/msg/Storage.java @@ -25,7 +25,7 @@ public class Storage { protected Storage() { this.bind = 0; this.data = null; - }; + } @Override public String toString (){ @@ -43,7 +43,7 @@ public class Storage { * @exception StorageNotFoundException if the name of the storage is not valid. * @exception NativeException if the native version of this method failed. */ - public native static Storage getByName(String name) + public static native Storage getByName(String name) throws HostNotFoundException, NullPointerException, NativeException, StorageNotFoundException; /** @@ -104,7 +104,7 @@ public class Storage { * @return An array containing all the storages installed. * */ - public native static Storage[] all(); + public static native Storage[] all(); /** * Class initializer, to initialize various JNI stuff diff --git a/src/bindings/java/org/simgrid/trace/Trace.java b/src/bindings/java/org/simgrid/trace/Trace.java index 70cb9e03f9..9877a95d57 100644 --- a/src/bindings/java/org/simgrid/trace/Trace.java +++ b/src/bindings/java/org/simgrid/trace/Trace.java @@ -25,7 +25,7 @@ public final class Trace { * @param variable * @param color */ - public final static native void hostVariableDeclareWithColor (String variable, String color); + public final static native void hostVariableDeclareWithColor (String variable, String color); /** @@ -35,7 +35,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void hostVariableAdd (String host, String variable, double value); + public final static native void hostVariableAdd (String host, String variable, double value); /** * Subtract a value from a variable of a host. @@ -44,7 +44,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void hostVariableSub (String host, String variable, double value); + public final static native void hostVariableSub (String host, String variable, double value); /** * Set the value of a variable of a host at a given timestamp. @@ -54,7 +54,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void hostVariableSetWithTime (double time, String host, String variable, double value); + public final static native void hostVariableSetWithTime (double time, String host, String variable, double value); /** * Add a value to a variable of a host at a given timestamp. @@ -64,7 +64,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void hostVariableAddWithTime (double time, String host, String variable, double value); + public final static native void hostVariableAddWithTime (double time, String host, String variable, double value); /** * Subtract a value from a variable of a host at a given timestamp. @@ -74,7 +74,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void hostVariableSubWithTime (double time, String host, String variable, double value); + public final static native void hostVariableSubWithTime (double time, String host, String variable, double value); /** * Get declared user host variables. @@ -87,14 +87,14 @@ public final class Trace { * * @param variable */ - public final static native void linkVariableDeclare (String variable); + public final static native void linkVariableDeclare (String variable); /** * Declare a new user variable associated to links with a color. * @param variable * @param color */ - public final static native void linkVariableDeclareWithColor (String variable, String color); + public final static native void linkVariableDeclareWithColor (String variable, String color); /** * Set the value of a variable of a link. @@ -103,7 +103,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkVariableSet (String link, String variable, double value); + public final static native void linkVariableSet (String link, String variable, double value); /** * Add a value to a variable of a link. @@ -112,7 +112,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkVariableAdd (String link, String variable, double value); + public final static native void linkVariableAdd (String link, String variable, double value); /** * Subtract a value from a variable of a link. @@ -121,7 +121,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkVariableSub (String link, String variable, double value); + public final static native void linkVariableSub (String link, String variable, double value); /** * Set the value of a variable of a link at a given timestamp. @@ -131,7 +131,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkVariableSetWithTime (double time, String link, String variable, double value); + public final static native void linkVariableSetWithTime (double time, String link, String variable, double value); /** * Add a value to a variable of a link at a given timestamp. @@ -141,7 +141,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkVariableAddWithTime (double time, String link, String variable, double value); + public final static native void linkVariableAddWithTime (double time, String link, String variable, double value); /** @@ -152,7 +152,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkVariableSubWithTime (double time, String link, String variable, double value); + public final static native void linkVariableSubWithTime (double time, String link, String variable, double value); /** * Set the value of the variable present in the links connecting source and destination. @@ -162,7 +162,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkSrcDstVariableSet (String src, String dst, String variable, double value); + public final static native void linkSrcDstVariableSet (String src, String dst, String variable, double value); /** * Add a value to the variable present in the links connecting source and destination. @@ -172,7 +172,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkSrcDstVariableAdd (String src, String dst, String variable, double value); + public final static native void linkSrcDstVariableAdd (String src, String dst, String variable, double value); /** * Subtract a value from the variable present in the links connecting source and destination. @@ -182,7 +182,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkSrcDstVariableSub (String src, String dst, String variable, double value); + public final static native void linkSrcDstVariableSub (String src, String dst, String variable, double value); /** * Set the value of the variable present in the links connecting source and destination at a given timestamp. @@ -193,7 +193,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkSrcDstVariableSetWithTime (double time, String src, String dst, String variable, double value); + public final static native void linkSrcDstVariableSetWithTime (double time, String src, String dst, String variable, double value); /** * Add a value to the variable present in the links connecting source and destination at a given timestamp. @@ -204,7 +204,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkSrcdstVariableAddWithTime (double time, String src, String dst, String variable, double value); + public final static native void linkSrcdstVariableAddWithTime (double time, String src, String dst, String variable, double value); /** * Subtract a value from the variable present in the links connecting source and destination at a given timestamp. @@ -215,7 +215,7 @@ public final class Trace { * @param variable * @param value */ - public final static native void linkSrcDstVariableSubWithTime (double time, String src, String dst, String variable, double value); + public final static native void linkSrcDstVariableSubWithTime (double time, String src, String dst, String variable, double value); /** * Get declared user link variables. @@ -279,7 +279,7 @@ public final class Trace { * * @param variable */ - public final static native void hostVariableDeclare (String variable); + public final static native void hostVariableDeclare (String variable); /** @@ -289,14 +289,14 @@ public final class Trace { * @param variable * @param value */ - public final static native void hostVariableSet (String host, String variable, double value); + public final static native void hostVariableSet (String host, String variable, double value); /** * Declare a new user variable associated to VMs. * * @param variable */ - public final static native void vmVariableDeclare (String variable); + public final static native void vmVariableDeclare (String variable); /** @@ -306,5 +306,5 @@ public final class Trace { * @param variable * @param value */ - public final static native void vmVariableSet (String vm, String variable, double value); + public final static native void vmVariableSet (String vm, String variable, double value); } -- 2.20.1