Added missing final modifiers.

This commit is contained in:
MobiusDev
2015-12-26 12:03:36 +00:00
parent cc92e5d062
commit e0d681a17e
974 changed files with 5919 additions and 5917 deletions

View File

@@ -50,7 +50,7 @@ public final class ComplexBlock implements IBlock
private int _getCellHeight(int geoX, int geoY)
{
short height = (short) (_getCellData(geoX, geoY) & 0x0FFF0);
final short height = (short) (_getCellData(geoX, geoY) & 0x0FFF0);
return height >> 1;
}
@@ -69,14 +69,14 @@ public final class ComplexBlock implements IBlock
@Override
public int getNextLowerZ(int geoX, int geoY, int worldZ)
{
int cellHeight = _getCellHeight(geoX, geoY);
final int cellHeight = _getCellHeight(geoX, geoY);
return cellHeight <= worldZ ? cellHeight : worldZ;
}
@Override
public int getNextHigherZ(int geoX, int geoY, int worldZ)
{
int cellHeight = _getCellHeight(geoX, geoY);
final int cellHeight = _getCellHeight(geoX, geoY);
return cellHeight >= worldZ ? cellHeight : worldZ;
}
}

View File

@@ -35,11 +35,11 @@ public class MultilayerBlock implements IBlock
*/
public MultilayerBlock(ByteBuffer bb)
{
int start = bb.position();
final int start = bb.position();
for (int blockCellOffset = 0; blockCellOffset < IBlock.BLOCK_CELLS; blockCellOffset++)
{
byte nLayers = bb.get();
final byte nLayers = bb.get();
if ((nLayers <= 0) || (nLayers > 125))
{
throw new RuntimeException("L2JGeoDriver: Geo file corrupted! Invalid layers count!");
@@ -55,24 +55,24 @@ public class MultilayerBlock implements IBlock
private short _getNearestLayer(int geoX, int geoY, int worldZ)
{
int startOffset = _getCellDataOffset(geoX, geoY);
byte nLayers = _data[startOffset];
int endOffset = startOffset + 1 + (nLayers * 2);
final int startOffset = _getCellDataOffset(geoX, geoY);
final byte nLayers = _data[startOffset];
final int endOffset = startOffset + 1 + (nLayers * 2);
// 1 layer at least was required on loading so this is set at least once on the loop below
int nearestDZ = 0;
short nearestData = 0;
for (int offset = startOffset + 1; offset < endOffset; offset += 2)
{
short layerData = _extractLayerData(offset);
int layerZ = _extractLayerHeight(layerData);
final short layerData = _extractLayerData(offset);
final int layerZ = _extractLayerHeight(layerData);
if (layerZ == worldZ)
{
// exact z
return layerData;
}
int layerDZ = Math.abs(layerZ - worldZ);
final int layerDZ = Math.abs(layerZ - worldZ);
if ((offset == (startOffset + 1)) || (layerDZ < nearestDZ))
{
nearestDZ = layerDZ;
@@ -85,7 +85,7 @@ public class MultilayerBlock implements IBlock
private int _getCellDataOffset(int geoX, int geoY)
{
int cellLocalOffset = ((geoX % IBlock.BLOCK_CELLS_X) * IBlock.BLOCK_CELLS_Y) + (geoY % IBlock.BLOCK_CELLS_Y);
final int cellLocalOffset = ((geoX % IBlock.BLOCK_CELLS_X) * IBlock.BLOCK_CELLS_Y) + (geoY % IBlock.BLOCK_CELLS_Y);
int cellDataOffset = 0;
// move index to cell, we need to parse on each request, OR we parse on creation and save indexes
for (int i = 0; i < cellLocalOffset; i++)
@@ -133,16 +133,16 @@ public class MultilayerBlock implements IBlock
@Override
public int getNextLowerZ(int geoX, int geoY, int worldZ)
{
int startOffset = _getCellDataOffset(geoX, geoY);
byte nLayers = _data[startOffset];
int endOffset = startOffset + 1 + (nLayers * 2);
final int startOffset = _getCellDataOffset(geoX, geoY);
final byte nLayers = _data[startOffset];
final int endOffset = startOffset + 1 + (nLayers * 2);
int lowerZ = Integer.MIN_VALUE;
for (int offset = startOffset + 1; offset < endOffset; offset += 2)
{
short layerData = _extractLayerData(offset);
final short layerData = _extractLayerData(offset);
int layerZ = _extractLayerHeight(layerData);
final int layerZ = _extractLayerHeight(layerData);
if (layerZ == worldZ)
{
// exact z
@@ -161,16 +161,16 @@ public class MultilayerBlock implements IBlock
@Override
public int getNextHigherZ(int geoX, int geoY, int worldZ)
{
int startOffset = _getCellDataOffset(geoX, geoY);
byte nLayers = _data[startOffset];
int endOffset = startOffset + 1 + (nLayers * 2);
final int startOffset = _getCellDataOffset(geoX, geoY);
final byte nLayers = _data[startOffset];
final int endOffset = startOffset + 1 + (nLayers * 2);
int higherZ = Integer.MAX_VALUE;
for (int offset = startOffset + 1; offset < endOffset; offset += 2)
{
short layerData = _extractLayerData(offset);
final short layerData = _extractLayerData(offset);
int layerZ = _extractLayerHeight(layerData);
final int layerZ = _extractLayerHeight(layerData);
if (layerZ == worldZ)
{
// exact z

View File

@@ -37,7 +37,7 @@ public final class Region implements IRegion
{
for (int blockOffset = 0; blockOffset < IRegion.REGION_BLOCKS; blockOffset++)
{
int blockType = bb.get();
final int blockType = bb.get();
switch (blockType)
{
case IBlock.TYPE_FLAT:

View File

@@ -52,7 +52,7 @@ public class JavaCompiler
public Map<String, byte[]> compile(String source, String fileName)
{
PrintWriter err = new PrintWriter(System.err);
final PrintWriter err = new PrintWriter(System.err);
return compile(source, fileName, err, null, null);
}
@@ -78,17 +78,17 @@ public class JavaCompiler
public Map<String, byte[]> compile(String fileName, String source, Writer err, String sourcePath, String classPath)
{
// to collect errors, warnings etc.
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
// create a new memory JavaFileManager
MemoryJavaFileManager manager = new MemoryJavaFileManager();
final MemoryJavaFileManager manager = new MemoryJavaFileManager();
// prepare the compilation unit
List<JavaFileObject> compUnits = new ArrayList<>(1);
final List<JavaFileObject> compUnits = new ArrayList<>(1);
compUnits.add(MemoryJavaFileManager.makeStringSource(fileName, source));
// javac options
List<String> options = new ArrayList<>();
final List<String> options = new ArrayList<>();
options.add("-warn:-enumSwitch");
options.add("-g");
options.add("-deprecation");
@@ -105,11 +105,11 @@ public class JavaCompiler
}
// create a compilation task
CompilationTask task = tool.getTask(err, manager, diagnostics, options, null, compUnits);
final CompilationTask task = tool.getTask(err, manager, diagnostics, options, null, compUnits);
if (!task.call())
{
PrintWriter perr = new PrintWriter(err);
final PrintWriter perr = new PrintWriter(err);
for (Diagnostic<?> diagnostic : diagnostics.getDiagnostics())
{
perr.println(diagnostic.getMessage(Locale.getDefault()));
@@ -118,7 +118,7 @@ public class JavaCompiler
return null;
}
Map<String, byte[]> classBytes = manager.getClassBytes();
final Map<String, byte[]> classBytes = manager.getClassBytes();
manager.close();
return classBytes;
}

View File

@@ -87,9 +87,9 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
{
if (_class == null)
{
Map<String, byte[]> classBytesCopy = new HashMap<>();
final Map<String, byte[]> classBytesCopy = new HashMap<>();
classBytesCopy.putAll(_classBytes);
MemoryClassLoader loader = new MemoryClassLoader(classBytesCopy, _classPath, JavaScriptEngine.getParentLoader(ctx));
final MemoryClassLoader loader = new MemoryClassLoader(classBytesCopy, _classPath, JavaScriptEngine.getParentLoader(ctx));
_class = JavaScriptEngine.parseMain(loader, ctx);
}
return JavaScriptEngine.evalClass(_class, ctx);
@@ -111,7 +111,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
@Override
public Object eval(String str, ScriptContext ctx) throws ScriptException
{
Class<?> clazz = parse(str, ctx);
final Class<?> clazz = parse(str, ctx);
return evalClass(clazz, ctx);
}
@@ -149,9 +149,9 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private Class<?> parse(String str, ScriptContext ctx) throws ScriptException
{
String fileName = getFileName(ctx);
String sourcePath = getSourcePath(ctx);
String classPath = getClassPath(ctx);
final String fileName = getFileName(ctx);
final String sourcePath = getSourcePath(ctx);
final String classPath = getClassPath(ctx);
Writer err = ctx.getErrorWriter();
if (err == null)
@@ -159,7 +159,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
err = new StringWriter();
}
Map<String, byte[]> classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
final Map<String, byte[]> classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
if (classBytes == null)
{
@@ -171,19 +171,19 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
}
// create a ClassLoader to load classes from MemoryJavaFileManager
MemoryClassLoader loader = new MemoryClassLoader(classBytes, classPath, getParentLoader(ctx));
final MemoryClassLoader loader = new MemoryClassLoader(classBytes, classPath, getParentLoader(ctx));
return parseMain(loader, ctx);
}
protected static Class<?> parseMain(MemoryClassLoader loader, ScriptContext ctx) throws ScriptException
{
String mainClassName = getMainClassName(ctx);
final String mainClassName = getMainClassName(ctx);
if (mainClassName != null)
{
try
{
Class<?> clazz = loader.load(mainClassName);
Method mainMethod = findMainMethod(clazz);
final Class<?> clazz = loader.load(mainClassName);
final Method mainMethod = findMainMethod(clazz);
if (mainMethod == null)
{
throw new ScriptException("no main method in " + mainClassName);
@@ -209,7 +209,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
}
// search for class with main method
Class<?> c = findMainClass(classes);
final Class<?> c = findMainClass(classes);
if (c != null)
{
return c;
@@ -217,7 +217,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
// if class with "main" method, then
// return first class
Iterator<Class<?>> itr = classes.iterator();
final Iterator<Class<?>> itr = classes.iterator();
if (itr.hasNext())
{
return itr.next();
@@ -227,9 +227,9 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private JavaCompiledScript compile(String str, ScriptContext ctx) throws ScriptException
{
String fileName = getFileName(ctx);
String sourcePath = getSourcePath(ctx);
String classPath = getClassPath(ctx);
final String fileName = getFileName(ctx);
final String sourcePath = getSourcePath(ctx);
final String classPath = getClassPath(ctx);
Writer err = ctx.getErrorWriter();
if (err == null)
@@ -237,7 +237,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
err = new StringWriter();
}
Map<String, byte[]> classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
final Map<String, byte[]> classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
if (classBytes == null)
{
if (err instanceof StringWriter)
@@ -255,10 +255,10 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
// find a public class with public static main method
for (Class<?> clazz : classes)
{
int modifiers = clazz.getModifiers();
final int modifiers = clazz.getModifiers();
if (Modifier.isPublic(modifiers))
{
Method mainMethod = findMainMethod(clazz);
final Method mainMethod = findMainMethod(clazz);
if (mainMethod != null)
{
return clazz;
@@ -270,7 +270,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
// has public static main method
for (Class<?> clazz : classes)
{
Method mainMethod = findMainMethod(clazz);
final Method mainMethod = findMainMethod(clazz);
if (mainMethod != null)
{
return clazz;
@@ -286,11 +286,11 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
{
try
{
Method mainMethod = clazz.getMethod("main", new Class[]
final Method mainMethod = clazz.getMethod("main", new Class[]
{
String[].class
});
int modifiers = mainMethod.getModifiers();
final int modifiers = mainMethod.getModifiers();
if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
{
return mainMethod;
@@ -307,11 +307,11 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
{
try
{
Method setCtxMethod = clazz.getMethod("setScriptContext", new Class[]
final Method setCtxMethod = clazz.getMethod("setScriptContext", new Class[]
{
ScriptContext.class
});
int modifiers = setCtxMethod.getModifiers();
final int modifiers = setCtxMethod.getModifiers();
if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
{
return setCtxMethod;
@@ -325,7 +325,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private static String getFileName(ScriptContext ctx)
{
int scope = ctx.getAttributesScope("javax.script.filename");
final int scope = ctx.getAttributesScope("javax.script.filename");
if (scope != -1)
{
return ctx.getAttribute("javax.script.filename", scope).toString();
@@ -342,10 +342,10 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private static String[] getArguments(ScriptContext ctx)
{
int scope = ctx.getAttributesScope(ARGUMENTS);
final int scope = ctx.getAttributesScope(ARGUMENTS);
if (scope != -1)
{
Object obj = ctx.getAttribute(ARGUMENTS, scope);
final Object obj = ctx.getAttribute(ARGUMENTS, scope);
if (obj instanceof String[])
{
return (String[]) obj;
@@ -359,7 +359,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private static String getSourcePath(ScriptContext ctx)
{
int scope = ctx.getAttributesScope(SOURCEPATH);
final int scope = ctx.getAttributesScope(SOURCEPATH);
if (scope != -1)
{
return ctx.getAttribute(SOURCEPATH).toString();
@@ -373,7 +373,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private static String getClassPath(ScriptContext ctx)
{
int scope = ctx.getAttributesScope(CLASSPATH);
final int scope = ctx.getAttributesScope(CLASSPATH);
if (scope != -1)
{
return ctx.getAttribute(CLASSPATH).toString();
@@ -392,7 +392,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
private static String getMainClassName(ScriptContext ctx)
{
int scope = ctx.getAttributesScope(MAINCLASS);
final int scope = ctx.getAttributesScope(MAINCLASS);
if (scope != -1)
{
return ctx.getAttribute(MAINCLASS).toString();
@@ -406,10 +406,10 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
protected static ClassLoader getParentLoader(ScriptContext ctx)
{
int scope = ctx.getAttributesScope(PARENTLOADER);
final int scope = ctx.getAttributesScope(PARENTLOADER);
if (scope != -1)
{
Object loader = ctx.getAttribute(PARENTLOADER);
final Object loader = ctx.getAttribute(PARENTLOADER);
if (loader instanceof ClassLoader)
{
return (ClassLoader) loader;
@@ -428,10 +428,10 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
}
try
{
boolean isPublicClazz = Modifier.isPublic(clazz.getModifiers());
final boolean isPublicClazz = Modifier.isPublic(clazz.getModifiers());
// find the setScriptContext method
Method setCtxMethod = findSetScriptContextMethod(clazz);
final Method setCtxMethod = findSetScriptContextMethod(clazz);
// call setScriptContext and pass current ctx variable
if (setCtxMethod != null)
{
@@ -447,7 +447,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
}
// find the main method
Method mainMethod = findMainMethod(clazz);
final Method mainMethod = findMainMethod(clazz);
if (mainMethod != null)
{
if (!isPublicClazz)
@@ -457,7 +457,7 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
}
// get "command line" args for the main method
String args[] = getArguments(ctx);
final String args[] = getArguments(ctx);
// call main method
mainMethod.invoke(null, new Object[]
@@ -479,8 +479,8 @@ public class JavaScriptEngine extends AbstractScriptEngine implements Compilable
// read a Reader fully and return the content as string
private String readFully(Reader reader) throws ScriptException
{
char[] arr = new char[8 * 1024]; // 8K at a time
StringBuilder buf = new StringBuilder();
final char[] arr = new char[8 * 1024]; // 8K at a time
final StringBuilder buf = new StringBuilder();
int numChars;
try
{

View File

@@ -69,7 +69,7 @@ public class JavaScriptEngineFactory implements ScriptEngineFactory
@Override
public String getMethodCallSyntax(String obj, String m, String... args)
{
StringBuilder buf = new StringBuilder();
final StringBuilder buf = new StringBuilder();
buf.append(obj);
buf.append('.');
buf.append(m);
@@ -102,12 +102,12 @@ public class JavaScriptEngineFactory implements ScriptEngineFactory
@Override
public String getOutputStatement(String toDisplay)
{
StringBuilder buf = new StringBuilder();
final StringBuilder buf = new StringBuilder();
buf.append("System.out.print(\"");
int len = toDisplay.length();
final int len = toDisplay.length();
for (int i = 0; i < len; i++)
{
char ch = toDisplay.charAt(i);
final char ch = toDisplay.charAt(i);
switch (ch)
{
case 34: // '"'
@@ -161,7 +161,7 @@ public class JavaScriptEngineFactory implements ScriptEngineFactory
// we generate a Main class with main method
// that contains all the given statements
StringBuilder buf = new StringBuilder();
final StringBuilder buf = new StringBuilder();
buf.append("class ");
buf.append(getClassName());
buf.append(" {\n");
@@ -183,7 +183,7 @@ public class JavaScriptEngineFactory implements ScriptEngineFactory
@Override
public ScriptEngine getScriptEngine()
{
JavaScriptEngine engine = new JavaScriptEngine();
final JavaScriptEngine engine = new JavaScriptEngine();
engine.setFactory(this);
return engine;
}

View File

@@ -58,7 +58,7 @@ public final class MemoryClassLoader extends URLClassLoader
public Iterable<Class<?>> loadAll() throws ClassNotFoundException
{
List<Class<?>> classes = new ArrayList<>(classBytes.size());
final List<Class<?>> classes = new ArrayList<>(classBytes.size());
for (String name : classBytes.keySet())
{
classes.add(loadClass(name));
@@ -69,7 +69,7 @@ public final class MemoryClassLoader extends URLClassLoader
@Override
protected Class<?> findClass(String className) throws ClassNotFoundException
{
byte buf[] = classBytes.get(className);
final byte buf[] = classBytes.get(className);
if (buf != null)
{
// clear the bytes in map -- we don't need it anymore
@@ -86,12 +86,12 @@ public final class MemoryClassLoader extends URLClassLoader
return new URL[0];
}
List<URL> list = new ArrayList<>();
StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
final List<URL> list = new ArrayList<>();
final StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
while (st.hasMoreTokens())
{
String token = st.nextToken();
File file = new File(token);
final String token = st.nextToken();
final File file = new File(token);
if (file.exists())
{
try
@@ -116,7 +116,7 @@ public final class MemoryClassLoader extends URLClassLoader
}
}
URL res[] = new URL[list.size()];
final URL res[] = new URL[list.size()];
list.toArray(res);
return res;
}

View File

@@ -114,7 +114,7 @@ public final class MemoryJavaFileManager extends EclipseFileManager
public void close() throws IOException
{
out.close();
ByteArrayOutputStream bos = (ByteArrayOutputStream) out;
final ByteArrayOutputStream bos = (ByteArrayOutputStream) out;
classBytes.put(name, bos.toByteArray());
}
};
@@ -138,7 +138,7 @@ public final class MemoryJavaFileManager extends EclipseFileManager
static URI toURI(String name)
{
File file = new File(name);
final File file = new File(name);
if (file.exists())
{
return file.toURI();

View File

@@ -102,10 +102,10 @@ public final class SelectorThread<T extends MMOClient<?>> extends Thread
public final void openServerSocket(InetAddress address, int tcpPort) throws IOException
{
ServerSocketChannel selectable = ServerSocketChannel.open();
final ServerSocketChannel selectable = ServerSocketChannel.open();
selectable.configureBlocking(false);
ServerSocket ss = selectable.socket();
final ServerSocket ss = selectable.socket();
if (address == null)
{
@@ -247,7 +247,7 @@ public final class SelectorThread<T extends MMOClient<?>> extends Thread
private final void acceptConnection(final SelectionKey key, MMOConnection<T> con)
{
ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
final ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
SocketChannel sc;
try
@@ -257,7 +257,7 @@ public final class SelectorThread<T extends MMOClient<?>> extends Thread
if ((_acceptFilter == null) || _acceptFilter.accept(sc))
{
sc.configureBlocking(false);
SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
con = new MMOConnection<>(this, sc.socket(), clientKey, TCP_NODELAY);
con.setClient(_clientFactory.create(con));
clientKey.attach(con);
@@ -678,7 +678,7 @@ public final class SelectorThread<T extends MMOClient<?>> extends Thread
protected void closeSelectorThread()
{
for (final SelectionKey key : _selector.keys())
for (SelectionKey key : _selector.keys())
{
try
{