Apply new checkstyle rules

This commit is contained in:
Alexey Andreev 2015-07-23 11:47:14 +03:00
parent c20209e651
commit 4548705620
105 changed files with 588 additions and 582 deletions

View File

@ -63,20 +63,19 @@
<module name="EmptyForIteratorPad"/> <module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/> <module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"> <module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS,TYPECAST"/> <property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
</module> </module>
<module name="NoWhitespaceBefore"> <module name="NoWhitespaceBefore">
<property name="allowLineBreaks" value="true"/> <property name="allowLineBreaks" value="true"/>
<property name="tokens" value="SEMI,POST_DEC,POST_INC"/> <property name="tokens" value="SEMI,POST_DEC,POST_INC"/>
</module> </module>
<module name="OperatorWrap"> <module name="OperatorWrap"/>
<property name="option" value="eol"/>
</module>
<module name="ParenPad"/> <module name="ParenPad"/>
<module name="TypecastParenPad"/> <module name="TypecastParenPad"/>
<module name="WhitespaceAfter"> <module name="WhitespaceAfter">
<property name="tokens" value="COMMA,SEMI"/> <property name="tokens" value="COMMA,SEMI,TYPECAST"/>
</module> </module>
<module name="WhitespaceAround"/>
</module> </module>
<module name="RegexpHeader"> <module name="RegexpHeader">
<property name="headerFile" value="${config_loc}/license-regexp.txt"/> <property name="headerFile" value="${config_loc}/license-regexp.txt"/>

View File

@ -69,6 +69,7 @@
<html4j.version>1.1</html4j.version> <html4j.version>1.1</html4j.version>
<jetty.version>9.2.1.v20140609</jetty.version> <jetty.version>9.2.1.v20140609</jetty.version>
<slf4j.version>1.7.7</slf4j.version> <slf4j.version>1.7.7</slf4j.version>
<checker.version>1.9.3</checker.version>
</properties> </properties>
<modules> <modules>
@ -164,6 +165,11 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version> <version>${slf4j.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker</artifactId>
<version>${checker.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View File

@ -436,8 +436,8 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
} else { } else {
CallFunctionResponse response = mapper.reader(CallFunctionResponse.class).readValue(node); CallFunctionResponse response = mapper.reader(CallFunctionResponse.class).readValue(node);
RemoteObjectDTO result = response.getResult(); RemoteObjectDTO result = response.getResult();
sync.add(new RepresentationWrapper(result.getValue() != null ? sync.add(new RepresentationWrapper(result.getValue() != null
result.getValue().getTextValue() : null)); ? result.getValue().getTextValue() : null));
} }
} }
}); });

View File

@ -39,7 +39,7 @@ public class ChromeRDPDebuggerEndpoint implements ChromeRDPExchange {
session.setMaxIdleTimeout(0); session.setMaxIdleTimeout(0);
Object debugger = session.getUserProperties().get("chrome.rdp"); Object debugger = session.getUserProperties().get("chrome.rdp");
if (debugger instanceof ChromeRDPExchangeConsumer) { if (debugger instanceof ChromeRDPExchangeConsumer) {
this.debugger = (ChromeRDPExchangeConsumer)debugger; this.debugger = (ChromeRDPExchangeConsumer) debugger;
this.debugger.setExchange(this); this.debugger.setExchange(this);
} }
} }

View File

@ -41,8 +41,8 @@ public class RDPValue implements JavaScriptValue {
this.debugger = debugger; this.debugger = debugger;
this.objectId = objectId; this.objectId = objectId;
this.innerStructure = innerStructure; this.innerStructure = innerStructure;
properties = objectId != null ? new RDPScope(debugger, objectId) : properties = objectId != null ? new RDPScope(debugger, objectId)
Collections.<String, RDPLocalVariable>emptyMap(); : Collections.<String, RDPLocalVariable>emptyMap();
} }
@Override @Override
@ -69,7 +69,7 @@ public class RDPValue implements JavaScriptValue {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Map<String, JavaScriptVariable> getProperties() { public Map<String, JavaScriptVariable> getProperties() {
return (Map<String, JavaScriptVariable>)properties; return (Map<String, JavaScriptVariable>) properties;
} }
@Override @Override

View File

@ -149,7 +149,7 @@ public final class TeaVMTestRunner {
} }
try { try {
return (TestAdapter)cons.newInstance(); return (TestAdapter) cons.newInstance();
} catch (IllegalAccessException | InstantiationException e) { } catch (IllegalAccessException | InstantiationException e) {
System.err.println("Error instantiating adapter: " + adapterName); System.err.println("Error instantiating adapter: " + adapterName);
e.printStackTrace(System.err); e.printStackTrace(System.err);
@ -187,7 +187,7 @@ public final class TeaVMTestRunner {
} }
try { try {
return (ClassHolderTransformer)cons.newInstance(); return (ClassHolderTransformer) cons.newInstance();
} catch (IllegalAccessException | InstantiationException e) { } catch (IllegalAccessException | InstantiationException e) {
System.err.println("Error instantiating transformer: " + transformerName); System.err.println("Error instantiating transformer: " + transformerName);
e.printStackTrace(System.err); e.printStackTrace(System.err);

View File

@ -45,6 +45,10 @@
<artifactId>hppc</artifactId> <artifactId>hppc</artifactId>
<version>0.6.1</version> <version>0.6.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker</artifactId>
</dependency>
</dependencies> </dependencies>
<name>TeaVM core</name> <name>TeaVM core</name>

View File

@ -71,7 +71,7 @@ public class AstIO {
node.getModifiers().addAll(unpackModifiers(input.readInt())); node.getModifiers().addAll(unpackModifiers(input.readInt()));
int varCount = input.readShort(); int varCount = input.readShort();
for (int i = 0; i < varCount; ++i) { for (int i = 0; i < varCount; ++i) {
node.getVariables().add((int)input.readShort()); node.getVariables().add((int) input.readShort());
} }
int paramDebugNameCount = input.readShort(); int paramDebugNameCount = input.readShort();
for (int i = 0; i < paramDebugNameCount; ++i) { for (int i = 0; i < paramDebugNameCount; ++i) {
@ -116,7 +116,7 @@ public class AstIO {
node.getModifiers().addAll(unpackModifiers(input.readInt())); node.getModifiers().addAll(unpackModifiers(input.readInt()));
int varCount = input.readShort(); int varCount = input.readShort();
for (int i = 0; i < varCount; ++i) { for (int i = 0; i < varCount; ++i) {
node.getVariables().add((int)input.readShort()); node.getVariables().add((int) input.readShort());
} }
int paramDebugNameCount = input.readShort(); int paramDebugNameCount = input.readShort();
for (int i = 0; i < paramDebugNameCount; ++i) { for (int i = 0; i < paramDebugNameCount; ++i) {
@ -345,10 +345,10 @@ public class AstIO {
try { try {
output.writeByte(16); output.writeByte(16);
writeSequence(statement.getProtectedBody()); writeSequence(statement.getProtectedBody());
output.writeInt(statement.getExceptionType() != null ? output.writeInt(statement.getExceptionType() != null
symbolTable.lookup(statement.getExceptionType()) : -1); ? symbolTable.lookup(statement.getExceptionType()) : -1);
output.writeShort(statement.getExceptionVariable() != null ? output.writeShort(statement.getExceptionVariable() != null
statement.getExceptionVariable() : -1); ? statement.getExceptionVariable() : -1);
writeSequence(statement.getHandler()); writeSequence(statement.getHandler());
} catch (IOException e) { } catch (IOException e) {
throw new IOExceptionWrapper(e); throw new IOExceptionWrapper(e);
@ -430,19 +430,19 @@ public class AstIO {
output.writeByte(3); output.writeByte(3);
} else if (value instanceof Integer) { } else if (value instanceof Integer) {
output.writeByte(4); output.writeByte(4);
output.writeInt((Integer)value); output.writeInt((Integer) value);
} else if (value instanceof Long) { } else if (value instanceof Long) {
output.writeByte(5); output.writeByte(5);
output.writeLong((Long)value); output.writeLong((Long) value);
} else if (value instanceof Float) { } else if (value instanceof Float) {
output.writeByte(6); output.writeByte(6);
output.writeFloat((Float)value); output.writeFloat((Float) value);
} else if (value instanceof Double) { } else if (value instanceof Double) {
output.writeByte(7); output.writeByte(7);
output.writeDouble((Double)value); output.writeDouble((Double) value);
} else if (value instanceof String) { } else if (value instanceof String) {
output.writeByte(8); output.writeByte(8);
output.writeUTF((String)value); output.writeUTF((String) value);
} else if (value instanceof ValueType) { } else if (value instanceof ValueType) {
output.writeByte(9); output.writeByte(9);
output.writeInt(symbolTable.lookup(value.toString())); output.writeInt(symbolTable.lookup(value.toString()));

View File

@ -157,19 +157,19 @@ public class DiskCachedClassHolderSource implements ClassHolderSource {
output.writeByte(0); output.writeByte(0);
} else if (value instanceof Integer) { } else if (value instanceof Integer) {
output.writeByte(1); output.writeByte(1);
output.writeInt((Integer)value); output.writeInt((Integer) value);
} else if (value instanceof Long) { } else if (value instanceof Long) {
output.writeByte(2); output.writeByte(2);
output.writeLong((Long)value); output.writeLong((Long) value);
} else if (value instanceof Float) { } else if (value instanceof Float) {
output.writeByte(3); output.writeByte(3);
output.writeFloat((Float)value); output.writeFloat((Float) value);
} else if (value instanceof Double) { } else if (value instanceof Double) {
output.writeByte(4); output.writeByte(4);
output.writeDouble((Double)value); output.writeDouble((Double) value);
} else if (value instanceof String) { } else if (value instanceof String) {
output.writeByte(5); output.writeByte(5);
output.writeUTF((String)value); output.writeUTF((String) value);
} }
} }

View File

@ -155,8 +155,8 @@ public class DiskRegularMethodNodeCache implements MethodNodeCache {
private File getMethodFile(MethodReference method, boolean async) { private File getMethodFile(MethodReference method, boolean async) {
File dir = new File(directory, method.getClassName().replace('.', '/')); File dir = new File(directory, method.getClassName().replace('.', '/'));
return new File(dir, FileNameEncoder.encodeFileName(method.getDescriptor().toString()) + ".teavm-ast" + return new File(dir, FileNameEncoder.encodeFileName(method.getDescriptor().toString()) + ".teavm-ast"
(async ? "-async" : "")); + (async ? "-async" : ""));
} }
static class AstDependencyAnalyzer implements StatementVisitor, ExprVisitor { static class AstDependencyAnalyzer implements StatementVisitor, ExprVisitor {

View File

@ -67,8 +67,8 @@ public class ProgramIO {
for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) { for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) {
data.writeInt(tryCatch.getExceptionType() != null ? symbolTable.lookup( data.writeInt(tryCatch.getExceptionType() != null ? symbolTable.lookup(
tryCatch.getExceptionType()) : -1); tryCatch.getExceptionType()) : -1);
data.writeShort(tryCatch.getExceptionVariable() != null ? data.writeShort(tryCatch.getExceptionVariable() != null
tryCatch.getExceptionVariable().getIndex() : -1); ? tryCatch.getExceptionVariable().getIndex() : -1);
data.writeShort(tryCatch.getHandler().getIndex()); data.writeShort(tryCatch.getHandler().getIndex());
} }
InstructionLocation location = null; InstructionLocation location = null;
@ -87,7 +87,7 @@ public class ProgramIO {
} }
insn.acceptVisitor(insnWriter); insn.acceptVisitor(insnWriter);
} catch (IOExceptionWrapper e) { } catch (IOExceptionWrapper e) {
throw (IOException)e.getCause(); throw (IOException) e.getCause();
} }
} }
data.writeByte(-1); data.writeByte(-1);

View File

@ -41,8 +41,8 @@ public class DefaultCallGraph implements CallGraph {
@Override @Override
public Collection<DefaultFieldAccessSite> getFieldAccess(FieldReference reference) { public Collection<DefaultFieldAccessSite> getFieldAccess(FieldReference reference) {
Set<DefaultFieldAccessSite> resultSet = fieldAccessSites.get(reference); Set<DefaultFieldAccessSite> resultSet = fieldAccessSites.get(reference);
return resultSet != null ? Collections.unmodifiableSet(resultSet) : return resultSet != null ? Collections.unmodifiableSet(resultSet)
Collections.<DefaultFieldAccessSite>emptySet(); : Collections.<DefaultFieldAccessSite>emptySet();
} }
void addFieldAccess(DefaultFieldAccessSite accessSite) { void addFieldAccess(DefaultFieldAccessSite accessSite) {
@ -57,8 +57,8 @@ public class DefaultCallGraph implements CallGraph {
@Override @Override
public Collection<DefaultClassAccessSite> getClassAccess(String className) { public Collection<DefaultClassAccessSite> getClassAccess(String className) {
Set<DefaultClassAccessSite> resultSet = classAccessSites.get(className); Set<DefaultClassAccessSite> resultSet = classAccessSites.get(className);
return resultSet != null ? Collections.unmodifiableSet(resultSet) : return resultSet != null ? Collections.unmodifiableSet(resultSet)
Collections.<DefaultClassAccessSite>emptySet(); : Collections.<DefaultClassAccessSite>emptySet();
} }
void addClassAccess(DefaultClassAccessSite accessSite) { void addClassAccess(DefaultClassAccessSite accessSite) {

View File

@ -56,9 +56,9 @@ public class DefaultCallSite implements CallSite {
if (!(obj instanceof DefaultCallSite)) { if (!(obj instanceof DefaultCallSite)) {
return false; return false;
} }
DefaultCallSite other = (DefaultCallSite)obj; DefaultCallSite other = (DefaultCallSite) obj;
return Objects.equals(callee.getMethod(), other.callee.getMethod()) && return Objects.equals(callee.getMethod(), other.callee.getMethod())
Objects.equals(location, other.location); && Objects.equals(location, other.location);
} }
@Override @Override

View File

@ -61,9 +61,9 @@ public class DefaultClassAccessSite implements ClassAccessSite {
if (!(obj instanceof DefaultClassAccessSite)) { if (!(obj instanceof DefaultClassAccessSite)) {
return false; return false;
} }
DefaultClassAccessSite other = (DefaultClassAccessSite)obj; DefaultClassAccessSite other = (DefaultClassAccessSite) obj;
return Objects.equals(location, other.location) && return Objects.equals(location, other.location)
Objects.equals(callee, other.callee) && && Objects.equals(callee, other.callee)
Objects.equals(className, other.className); && Objects.equals(className, other.className);
} }
} }

View File

@ -62,8 +62,8 @@ public class DefaultFieldAccessSite implements FieldAccessSite {
if (!(obj instanceof DefaultFieldAccessSite)) { if (!(obj instanceof DefaultFieldAccessSite)) {
return false; return false;
} }
DefaultFieldAccessSite other = (DefaultFieldAccessSite)obj; DefaultFieldAccessSite other = (DefaultFieldAccessSite) obj;
return Objects.equals(location, other.location) && Objects.equals(callee, other.callee) && return Objects.equals(location, other.location) && Objects.equals(callee, other.callee)
Objects.equals(field, other.field); && Objects.equals(field, other.field);
} }
} }

View File

@ -155,8 +155,8 @@ public class DefaultNamingStrategy implements NamingStrategy {
ClassReader clsHolder = classSource.get(cls); ClassReader clsHolder = classSource.get(cls);
cls = clsHolder.getParent(); cls = clsHolder.getParent();
if (cls == null) { if (cls == null) {
throw new NamingException("Can't provide name for field as the field not found: " + throw new NamingException("Can't provide name for field as the field not found: "
initialCls + "." + field); + initialCls + "." + field);
} }
} }
return cls; return cls;

View File

@ -46,7 +46,7 @@ public class SourceWriter implements Appendable, LocationProvider {
} }
public SourceWriter append(String value) throws IOException { public SourceWriter append(String value) throws IOException {
append((CharSequence)value); append((CharSequence) value);
return this; return this;
} }
@ -154,7 +154,7 @@ public class SourceWriter implements Appendable, LocationProvider {
} }
} }
public SourceWriter newLine() throws IOException{ public SourceWriter newLine() throws IOException {
innerWriter.append('\n'); innerWriter.append('\n');
column = 0; column = 0;
++line; ++line;
@ -181,7 +181,7 @@ public class SourceWriter implements Appendable, LocationProvider {
return this; return this;
} }
public SourceWriter softNewLine() throws IOException{ public SourceWriter softNewLine() throws IOException {
if (!minified) { if (!minified) {
innerWriter.append('\n'); innerWriter.append('\n');
column = 0; column = 0;

View File

@ -40,8 +40,8 @@ public class DJGraph {
public DJGraph(Graph src, int[] weight) { public DJGraph(Graph src, int[] weight) {
if (src.size() != weight.length) { if (src.size() != weight.length) {
throw new IllegalArgumentException("Node count " + src.size() + " is not equal to weight array " + throw new IllegalArgumentException("Node count " + src.size() + " is not equal to weight array "
weight.length); + weight.length);
} }
this.cfg = new MutableDirectedGraph(src); this.cfg = new MutableDirectedGraph(src);
domTree = GraphUtils.buildDominatorTree(src); domTree = GraphUtils.buildDominatorTree(src);

View File

@ -95,8 +95,8 @@ public class Debugger {
return; return;
} }
CallFrame recentFrame = callStack[0]; CallFrame recentFrame = callStack[0];
if (recentFrame.getLocation() == null || recentFrame.getLocation().getFileName() == null || if (recentFrame.getLocation() == null || recentFrame.getLocation().getFileName() == null
recentFrame.getLocation().getLine() < 0) { || recentFrame.getLocation().getLine() < 0) {
jsStep(enterMethod); jsStep(enterMethod);
return; return;
} }
@ -105,8 +105,8 @@ public class Debugger {
boolean exits; boolean exits;
String script = frame.getOriginalLocation().getScript(); String script = frame.getOriginalLocation().getScript();
DebugInformation debugInfo = debugInformationMap.get(script); DebugInformation debugInfo = debugInformationMap.get(script);
if (frame.getLocation() != null && frame.getLocation().getFileName() != null && if (frame.getLocation() != null && frame.getLocation().getFileName() != null
frame.getLocation().getLine() >= 0 && debugInfo != null) { && frame.getLocation().getLine() >= 0 && debugInfo != null) {
exits = addFollowing(debugInfo, frame.getLocation(), script, new HashSet<>(), successors); exits = addFollowing(debugInfo, frame.getLocation(), script, new HashSet<>(), successors);
if (enterMethod) { if (enterMethod) {
CallSiteSuccessorFinder successorFinder = new CallSiteSuccessorFinder(debugInfo, script, CallSiteSuccessorFinder successorFinder = new CallSiteSuccessorFinder(debugInfo, script,

View File

@ -116,13 +116,13 @@ public class DebugInformation {
public MethodReference getExactMethod(int index) { public MethodReference getExactMethod(int index) {
long item = exactMethods[index]; long item = exactMethods[index];
int classIndex = (int)(item >>> 32); int classIndex = (int) (item >>> 32);
int methodIndex = (int)item; int methodIndex = (int) item;
return new MethodReference(classNames[classIndex], MethodDescriptor.parse(methods[methodIndex])); return new MethodReference(classNames[classIndex], MethodDescriptor.parse(methods[methodIndex]));
} }
public int getExactMethodId(int classNameId, int methodId) { public int getExactMethodId(int classNameId, int methodId) {
long full = ((long)classNameId << 32) | methodId; long full = ((long) classNameId << 32) | methodId;
Integer id = exactMethodMap.get(full); Integer id = exactMethodMap.get(full);
return id != null ? id : -1; return id != null ? id : -1;
} }
@ -501,7 +501,7 @@ public class DebugInformation {
int lastClass = -1; int lastClass = -1;
for (int i = 0; i < exactMethods.length; ++i) { for (int i = 0; i < exactMethods.length; ++i) {
long exactMethod = exactMethods[i]; long exactMethod = exactMethods[i];
int classIndex = (int)(exactMethod >>> 32); int classIndex = (int) (exactMethod >>> 32);
if (classIndex != lastClass) { if (classIndex != lastClass) {
if (lastClass >= 0) { if (lastClass >= 0) {
ClassMetadata clsData = classesMetadata.get(lastClass); ClassMetadata clsData = classesMetadata.get(lastClass);
@ -510,7 +510,7 @@ public class DebugInformation {
} }
lastClass = classIndex; lastClass = classIndex;
} }
int methodIndex = (int)exactMethod; int methodIndex = (int) exactMethod;
methods.add(methodIndex); methods.add(methodIndex);
} }
if (lastClass >= 0) { if (lastClass >= 0) {
@ -563,7 +563,7 @@ public class DebugInformation {
} }
private Integer getExactMethodIndex(int classIndex, int methodIndex) { private Integer getExactMethodIndex(int classIndex, int methodIndex) {
long entry = ((long)classIndex << 32) | methodIndex; long entry = ((long) classIndex << 32) | methodIndex;
return exactMethodMap.get(entry); return exactMethodMap.get(entry);
} }
@ -663,8 +663,8 @@ public class DebugInformation {
MethodReference[] references = new MethodReference[end - start]; MethodReference[] references = new MethodReference[end - start];
for (int i = 0; i < references.length; ++i) { for (int i = 0; i < references.length; ++i) {
long item = exactMethods[data[start + i]]; long item = exactMethods[data[start + i]];
int classIndex = (int)(item >>> 32); int classIndex = (int) (item >>> 32);
int methodIndex = (int)item; int methodIndex = (int) item;
references[i] = new MethodReference(classNames[classIndex], references[i] = new MethodReference(classNames[classIndex],
MethodDescriptor.parse(methods[methodIndex])); MethodDescriptor.parse(methods[methodIndex]));
} }

View File

@ -113,7 +113,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
} }
if (currentClass != null) { if (currentClass != null) {
int classIndex = classes.index(currentClass); int classIndex = classes.index(currentClass);
long fullIndex = ((long)classIndex << 32) | methodIndex; long fullIndex = ((long) classIndex << 32) | methodIndex;
if (!exactMethodMap.containsKey(fullIndex)) { if (!exactMethodMap.containsKey(fullIndex)) {
exactMethodMap.put(fullIndex, exactMethods.size()); exactMethodMap.put(fullIndex, exactMethods.size());
exactMethods.add(fullIndex); exactMethods.add(fullIndex);
@ -171,7 +171,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
private int getExactMethodIndex(MethodReference method) { private int getExactMethodIndex(MethodReference method) {
int methodIndex = methods.index(method.getDescriptor().toString()); int methodIndex = methods.index(method.getDescriptor().toString());
int classIndex = classes.index(method.getClassName()); int classIndex = classes.index(method.getClassName());
long fullIndex = ((long)classIndex << 32) | methodIndex; long fullIndex = ((long) classIndex << 32) | methodIndex;
Integer exactMethodIndex = exactMethodMap.get(fullIndex); Integer exactMethodIndex = exactMethodMap.get(fullIndex);
if (exactMethodIndex == null) { if (exactMethodIndex == null) {
exactMethodIndex = exactMethods.size(); exactMethodIndex = exactMethods.size();

View File

@ -269,7 +269,7 @@ class DebugInformationReader {
for (int i = 0; i < result.length; ++i) { for (int i = 0; i < result.length; ++i) {
lastClass += readNumber(); lastClass += readNumber();
lastMethod += readNumber(); lastMethod += readNumber();
result[i] = ((long)lastClass << 32) | lastMethod; result[i] = ((long) lastClass << 32) | lastMethod;
} }
return result; return result;
} }
@ -306,7 +306,7 @@ class DebugInformationReader {
if (r < 0) { if (r < 0) {
throw new EOFException(); throw new EOFException();
} }
byte b = (byte)r; byte b = (byte) r;
number |= (b & 0x7F) << shift; number |= (b & 0x7F) << shift;
shift += 7; shift += 7;
if ((b & 0x80) == 0) { if ((b & 0x80) == 0) {

View File

@ -108,8 +108,8 @@ class DebugInformationWriter {
writeUnsignedNumber(array.length); writeUnsignedNumber(array.length);
for (int i = 0; i < array.length; ++i) { for (int i = 0; i < array.length; ++i) {
long item = array[i]; long item = array[i];
int classIndex = (int)(item >> 32); int classIndex = (int) (item >> 32);
int methodIndex = (int)item; int methodIndex = (int) item;
writeNumber(classIndex - lastClass); writeNumber(classIndex - lastClass);
lastClass = classIndex; lastClass = classIndex;
writeNumber(methodIndex - lastMethod); writeNumber(methodIndex - lastMethod);
@ -249,7 +249,7 @@ class DebugInformationWriter {
private void writeUnsignedNumber(int number) throws IOException { private void writeUnsignedNumber(int number) throws IOException {
do { do {
byte b = (byte)(number & 0x7F); byte b = (byte) (number & 0x7F);
if ((number & 0xFFFFFF80) != 0) { if ((number & 0xFFFFFF80) != 0) {
b |= 0x80; b |= 0x80;
} }

View File

@ -39,13 +39,13 @@ public class ExactMethodIterator {
} }
public boolean isEndReached() { public boolean isEndReached() {
return methodIndex >= debugInformation.methodMapping.size() && return methodIndex >= debugInformation.methodMapping.size()
classIndex >= debugInformation.classMapping.size(); && classIndex >= debugInformation.classMapping.size();
} }
private void read() { private void read() {
if (classIndex < debugInformation.classMapping.size() && if (classIndex < debugInformation.classMapping.size()
methodIndex < debugInformation.methodMapping.size()) { && methodIndex < debugInformation.methodMapping.size()) {
RecordArray.Record classRecord = debugInformation.classMapping.get(classIndex); RecordArray.Record classRecord = debugInformation.classMapping.get(classIndex);
RecordArray.Record methodRecord = debugInformation.methodMapping.get(methodIndex); RecordArray.Record methodRecord = debugInformation.methodMapping.get(methodIndex);
GeneratedLocation classLoc = DebugInformation.key(classRecord); GeneratedLocation classLoc = DebugInformation.key(classRecord);

View File

@ -62,7 +62,7 @@ public class GeneratedLocation implements Comparable<GeneratedLocation> {
if (obj == null) { if (obj == null) {
return false; return false;
} }
GeneratedLocation other = (GeneratedLocation)obj; GeneratedLocation other = (GeneratedLocation) obj;
return line == other.line && column == other.column; return line == other.line && column == other.column;
} }

View File

@ -37,13 +37,11 @@ public class SourceLocationIterator {
} }
public boolean isEndReached() { public boolean isEndReached() {
return fileIndex >= debugInformation.fileMapping.size() && return fileIndex >= debugInformation.fileMapping.size() && lineIndex >= debugInformation.lineMapping.size();
lineIndex >= debugInformation.lineMapping.size();
} }
private void read() { private void read() {
if (fileIndex < debugInformation.fileMapping.size() && if (fileIndex < debugInformation.fileMapping.size() && lineIndex < debugInformation.lineMapping.size()) {
lineIndex < debugInformation.lineMapping.size()) {
RecordArray.Record fileRecord = debugInformation.fileMapping.get(fileIndex); RecordArray.Record fileRecord = debugInformation.fileMapping.get(fileIndex);
RecordArray.Record lineRecord = debugInformation.lineMapping.get(lineIndex); RecordArray.Record lineRecord = debugInformation.lineMapping.get(lineIndex);
GeneratedLocation fileLoc = DebugInformation.key(fileRecord); GeneratedLocation fileLoc = DebugInformation.key(fileRecord);

View File

@ -52,7 +52,7 @@ public class JavaScriptLocation {
if (!(obj instanceof JavaScriptLocation)) { if (!(obj instanceof JavaScriptLocation)) {
return false; return false;
} }
JavaScriptLocation other = (JavaScriptLocation)obj; JavaScriptLocation other = (JavaScriptLocation) obj;
return Objects.equals(other.script, script) && other.line == line && other.column == column; return Objects.equals(other.script, script) && other.line == line && other.column == column;
} }

View File

@ -430,7 +430,7 @@ public class DependencyChecker implements DependencyInfo {
return; return;
} }
ValueType depType = depAnnot.getValue("value").getJavaClass(); ValueType depType = depAnnot.getValue("value").getJavaClass();
String depClassName = ((ValueType.Object)depType).getClassName(); String depClassName = ((ValueType.Object) depType).getClassName();
Class<?> depClass; Class<?> depClass;
try { try {
depClass = Class.forName(depClassName, true, classLoader); depClass = Class.forName(depClassName, true, classLoader);
@ -438,7 +438,7 @@ public class DependencyChecker implements DependencyInfo {
throw new RuntimeException("Dependency plugin not found: " + depClassName, e); throw new RuntimeException("Dependency plugin not found: " + depClassName, e);
} }
try { try {
methodDep.dependencyPlugin = (DependencyPlugin)depClass.newInstance(); methodDep.dependencyPlugin = (DependencyPlugin) depClass.newInstance();
} catch (IllegalAccessException | InstantiationException e) { } catch (IllegalAccessException | InstantiationException e) {
throw new RuntimeException("Can't instantiate dependency plugin " + depClassName, e); throw new RuntimeException("Can't instantiate dependency plugin " + depClassName, e);
} }

View File

@ -220,8 +220,8 @@ class DependencyGraphBuilder {
public void consume(DependencyType type) { public void consume(DependencyType type) {
String className = type.getName(); String className = type.getName();
if (DependencyChecker.shouldLog) { if (DependencyChecker.shouldLog) {
System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " + System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". "
"Target class is " + className); + "Target class is " + className);
} }
if (className.startsWith("[")) { if (className.startsWith("[")) {
className = "java.lang.Object"; className = "java.lang.Object";
@ -286,10 +286,10 @@ class DependencyGraphBuilder {
node.propagate(dependencyChecker.getType("java.lang.Class")); node.propagate(dependencyChecker.getType("java.lang.Class"));
} }
while (cst instanceof ValueType.Array) { while (cst instanceof ValueType.Array) {
cst = ((ValueType.Array)cst).getItemType(); cst = ((ValueType.Array) cst).getItemType();
} }
if (cst instanceof ValueType.Object) { if (cst instanceof ValueType.Object) {
final String className = ((ValueType.Object)cst).getClassName(); final String className = ((ValueType.Object) cst).getClassName();
dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation)); dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation));
} }
} }
@ -348,7 +348,7 @@ class DependencyGraphBuilder {
DependencyNode valueNode = nodes[value.getIndex()]; DependencyNode valueNode = nodes[value.getIndex()];
DependencyNode receiverNode = nodes[receiver.getIndex()]; DependencyNode receiverNode = nodes[receiver.getIndex()];
if (targetType instanceof ValueType.Object) { if (targetType instanceof ValueType.Object) {
String targetClsName = ((ValueType.Object)targetType).getClassName(); String targetClsName = ((ValueType.Object) targetType).getClassName();
final ClassReader targetClass = dependencyChecker.getClassSource().get(targetClsName); final ClassReader targetClass = dependencyChecker.getClassSource().get(targetClsName);
if (targetClass != null) { if (targetClass != null) {
if (valueNode != null && receiverNode != null) { if (valueNode != null && receiverNode != null) {
@ -426,9 +426,9 @@ class DependencyGraphBuilder {
private String extractClassName(ValueType itemType) { private String extractClassName(ValueType itemType) {
while (itemType instanceof ValueType.Array) { while (itemType instanceof ValueType.Array) {
itemType = ((ValueType.Array)itemType).getItemType(); itemType = ((ValueType.Array) itemType).getItemType();
} }
return itemType instanceof ValueType.Object ? ((ValueType.Object)itemType).getClassName() : null; return itemType instanceof ValueType.Object ? ((ValueType.Object) itemType).getClassName() : null;
} }
@Override @Override
@ -437,11 +437,11 @@ class DependencyGraphBuilder {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < dimensions.size(); ++i) { for (int i = 0; i < dimensions.size(); ++i) {
sb.append('['); sb.append('[');
itemType = ((ValueType.Array)itemType).getItemType(); itemType = ((ValueType.Array) itemType).getItemType();
} }
String itemTypeStr; String itemTypeStr;
if (itemType instanceof ValueType.Object) { if (itemType instanceof ValueType.Object) {
itemTypeStr = ((ValueType.Object)itemType).getClassName(); itemTypeStr = ((ValueType.Object) itemType).getClassName();
} else { } else {
itemTypeStr = itemType.toString(); itemTypeStr = itemType.toString();
} }

View File

@ -52,19 +52,19 @@ public class Linker {
BasicBlock block = program.basicBlockAt(i); BasicBlock block = program.basicBlockAt(i);
for (Instruction insn : block.getInstructions()) { for (Instruction insn : block.getInstructions()) {
if (insn instanceof InvokeInstruction) { if (insn instanceof InvokeInstruction) {
InvokeInstruction invoke = (InvokeInstruction)insn; InvokeInstruction invoke = (InvokeInstruction) insn;
MethodDependencyInfo linkedMethod = dependency.getMethodImplementation(invoke.getMethod()); MethodDependencyInfo linkedMethod = dependency.getMethodImplementation(invoke.getMethod());
if (linkedMethod != null) { if (linkedMethod != null) {
invoke.setMethod(linkedMethod.getReference()); invoke.setMethod(linkedMethod.getReference());
} }
} else if (insn instanceof GetFieldInstruction) { } else if (insn instanceof GetFieldInstruction) {
GetFieldInstruction getField = (GetFieldInstruction)insn; GetFieldInstruction getField = (GetFieldInstruction) insn;
FieldDependencyInfo linkedField = dependency.getField(getField.getField()); FieldDependencyInfo linkedField = dependency.getField(getField.getField());
if (linkedField != null) { if (linkedField != null) {
getField.setField(linkedField.getReference()); getField.setField(linkedField.getReference());
} }
} else if (insn instanceof PutFieldInstruction) { } else if (insn instanceof PutFieldInstruction) {
PutFieldInstruction getField = (PutFieldInstruction)insn; PutFieldInstruction getField = (PutFieldInstruction) insn;
FieldDependencyInfo linkedField = dependency.getField(getField.getField()); FieldDependencyInfo linkedField = dependency.getField(getField.getField());
if (linkedField != null) { if (linkedField != null) {
getField.setField(linkedField.getReference()); getField.setField(linkedField.getReference());

View File

@ -111,31 +111,31 @@ public class Problem {
if (!(param instanceof String)) { if (!(param instanceof String)) {
return index; return index;
} }
consumer.appendClass((String)param); consumer.appendClass((String) param);
break; break;
case TYPE: case TYPE:
if (!(param instanceof ValueType)) { if (!(param instanceof ValueType)) {
return index; return index;
} }
consumer.appendType((ValueType)param); consumer.appendType((ValueType) param);
break; break;
case METHOD: case METHOD:
if (!(param instanceof MethodReference)) { if (!(param instanceof MethodReference)) {
return index; return index;
} }
consumer.appendMethod((MethodReference)param); consumer.appendMethod((MethodReference) param);
break; break;
case FIELD: case FIELD:
if (!(param instanceof FieldReference)) { if (!(param instanceof FieldReference)) {
return index; return index;
} }
consumer.appendField((FieldReference)param); consumer.appendField((FieldReference) param);
break; break;
case LOCATION: case LOCATION:
if (!(param instanceof InstructionLocation)) { if (!(param instanceof InstructionLocation)) {
return index; return index;
} }
consumer.appendLocation((InstructionLocation)param); consumer.appendLocation((InstructionLocation) param);
break; break;
} }
next += 2; next += 2;

View File

@ -49,7 +49,7 @@ class AsyncCallsFinder implements StatementVisitor, ExprVisitor {
statement.getRightValue().acceptVisitor(this); statement.getRightValue().acceptVisitor(this);
return; return;
} }
InvocationExpr invocation = (InvocationExpr)statement.getRightValue(); InvocationExpr invocation = (InvocationExpr) statement.getRightValue();
asyncCalls.add(invocation.getMethod()); asyncCalls.add(invocation.getMethod());
} }

View File

@ -202,8 +202,8 @@ public class Decompiler {
if (method.getModifiers().contains(ElementModifier.ABSTRACT)) { if (method.getModifiers().contains(ElementModifier.ABSTRACT)) {
continue; continue;
} }
if (method.getAnnotations().get(InjectedBy.class.getName()) != null || if (method.getAnnotations().get(InjectedBy.class.getName()) != null
methodsToPass.contains(method.getReference())) { || methodsToPass.contains(method.getReference())) {
continue; continue;
} }
MethodNode methodNode = decompile(method); MethodNode methodNode = decompile(method);
@ -215,8 +215,8 @@ public class Decompiler {
} }
public MethodNode decompile(MethodHolder method) { public MethodNode decompile(MethodHolder method) {
return method.getModifiers().contains(ElementModifier.NATIVE) ? decompileNative(method) : return method.getModifiers().contains(ElementModifier.NATIVE) ? decompileNative(method)
!asyncMethods.contains(method.getReference()) ? decompileRegular(method) : decompileAsync(method); : !asyncMethods.contains(method.getReference()) ? decompileRegular(method) : decompileAsync(method);
} }
public NativeMethodNode decompileNative(MethodHolder method) { public NativeMethodNode decompileNative(MethodHolder method) {
@ -224,17 +224,17 @@ public class Decompiler {
if (generator == null) { if (generator == null) {
AnnotationHolder annotHolder = method.getAnnotations().get(GeneratedBy.class.getName()); AnnotationHolder annotHolder = method.getAnnotations().get(GeneratedBy.class.getName());
if (annotHolder == null) { if (annotHolder == null) {
throw new DecompilationException("Method " + method.getOwnerName() + "." + method.getDescriptor() + throw new DecompilationException("Method " + method.getOwnerName() + "." + method.getDescriptor()
" is native, but no " + GeneratedBy.class.getName() + " annotation found"); + " is native, but no " + GeneratedBy.class.getName() + " annotation found");
} }
ValueType annotValue = annotHolder.getValues().get("value").getJavaClass(); ValueType annotValue = annotHolder.getValues().get("value").getJavaClass();
String generatorClassName = ((ValueType.Object)annotValue).getClassName(); String generatorClassName = ((ValueType.Object) annotValue).getClassName();
try { try {
Class<?> generatorClass = Class.forName(generatorClassName, true, classLoader); Class<?> generatorClass = Class.forName(generatorClassName, true, classLoader);
generator = (Generator)generatorClass.newInstance(); generator = (Generator) generatorClass.newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new DecompilationException("Error instantiating generator " + generatorClassName + throw new DecompilationException("Error instantiating generator " + generatorClassName
" for native method " + method.getOwnerName() + "." + method.getDescriptor()); + " for native method " + method.getOwnerName() + "." + method.getDescriptor());
} }
} }
NativeMethodNode methodNode = new NativeMethodNode(new MethodReference(method.getOwnerName(), NativeMethodNode methodNode = new NativeMethodNode(new MethodReference(method.getOwnerName(),
@ -323,8 +323,8 @@ public class Decompiler {
try { try {
part = getRegularMethodStatement(splitter.getProgram(i), splitter.getBlockSuccessors(i), i > 0); part = getRegularMethodStatement(splitter.getProgram(i), splitter.getBlockSuccessors(i), i > 0);
} catch (RuntimeException e) { } catch (RuntimeException e) {
StringBuilder sb = new StringBuilder("Error decompiling method " + method.getReference() + StringBuilder sb = new StringBuilder("Error decompiling method " + method.getReference()
" part " + i + ":\n"); + " part " + i + ":\n");
sb.append(new ListingBuilder().buildListing(splitter.getProgram(i), " ")); sb.append(new ListingBuilder().buildListing(splitter.getProgram(i), " "));
throw new DecompilationException(sb.toString(), e); throw new DecompilationException(sb.toString(), e);
} }
@ -539,8 +539,8 @@ public class Decompiler {
bookmark.offset = bookmark.block.body.size(); bookmark.offset = bookmark.block.body.size();
bookmark.exceptionHandler = tryCatch.getHandler().getIndex(); bookmark.exceptionHandler = tryCatch.getHandler().getIndex();
bookmark.exceptionType = tryCatch.getExceptionType(); bookmark.exceptionType = tryCatch.getExceptionType();
bookmark.exceptionVariable = tryCatch.getExceptionVariable() != null ? bookmark.exceptionVariable = tryCatch.getExceptionVariable() != null
tryCatch.getExceptionVariable().getIndex() : null; ? tryCatch.getExceptionVariable().getIndex() : null;
bookmark.block.tryCatches.add(bookmark); bookmark.block.tryCatches.add(bookmark);
tryCatchBookmarks.add(bookmark); tryCatchBookmarks.add(bookmark);
} }
@ -581,8 +581,8 @@ public class Decompiler {
} }
result.add(block); result.add(block);
int mappedIndex = indexer.nodeAt(currentNode.getEnd()); int mappedIndex = indexer.nodeAt(currentNode.getEnd());
if (mappedIndex >= 0 && (blockMap[mappedIndex] == null || if (mappedIndex >= 0 && (blockMap[mappedIndex] == null
!(blockMap[mappedIndex].statement instanceof WhileStatement))) { || !(blockMap[mappedIndex].statement instanceof WhileStatement))) {
blockMap[mappedIndex] = block; blockMap[mappedIndex] = block;
} }
if (loop) { if (loop) {

View File

@ -34,7 +34,7 @@ class EscapingStatementFinder implements StatementVisitor {
if (!(statement instanceof SequentialStatement)) { if (!(statement instanceof SequentialStatement)) {
return false; return false;
} }
SequentialStatement seq = (SequentialStatement)statement; SequentialStatement seq = (SequentialStatement) statement;
for (int i = seq.getSequence().size() - 1; i >= 0; --i) { for (int i = seq.getSequence().size() - 1; i >= 0; --i) {
if (!isEmpty(seq.getSequence().get(i))) { if (!isEmpty(seq.getSequence().get(i))) {
return false; return false;

View File

@ -27,12 +27,12 @@ final class ExprOptimizer {
public static Expr invert(Expr expr) { public static Expr invert(Expr expr) {
if (expr instanceof UnaryExpr) { if (expr instanceof UnaryExpr) {
UnaryExpr unary = (UnaryExpr)expr; UnaryExpr unary = (UnaryExpr) expr;
if (unary.getOperation() == UnaryOperation.NOT) { if (unary.getOperation() == UnaryOperation.NOT) {
return unary.getOperand(); return unary.getOperand();
} }
} else if (expr instanceof BinaryExpr) { } else if (expr instanceof BinaryExpr) {
BinaryExpr binary = (BinaryExpr)expr; BinaryExpr binary = (BinaryExpr) expr;
Expr a = binary.getFirstOperand(); Expr a = binary.getFirstOperand();
Expr b = binary.getSecondOperand(); Expr b = binary.getSecondOperand();
switch (binary.getOperation()) { switch (binary.getOperation()) {

View File

@ -67,8 +67,8 @@ public class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, Me
if (asyncFamilyMethods.contains(method.getReference())) { if (asyncFamilyMethods.contains(method.getReference())) {
consumer.consume(method.getReference()); consumer.consume(method.getReference());
} }
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC) || if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC)
method.getReference().getName().equals("<init>"))) { || method.getReference().getName().equals("<init>"))) {
consumer.consume(method.getReference()); consumer.consume(method.getReference());
} }
if (!method.getModifiers().contains(NodeModifier.STATIC)) { if (!method.getModifiers().contains(NodeModifier.STATIC)) {
@ -258,16 +258,16 @@ public class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, Me
@Override @Override
public void visit(ConstantExpr expr) { public void visit(ConstantExpr expr) {
if (expr.getValue() instanceof ValueType) { if (expr.getValue() instanceof ValueType) {
visitType((ValueType)expr.getValue()); visitType((ValueType) expr.getValue());
} }
} }
private void visitType(ValueType type) { private void visitType(ValueType type) {
while (type instanceof ValueType.Array) { while (type instanceof ValueType.Array) {
type = ((ValueType.Array)type).getItemType(); type = ((ValueType.Array) type).getItemType();
} }
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
String clsName = ((ValueType.Object)type).getClassName(); String clsName = ((ValueType.Object) type).getClassName();
consumer.consume(clsName); consumer.consume(clsName);
consumer.consumeFunction("$rt_cls"); consumer.consumeFunction("$rt_cls");
} }
@ -340,7 +340,7 @@ public class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, Me
expr.getExpr().acceptVisitor(this); expr.getExpr().acceptVisitor(this);
visitType(expr.getType()); visitType(expr.getType());
if (expr.getType() instanceof ValueType.Object) { if (expr.getType() instanceof ValueType.Object) {
String clsName = ((ValueType.Object)expr.getType()).getClassName(); String clsName = ((ValueType.Object) expr.getType()).getClassName();
ClassReader cls = classSource.get(clsName); ClassReader cls = classSource.get(clsName);
if (cls == null || cls.hasModifier(ElementModifier.INTERFACE)) { if (cls == null || cls.hasModifier(ElementModifier.INTERFACE)) {
consumer.consumeFunction("$rt_isInstance"); consumer.consumeFunction("$rt_isInstance");

View File

@ -44,7 +44,7 @@ public class NullPointerExceptionTransformer implements ClassHolderTransformer {
for (int i = 0; i < block.getInstructions().size(); ++i) { for (int i = 0; i < block.getInstructions().size(); ++i) {
Instruction insn = block.getInstructions().get(i); Instruction insn = block.getInstructions().get(i);
if (insn instanceof InvokeInstruction) { if (insn instanceof InvokeInstruction) {
InvokeInstruction invoke = (InvokeInstruction)insn; InvokeInstruction invoke = (InvokeInstruction) insn;
if (invoke.getType() != InvocationType.VIRTUAL) { if (invoke.getType() != InvocationType.VIRTUAL) {
continue; continue;
} }

View File

@ -35,11 +35,11 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
} }
private static boolean isZero(Expr expr) { private static boolean isZero(Expr expr) {
return expr instanceof ConstantExpr && Integer.valueOf(0).equals(((ConstantExpr)expr).getValue()); return expr instanceof ConstantExpr && Integer.valueOf(0).equals(((ConstantExpr) expr).getValue());
} }
private static boolean isComparison(Expr expr) { private static boolean isComparison(Expr expr) {
return expr instanceof BinaryExpr && ((BinaryExpr)expr).getOperation() == BinaryOperation.COMPARE; return expr instanceof BinaryExpr && ((BinaryExpr) expr).getOperation() == BinaryOperation.COMPARE;
} }
@Override @Override
@ -55,7 +55,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
expr.getSecondOperand().acceptVisitor(this); expr.getSecondOperand().acceptVisitor(this);
Expr b = resultExpr; Expr b = resultExpr;
if (b instanceof ConstantExpr && expr.getOperation() == BinaryOperation.SUBTRACT) { if (b instanceof ConstantExpr && expr.getOperation() == BinaryOperation.SUBTRACT) {
if (tryMakePositive((ConstantExpr)b)) { if (tryMakePositive((ConstantExpr) b)) {
expr.setOperation(BinaryOperation.ADD); expr.setOperation(BinaryOperation.ADD);
} }
} }
@ -78,7 +78,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
case LESS_OR_EQUALS: case LESS_OR_EQUALS:
case GREATER: case GREATER:
case GREATER_OR_EQUALS: { case GREATER_OR_EQUALS: {
BinaryExpr comparison = (BinaryExpr)p; BinaryExpr comparison = (BinaryExpr) p;
Expr result = BinaryExpr.binary(expr.getOperation(), Expr result = BinaryExpr.binary(expr.getOperation(),
comparison.getFirstOperand(), comparison.getSecondOperand()); comparison.getFirstOperand(), comparison.getSecondOperand());
result.setLocation(comparison.getLocation()); result.setLocation(comparison.getLocation());
@ -102,7 +102,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
expr.getOperand().acceptVisitor(this); expr.getOperand().acceptVisitor(this);
Expr operand = resultExpr; Expr operand = resultExpr;
if (expr.getOperation() == UnaryOperation.NEGATE && operand instanceof ConstantExpr) { if (expr.getOperation() == UnaryOperation.NEGATE && operand instanceof ConstantExpr) {
ConstantExpr constantExpr = (ConstantExpr)operand; ConstantExpr constantExpr = (ConstantExpr) operand;
if (tryMakePositive(constantExpr)) { if (tryMakePositive(constantExpr)) {
resultExpr = expr; resultExpr = expr;
return; return;
@ -114,23 +114,23 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
private boolean tryMakePositive(ConstantExpr constantExpr) { private boolean tryMakePositive(ConstantExpr constantExpr) {
Object value = constantExpr.getValue(); Object value = constantExpr.getValue();
if (value instanceof Integer && (Integer)value < 0) { if (value instanceof Integer && (Integer) value < 0) {
constantExpr.setValue(-(Integer)value); constantExpr.setValue(-(Integer) value);
return true; return true;
} else if (value instanceof Float && (Float)value < 0) { } else if (value instanceof Float && (Float) value < 0) {
constantExpr.setValue(-(Float)value); constantExpr.setValue(-(Float) value);
return true; return true;
} else if (value instanceof Byte && (Byte)value < 0) { } else if (value instanceof Byte && (Byte) value < 0) {
constantExpr.setValue(-(Byte)value); constantExpr.setValue(-(Byte) value);
return true; return true;
} else if (value instanceof Short && (Short)value < 0) { } else if (value instanceof Short && (Short) value < 0) {
constantExpr.setValue(-(Short)value); constantExpr.setValue(-(Short) value);
return true; return true;
} else if (value instanceof Long && (Long)value < 0) { } else if (value instanceof Long && (Long) value < 0) {
constantExpr.setValue(-(Long)value); constantExpr.setValue(-(Long) value);
return true; return true;
} else if (value instanceof Double && (Double)value < 0) { } else if (value instanceof Double && (Double) value < 0) {
constantExpr.setValue(-(Double)value); constantExpr.setValue(-(Double) value);
return true; return true;
} }
return false; return false;
@ -169,16 +169,16 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
if (!(last instanceof AssignmentStatement)) { if (!(last instanceof AssignmentStatement)) {
return; return;
} }
AssignmentStatement assignment = (AssignmentStatement)last; AssignmentStatement assignment = (AssignmentStatement) last;
if (assignment.isAsync()) { if (assignment.isAsync()) {
return; return;
} }
if (!(assignment.getLeftValue() instanceof VariableExpr)) { if (!(assignment.getLeftValue() instanceof VariableExpr)) {
return; return;
} }
VariableExpr var = (VariableExpr)assignment.getLeftValue(); VariableExpr var = (VariableExpr) assignment.getLeftValue();
if (var.getLocation() != null && assignment.getLocation() != null && if (var.getLocation() != null && assignment.getLocation() != null
!assignment.getLocation().equals(var.getLocation())) { && !assignment.getLocation().equals(var.getLocation())) {
return; return;
} }
if (var.getIndex() == index) { if (var.getIndex() == index) {
@ -231,22 +231,22 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
if (!(last instanceof AssignmentStatement)) { if (!(last instanceof AssignmentStatement)) {
return false; return false;
} }
AssignmentStatement assignment = (AssignmentStatement)last; AssignmentStatement assignment = (AssignmentStatement) last;
if (!(assignment.getLeftValue() instanceof VariableExpr)) { if (!(assignment.getLeftValue() instanceof VariableExpr)) {
return false; return false;
} }
VariableExpr var = (VariableExpr)assignment.getLeftValue(); VariableExpr var = (VariableExpr) assignment.getLeftValue();
if (!(expr.getArguments().get(0) instanceof VariableExpr)) { if (!(expr.getArguments().get(0) instanceof VariableExpr)) {
return false; return false;
} }
VariableExpr target = (VariableExpr)expr.getArguments().get(0); VariableExpr target = (VariableExpr) expr.getArguments().get(0);
if (target.getIndex() != var.getIndex()) { if (target.getIndex() != var.getIndex()) {
return false; return false;
} }
if (!(assignment.getRightValue() instanceof NewExpr)) { if (!(assignment.getRightValue() instanceof NewExpr)) {
return false; return false;
} }
NewExpr constructed = (NewExpr)assignment.getRightValue(); NewExpr constructed = (NewExpr) assignment.getRightValue();
if (!constructed.getConstructedClass().equals(expr.getMethod().getClassName())) { if (!constructed.getConstructedClass().equals(expr.getMethod().getClassName())) {
return false; return false;
} }
@ -306,7 +306,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
public void visit(AssignmentStatement statement) { public void visit(AssignmentStatement statement) {
if (statement.getLeftValue() == null) { if (statement.getLeftValue() == null) {
statement.getRightValue().acceptVisitor(this); statement.getRightValue().acceptVisitor(this);
if (resultExpr instanceof InvocationExpr && tryApplyConstructor((InvocationExpr)resultExpr)) { if (resultExpr instanceof InvocationExpr && tryApplyConstructor((InvocationExpr) resultExpr)) {
resultStmt = new SequentialStatement(); resultStmt = new SequentialStatement();
} else { } else {
statement.setRightValue(resultExpr); statement.setRightValue(resultExpr);
@ -345,7 +345,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
for (int i = 0; i < statements.size(); ++i) { for (int i = 0; i < statements.size(); ++i) {
Statement part = statements.get(i); Statement part = statements.get(i);
if (part instanceof SequentialStatement) { if (part instanceof SequentialStatement) {
if (!processSequenceImpl(((SequentialStatement)part).getSequence())) { if (!processSequenceImpl(((SequentialStatement) part).getSequence())) {
return false; return false;
} }
continue; continue;
@ -353,7 +353,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
part.acceptVisitor(this); part.acceptVisitor(this);
part = resultStmt; part = resultStmt;
if (part instanceof SequentialStatement) { if (part instanceof SequentialStatement) {
if (!processSequenceImpl(((SequentialStatement)part).getSequence())) { if (!processSequenceImpl(((SequentialStatement) part).getSequence())) {
return false; return false;
} }
continue; continue;
@ -369,11 +369,11 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
private void wieldTryCatch(List<Statement> statements) { private void wieldTryCatch(List<Statement> statements) {
for (int i = 0; i < statements.size() - 1; ++i) { for (int i = 0; i < statements.size() - 1; ++i) {
if (statements.get(i) instanceof TryCatchStatement && statements.get(i + 1) instanceof TryCatchStatement) { if (statements.get(i) instanceof TryCatchStatement && statements.get(i + 1) instanceof TryCatchStatement) {
TryCatchStatement first = (TryCatchStatement)statements.get(i); TryCatchStatement first = (TryCatchStatement) statements.get(i);
TryCatchStatement second = (TryCatchStatement)statements.get(i + 1); TryCatchStatement second = (TryCatchStatement) statements.get(i + 1);
if (Objects.equals(first.getExceptionType(), second.getExceptionType()) && if (Objects.equals(first.getExceptionType(), second.getExceptionType())
Objects.equals(first.getExceptionVariable(), second.getExceptionVariable()) && && Objects.equals(first.getExceptionVariable(), second.getExceptionVariable())
briefStatementComparison(first.getHandler(), second.getHandler())) { && briefStatementComparison(first.getHandler(), second.getHandler())) {
first.getProtectedBody().addAll(second.getProtectedBody()); first.getProtectedBody().addAll(second.getProtectedBody());
statements.remove(i + 1); statements.remove(i + 1);
wieldTryCatch(first.getProtectedBody()); wieldTryCatch(first.getProtectedBody());
@ -393,8 +393,8 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
Statement first = firstSeq.get(0); Statement first = firstSeq.get(0);
Statement second = secondSeq.get(0); Statement second = secondSeq.get(0);
if (first instanceof BreakStatement && second instanceof BreakStatement) { if (first instanceof BreakStatement && second instanceof BreakStatement) {
BreakStatement firstBreak = (BreakStatement)first; BreakStatement firstBreak = (BreakStatement) first;
BreakStatement secondBreak = (BreakStatement)second; BreakStatement secondBreak = (BreakStatement) second;
return firstBreak.getTarget() == secondBreak.getTarget(); return firstBreak.getTarget() == secondBreak.getTarget();
} }
return false; return false;
@ -406,7 +406,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
} }
Statement last = statements.get(statements.size() - 1); Statement last = statements.get(statements.size() - 1);
if (last instanceof BreakStatement && exit != null) { if (last instanceof BreakStatement && exit != null) {
IdentifiedStatement target = ((BreakStatement)last).getTarget(); IdentifiedStatement target = ((BreakStatement) last).getTarget();
if (exit == target) { if (exit == target) {
statements.remove(statements.size() - 1); statements.remove(statements.size() - 1);
} }
@ -417,12 +417,12 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
for (int i = 0; i < statements.size(); ++i) { for (int i = 0; i < statements.size(); ++i) {
Statement stmt = statements.get(i); Statement stmt = statements.get(i);
if (stmt instanceof ConditionalStatement) { if (stmt instanceof ConditionalStatement) {
ConditionalStatement cond = (ConditionalStatement)stmt; ConditionalStatement cond = (ConditionalStatement) stmt;
check_conditional: { check_conditional: {
last = cond.getConsequent().isEmpty() ? null : last = cond.getConsequent().isEmpty() ? null
cond.getConsequent().get(cond.getConsequent().size() - 1); : cond.getConsequent().get(cond.getConsequent().size() - 1);
if (last instanceof BreakStatement) { if (last instanceof BreakStatement) {
BreakStatement breakStmt = (BreakStatement)last; BreakStatement breakStmt = (BreakStatement) last;
if (exit != null && exit == breakStmt.getTarget()) { if (exit != null && exit == breakStmt.getTarget()) {
cond.getConsequent().remove(cond.getConsequent().size() - 1); cond.getConsequent().remove(cond.getConsequent().size() - 1);
List<Statement> remaining = statements.subList(i + 1, statements.size()); List<Statement> remaining = statements.subList(i + 1, statements.size());
@ -431,10 +431,10 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
break check_conditional; break check_conditional;
} }
} }
last = cond.getAlternative().isEmpty() ? null : last = cond.getAlternative().isEmpty() ? null
cond.getAlternative().get(cond.getAlternative().size() - 1); : cond.getAlternative().get(cond.getAlternative().size() - 1);
if (last instanceof BreakStatement) { if (last instanceof BreakStatement) {
BreakStatement breakStmt = (BreakStatement)last; BreakStatement breakStmt = (BreakStatement) last;
if (exit != null && exit == breakStmt.getTarget()) { if (exit != null && exit == breakStmt.getTarget()) {
cond.getAlternative().remove(cond.getAlternative().size() - 1); cond.getAlternative().remove(cond.getAlternative().size() - 1);
List<Statement> remaining = statements.subList(i + 1, statements.size()); List<Statement> remaining = statements.subList(i + 1, statements.size());
@ -450,7 +450,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
} }
normalizeConditional(cond); normalizeConditional(cond);
if (cond.getConsequent().size() == 1 && cond.getConsequent().get(0) instanceof ConditionalStatement) { if (cond.getConsequent().size() == 1 && cond.getConsequent().get(0) instanceof ConditionalStatement) {
ConditionalStatement innerCond = (ConditionalStatement)cond.getConsequent().get(0); ConditionalStatement innerCond = (ConditionalStatement) cond.getConsequent().get(0);
if (innerCond.getAlternative().isEmpty()) { if (innerCond.getAlternative().isEmpty()) {
if (cond.getAlternative().isEmpty()) { if (cond.getAlternative().isEmpty()) {
cond.getConsequent().clear(); cond.getConsequent().clear();
@ -458,8 +458,8 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
cond.setCondition(Expr.binary(BinaryOperation.AND, cond.getCondition(), cond.setCondition(Expr.binary(BinaryOperation.AND, cond.getCondition(),
innerCond.getCondition(), cond.getCondition().getLocation())); innerCond.getCondition(), cond.getCondition().getLocation()));
--i; --i;
} else if (cond.getAlternative().size() != 1 || } else if (cond.getAlternative().size() != 1
!(cond.getAlternative().get(0) instanceof ConditionalStatement)) { || !(cond.getAlternative().get(0) instanceof ConditionalStatement)) {
cond.setCondition(ExprOptimizer.invert(cond.getCondition())); cond.setCondition(ExprOptimizer.invert(cond.getCondition()));
cond.getConsequent().clear(); cond.getConsequent().clear();
cond.getConsequent().addAll(cond.getAlternative()); cond.getConsequent().addAll(cond.getAlternative());
@ -470,13 +470,13 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
} }
} }
} else if (stmt instanceof BlockStatement) { } else if (stmt instanceof BlockStatement) {
BlockStatement nestedBlock = (BlockStatement)stmt; BlockStatement nestedBlock = (BlockStatement) stmt;
eliminateRedundantBreaks(nestedBlock.getBody(), nestedBlock); eliminateRedundantBreaks(nestedBlock.getBody(), nestedBlock);
} else if (stmt instanceof WhileStatement) { } else if (stmt instanceof WhileStatement) {
WhileStatement whileStmt = (WhileStatement)stmt; WhileStatement whileStmt = (WhileStatement) stmt;
eliminateRedundantBreaks(whileStmt.getBody(), null); eliminateRedundantBreaks(whileStmt.getBody(), null);
} else if (stmt instanceof SwitchStatement) { } else if (stmt instanceof SwitchStatement) {
SwitchStatement switchStmt = (SwitchStatement)stmt; SwitchStatement switchStmt = (SwitchStatement) stmt;
for (SwitchClause clause : switchStmt.getClauses()) { for (SwitchClause clause : switchStmt.getClauses()) {
eliminateRedundantBreaks(clause.getBody(), null); eliminateRedundantBreaks(clause.getBody(), null);
} }
@ -546,7 +546,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
@Override @Override
public void visit(WhileStatement statement) { public void visit(WhileStatement statement) {
if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) { if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) {
WhileStatement innerLoop = (WhileStatement)statement.getBody().get(0); WhileStatement innerLoop = (WhileStatement) statement.getBody().get(0);
BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement); BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement);
replacer.visitSequence(innerLoop.getBody()); replacer.visitSequence(innerLoop.getBody());
statement.getBody().clear(); statement.getBody().clear();
@ -555,7 +555,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
List<Statement> statements = processSequence(statement.getBody()); List<Statement> statements = processSequence(statement.getBody());
for (int i = 0; i < statements.size(); ++i) { for (int i = 0; i < statements.size(); ++i) {
if (statements.get(i) instanceof ContinueStatement) { if (statements.get(i) instanceof ContinueStatement) {
ContinueStatement continueStmt = (ContinueStatement)statements.get(i); ContinueStatement continueStmt = (ContinueStatement) statements.get(i);
if (continueStmt.getTarget() == statement) { if (continueStmt.getTarget() == statement) {
statements.subList(i, statements.size()).clear(); statements.subList(i, statements.size()).clear();
break; break;
@ -573,9 +573,9 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
} }
while (true) { while (true) {
if (!statement.getBody().isEmpty() && statement.getBody().get(0) instanceof ConditionalStatement) { if (!statement.getBody().isEmpty() && statement.getBody().get(0) instanceof ConditionalStatement) {
ConditionalStatement cond = (ConditionalStatement)statement.getBody().get(0); ConditionalStatement cond = (ConditionalStatement) statement.getBody().get(0);
if (cond.getConsequent().size() == 1 && cond.getConsequent().get(0) instanceof BreakStatement) { if (cond.getConsequent().size() == 1 && cond.getConsequent().get(0) instanceof BreakStatement) {
BreakStatement breakStmt = (BreakStatement)cond.getConsequent().get(0); BreakStatement breakStmt = (BreakStatement) cond.getConsequent().get(0);
if (breakStmt.getTarget() == statement) { if (breakStmt.getTarget() == statement) {
statement.getBody().remove(0); statement.getBody().remove(0);
if (statement.getCondition() != null) { if (statement.getCondition() != null) {

View File

@ -363,8 +363,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
new MethodDescriptor("<clinit>", ValueType.VOID)); new MethodDescriptor("<clinit>", ValueType.VOID));
List<MethodNode> clinitMethods = new ArrayList<>(); List<MethodNode> clinitMethods = new ArrayList<>();
for (MethodNode method : cls.getMethods()) { for (MethodNode method : cls.getMethods()) {
if (clinit == null || (!method.getModifiers().contains(NodeModifier.STATIC) && if (clinit == null || (!method.getModifiers().contains(NodeModifier.STATIC)
!method.getReference().getName().equals("<init>"))) { && !method.getReference().getName().equals("<init>"))) {
nonInitMethods.add(method); nonInitMethods.add(method);
} else { } else {
clinitMethods.add(method); clinitMethods.add(method);
@ -451,8 +451,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
List<String> stubNames = new ArrayList<>(); List<String> stubNames = new ArrayList<>();
List<MethodNode> virtualMethods = new ArrayList<>(); List<MethodNode> virtualMethods = new ArrayList<>();
for (MethodNode method : cls.getMethods()) { for (MethodNode method : cls.getMethods()) {
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC) || if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC)
method.getReference().getName().equals("<init>"))) { || method.getReference().getName().equals("<init>"))) {
stubNames.add(naming.getFullNameFor(method.getReference())); stubNames.add(naming.getFullNameFor(method.getReference()));
} }
if (!method.getModifiers().contains(NodeModifier.STATIC)) { if (!method.getModifiers().contains(NodeModifier.STATIC)) {
@ -485,14 +485,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
private static Object getDefaultValue(ValueType type) { private static Object getDefaultValue(ValueType type) {
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
ValueType.Primitive primitive = (ValueType.Primitive)type; ValueType.Primitive primitive = (ValueType.Primitive) type;
switch (primitive.getKind()) { switch (primitive.getKind()) {
case BOOLEAN: case BOOLEAN:
return false; return false;
case BYTE: case BYTE:
return (byte)0; return (byte) 0;
case SHORT: case SHORT:
return (short)0; return (short) 0;
case INTEGER: case INTEGER:
return 0; return 0;
case CHARACTER: case CHARACTER:
@ -893,7 +893,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
popLocation(); popLocation();
} }
if (statement.getLeftValue() instanceof VariableExpr) { if (statement.getLeftValue() instanceof VariableExpr) {
VariableExpr receiver = (VariableExpr)statement.getLeftValue(); VariableExpr receiver = (VariableExpr) statement.getLeftValue();
debugEmitter.emitVariable(statement.getDebugNames().toArray(new String[0]), debugEmitter.emitVariable(statement.getDebugNames().toArray(new String[0]),
variableName(receiver.getIndex())); variableName(receiver.getIndex()));
} }
@ -928,9 +928,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
visitStatements(statement.getConsequent()); visitStatements(statement.getConsequent());
if (!statement.getAlternative().isEmpty()) { if (!statement.getAlternative().isEmpty()) {
writer.outdent().append("}").ws(); writer.outdent().append("}").ws();
if (statement.getAlternative().size() == 1 && if (statement.getAlternative().size() == 1
statement.getAlternative().get(0) instanceof ConditionalStatement) { && statement.getAlternative().get(0) instanceof ConditionalStatement) {
statement = (ConditionalStatement)statement.getAlternative().get(0); statement = (ConditionalStatement) statement.getAlternative().get(0);
writer.append("else "); writer.append("else ");
continue; continue;
} }
@ -1194,8 +1194,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
if (index < variableNames.length()) { if (index < variableNames.length()) {
sb.append(Character.toString(variableNames.charAt(index))); sb.append(Character.toString(variableNames.charAt(index)));
} else { } else {
sb.append(Character.toString(variableNames.charAt(index % variableNames.length())) + sb.append(Character.toString(variableNames.charAt(index % variableNames.length()))
index / variableNames.length()); + index / variableNames.length());
} }
if (!minifying && names != null && !names.isEmpty()) { if (!minifying && names != null && !names.isEmpty()) {
List<String> nameList = new ArrayList<>(names); List<String> nameList = new ArrayList<>(names);
@ -1249,9 +1249,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
precedence.associativity = this.associativity; precedence.associativity = this.associativity;
precedenceStack.push(precedence); precedenceStack.push(precedence);
wasGrouped = false; wasGrouped = false;
if (autoGroup && (priority.ordinal() < this.priority.ordinal() || if (autoGroup && (priority.ordinal() < this.priority.ordinal()
priority.ordinal() == this.priority.ordinal() && || priority.ordinal() == this.priority.ordinal()
(associativity != this.associativity || associativity == Associativity.NONE))) { && (associativity != this.associativity || associativity == Associativity.NONE))) {
wasGrouped = true; wasGrouped = true;
writer.append('('); writer.append('(');
} }
@ -1548,10 +1548,10 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
return "null"; return "null";
} }
if (cst instanceof ValueType) { if (cst instanceof ValueType) {
ValueType type = (ValueType)cst; ValueType type = (ValueType) cst;
return naming.getNameForFunction("$rt_cls") + "(" + typeToClsString(naming, type) + ")"; return naming.getNameForFunction("$rt_cls") + "(" + typeToClsString(naming, type) + ")";
} else if (cst instanceof String) { } else if (cst instanceof String) {
String string = (String)cst; String string = (String) cst;
Integer index = stringPoolMap.get(string); Integer index = stringPoolMap.get(string);
if (index == null) { if (index == null) {
index = stringPool.size(); index = stringPool.size();
@ -1560,16 +1560,16 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
} }
return "$rt_s(" + index + ")"; return "$rt_s(" + index + ")";
} else if (cst instanceof Long) { } else if (cst instanceof Long) {
long value = (Long)cst; long value = (Long) cst;
if (value == 0) { if (value == 0) {
return "Long_ZERO"; return "Long_ZERO";
} else if ((int)value == value) { } else if ((int) value == value) {
return "Long_fromInt(" + value + ")"; return "Long_fromInt(" + value + ")";
} else { } else {
return "new Long(" + (value & 0xFFFFFFFFL) + ", " + (value >>> 32) + ")"; return "new Long(" + (value & 0xFFFFFFFFL) + ", " + (value >>> 32) + ")";
} }
} else if (cst instanceof Character) { } else if (cst instanceof Character) {
return Integer.toString((Character)cst); return Integer.toString((Character) cst);
} else { } else {
return cst.toString(); return cst.toString();
} }
@ -1579,16 +1579,16 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
int arrayCount = 0; int arrayCount = 0;
while (type instanceof ValueType.Array) { while (type instanceof ValueType.Array) {
arrayCount++; arrayCount++;
type = ((ValueType.Array)type).getItemType(); type = ((ValueType.Array) type).getItemType();
} }
String value; String value;
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
ValueType.Object objType = (ValueType.Object)type; ValueType.Object objType = (ValueType.Object) type;
value = naming.getNameFor(objType.getClassName()); value = naming.getNameFor(objType.getClassName());
} else if (type instanceof ValueType.Void) { } else if (type instanceof ValueType.Void) {
value = "$rt_voidcls()"; value = "$rt_voidcls()";
} else if (type instanceof ValueType.Primitive) { } else if (type instanceof ValueType.Primitive) {
ValueType.Primitive primitiveType = (ValueType.Primitive)type; ValueType.Primitive primitiveType = (ValueType.Primitive) type;
switch (primitiveType.getKind()) { switch (primitiveType.getKind()) {
case BOOLEAN: case BOOLEAN:
value = "$rt_booleancls()"; value = "$rt_booleancls()";
@ -1854,7 +1854,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
ValueType type = expr.getType(); ValueType type = expr.getType();
enterPriority(Priority.COMMA, Associativity.NONE, false); enterPriority(Priority.COMMA, Associativity.NONE, false);
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
writer.append("$rt_createBooleanArray("); writer.append("$rt_createBooleanArray(");
expr.getLength().acceptVisitor(this); expr.getLength().acceptVisitor(this);
@ -1919,11 +1919,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
} }
ValueType type = expr.getType(); ValueType type = expr.getType();
for (int i = 0; i < expr.getDimensions().size(); ++i) { for (int i = 0; i < expr.getDimensions().size(); ++i) {
type = ((ValueType.Array)type).getItemType(); type = ((ValueType.Array) type).getItemType();
} }
enterPriority(Priority.COMMA, Associativity.NONE, false); enterPriority(Priority.COMMA, Associativity.NONE, false);
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
writer.append("$rt_createBooleanMultiArray("); writer.append("$rt_createBooleanMultiArray(");
break; break;
@ -1981,7 +1981,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
pushLocation(expr.getLocation()); pushLocation(expr.getLocation());
} }
if (expr.getType() instanceof ValueType.Object) { if (expr.getType() instanceof ValueType.Object) {
String clsName = ((ValueType.Object)expr.getType()).getClassName(); String clsName = ((ValueType.Object) expr.getType()).getClassName();
ClassHolder cls = classSource.get(clsName); ClassHolder cls = classSource.get(clsName);
if (cls != null && !cls.getModifiers().contains(ElementModifier.INTERFACE)) { if (cls != null && !cls.getModifiers().contains(ElementModifier.INTERFACE)) {
enterPriority(Priority.COMPARISON, Associativity.LEFT, true); enterPriority(Priority.COMPARISON, Associativity.LEFT, true);
@ -2041,7 +2041,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
sequence.add(statement); sequence.add(statement);
List<Statement> protectedBody = statement.getProtectedBody(); List<Statement> protectedBody = statement.getProtectedBody();
while (protectedBody.size() == 1 && protectedBody.get(0) instanceof TryCatchStatement) { while (protectedBody.size() == 1 && protectedBody.get(0) instanceof TryCatchStatement) {
TryCatchStatement nextStatement = (TryCatchStatement)protectedBody.get(0); TryCatchStatement nextStatement = (TryCatchStatement) protectedBody.get(0);
sequence.add(nextStatement); sequence.add(nextStatement);
protectedBody = nextStatement.getProtectedBody(); protectedBody = nextStatement.getProtectedBody();
} }
@ -2082,7 +2082,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
if (!end || statement.getPart() != currentPart + 1) { if (!end || statement.getPart() != currentPart + 1) {
writer.append("continue ").append(mainLoopName()).append(";").softNewLine(); writer.append("continue ").append(mainLoopName()).append(";").softNewLine();
} }
} catch (IOException ex){ } catch (IOException ex) {
throw new RenderingException("IO error occured", ex); throw new RenderingException("IO error occured", ex);
} }
} }
@ -2104,7 +2104,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
statement.getObjectRef().acceptVisitor(this); statement.getObjectRef().acceptVisitor(this);
writer.append(");").softNewLine(); writer.append(");").softNewLine();
} }
} catch (IOException ex){ } catch (IOException ex) {
throw new RenderingException("IO error occured", ex); throw new RenderingException("IO error occured", ex);
} }
} }
@ -2132,7 +2132,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
statement.getObjectRef().acceptVisitor(this); statement.getObjectRef().acceptVisitor(this);
writer.append(");").softNewLine(); writer.append(");").softNewLine();
} }
} catch (IOException ex){ } catch (IOException ex) {
throw new RenderingException("IO error occured", ex); throw new RenderingException("IO error occured", ex);
} }
} }
@ -2149,7 +2149,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
AnnotationHolder injectedByAnnot = method.getAnnotations().get(InjectedBy.class.getName()); AnnotationHolder injectedByAnnot = method.getAnnotations().get(InjectedBy.class.getName());
if (injectedByAnnot != null) { if (injectedByAnnot != null) {
ValueType type = injectedByAnnot.getValues().get("value").getJavaClass(); ValueType type = injectedByAnnot.getValues().get("value").getJavaClass();
holder = new InjectorHolder(instantiateInjector(((ValueType.Object)type).getClassName())); holder = new InjectorHolder(instantiateInjector(((ValueType.Object) type).getClassName()));
} }
} }
} }

View File

@ -437,8 +437,8 @@ class StatementGenerator implements InstructionVisitor {
@Override @Override
public void visit(ExitInstruction insn) { public void visit(ExitInstruction insn) {
ReturnStatement stmt = Statement.exitFunction(insn.getValueToReturn() != null ? ReturnStatement stmt = Statement.exitFunction(insn.getValueToReturn() != null
Expr.var(insn.getValueToReturn().getIndex()) : null); ? Expr.var(insn.getValueToReturn().getIndex()) : null);
stmt.setLocation(currentLocation); stmt.setLocation(currentLocation);
statements.add(stmt); statements.add(stmt);
} }

View File

@ -49,7 +49,7 @@ public class UnwrapArrayExpr extends Expr {
@Override @Override
protected UnwrapArrayExpr clone(Map<Expr, Expr> cache) { protected UnwrapArrayExpr clone(Map<Expr, Expr> cache) {
UnwrapArrayExpr copy = (UnwrapArrayExpr)cache.get(this); UnwrapArrayExpr copy = (UnwrapArrayExpr) cache.get(this);
if (copy == null) { if (copy == null) {
copy = new UnwrapArrayExpr(elementType); copy = new UnwrapArrayExpr(elementType);
copy.array = array != null ? array.clone(cache) : null; copy.array = array != null ? array.clone(cache) : null;

View File

@ -102,63 +102,63 @@ public class AnnotationValue {
if (type != BOOLEAN) { if (type != BOOLEAN) {
throw new IllegalStateException("There is no boolean value"); throw new IllegalStateException("There is no boolean value");
} }
return (Boolean)value; return (Boolean) value;
} }
public byte getByte() { public byte getByte() {
if (type != BYTE) { if (type != BYTE) {
throw new IllegalStateException("There is no byte value"); throw new IllegalStateException("There is no byte value");
} }
return (Byte)value; return (Byte) value;
} }
public short getShort() { public short getShort() {
if (type != SHORT) { if (type != SHORT) {
throw new IllegalStateException("There is no short value"); throw new IllegalStateException("There is no short value");
} }
return (Short)value; return (Short) value;
} }
public int getInt() { public int getInt() {
if (type != INT) { if (type != INT) {
throw new IllegalStateException("There is no int value"); throw new IllegalStateException("There is no int value");
} }
return (Integer)value; return (Integer) value;
} }
public long getLong() { public long getLong() {
if (type != LONG) { if (type != LONG) {
throw new IllegalStateException("There is no long value"); throw new IllegalStateException("There is no long value");
} }
return (Long)value; return (Long) value;
} }
public float getFloat() { public float getFloat() {
if (type != FLOAT) { if (type != FLOAT) {
throw new IllegalStateException("There is no float value"); throw new IllegalStateException("There is no float value");
} }
return (Float)value; return (Float) value;
} }
public double getDouble() { public double getDouble() {
if (type != DOUBLE) { if (type != DOUBLE) {
throw new IllegalStateException("There is no double value"); throw new IllegalStateException("There is no double value");
} }
return (Double)value; return (Double) value;
} }
public String getString() { public String getString() {
if (type != STRING) { if (type != STRING) {
throw new IllegalStateException("There is no String value"); throw new IllegalStateException("There is no String value");
} }
return (String)value; return (String) value;
} }
public ValueType getJavaClass() { public ValueType getJavaClass() {
if (type != CLASS) { if (type != CLASS) {
throw new IllegalStateException("There is no ValueType value"); throw new IllegalStateException("There is no ValueType value");
} }
return (ValueType)value; return (ValueType) value;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -166,21 +166,21 @@ public class AnnotationValue {
if (type != LIST) { if (type != LIST) {
throw new IllegalStateException("There is no List value"); throw new IllegalStateException("There is no List value");
} }
return Collections.unmodifiableList((List<AnnotationValue>)value); return Collections.unmodifiableList((List<AnnotationValue>) value);
} }
public FieldReference getEnumValue() { public FieldReference getEnumValue() {
if (type != ENUM) { if (type != ENUM) {
throw new IllegalStateException("There is no enum value"); throw new IllegalStateException("There is no enum value");
} }
return (FieldReference)value; return (FieldReference) value;
} }
public AnnotationReader getAnnotation() { public AnnotationReader getAnnotation() {
if (type != ANNOTATION) { if (type != ANNOTATION) {
throw new IllegalStateException("There is no annotation value"); throw new IllegalStateException("There is no annotation value");
} }
return (AnnotationReader)value; return (AnnotationReader) value;
} }
public byte getType() { public byte getType() {

View File

@ -58,7 +58,7 @@ public class CallLocation {
if (!(obj instanceof CallLocation)) { if (!(obj instanceof CallLocation)) {
return false; return false;
} }
CallLocation other = (CallLocation)obj; CallLocation other = (CallLocation) obj;
return Objects.equals(method, other.method) && Objects.equals(sourceLocation, other.sourceLocation); return Objects.equals(method, other.method) && Objects.equals(sourceLocation, other.sourceLocation);
} }
} }

View File

@ -58,8 +58,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
public void addMethod(MethodHolder method) { public void addMethod(MethodHolder method) {
if (method.getOwner() != null) { if (method.getOwner() != null) {
throw new IllegalArgumentException("Method " + method.getDescriptor() + throw new IllegalArgumentException("Method " + method.getDescriptor()
" is already in another class (" + method.getOwner().getName() + ")"); + " is already in another class (" + method.getOwner().getName() + ")");
} }
method.setOwner(this); method.setOwner(this);
MethodHolder oldMethod = methods.put(method.getDescriptor(), method); MethodHolder oldMethod = methods.put(method.getDescriptor(), method);
@ -70,8 +70,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
public void removeMethod(MethodHolder method) { public void removeMethod(MethodHolder method) {
if (method.getOwner() != this) { if (method.getOwner() != this) {
throw new IllegalArgumentException("Method " + method.getOwner().getName() + throw new IllegalArgumentException("Method " + method.getOwner().getName()
"." + method.getDescriptor() + " is not a member of " + getName()); + "." + method.getDescriptor() + " is not a member of " + getName());
} }
methods.remove(method.getDescriptor()); methods.remove(method.getDescriptor());
method.setOwner(null); method.setOwner(null);
@ -89,8 +89,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
public void addField(FieldHolder field) { public void addField(FieldHolder field) {
if (field.getOwner() != null) { if (field.getOwner() != null) {
throw new IllegalArgumentException("Field " + field.getName() + " is already " + throw new IllegalArgumentException("Field " + field.getName() + " is already "
"in another class (" + field.getOwner().getName() + ")"); + "in another class (" + field.getOwner().getName() + ")");
} }
field.setOwner(this); field.setOwner(this);
FieldHolder oldField = fields.put(field.getName(), field); FieldHolder oldField = fields.put(field.getName(), field);
@ -101,8 +101,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
public void removeField(FieldHolder field) { public void removeField(FieldHolder field) {
if (field.getOwner() != this) { if (field.getOwner() != this) {
throw new IllegalArgumentException("Field " + field.getOwner().getName() + "." + throw new IllegalArgumentException("Field " + field.getOwner().getName() + "."
field.getName() + " is not a member of " + getName()); + field.getName() + " is not a member of " + getName());
} }
fields.remove(field.getName()); fields.remove(field.getName());
field.setOwner(null); field.setOwner(null);

View File

@ -49,7 +49,7 @@ public class FieldReference {
if (!(obj instanceof FieldReference)) { if (!(obj instanceof FieldReference)) {
return false; return false;
} }
FieldReference other = (FieldReference)obj; FieldReference other = (FieldReference) obj;
return className.equals(other.className) && fieldName.equals(other.fieldName); return className.equals(other.className) && fieldName.equals(other.fieldName);
} }

View File

@ -55,7 +55,7 @@ public class InstructionLocation {
if (!(obj instanceof InstructionLocation)) { if (!(obj instanceof InstructionLocation)) {
return false; return false;
} }
InstructionLocation other = (InstructionLocation)obj; InstructionLocation other = (InstructionLocation) obj;
return Objects.equals(fileName, other.fileName) && line == other.line; return Objects.equals(fileName, other.fileName) && line == other.line;
} }

View File

@ -67,8 +67,7 @@ public class MethodDescriptor {
public ValueType parameterType(int index) { public ValueType parameterType(int index) {
if (index >= signature.length - 1) { if (index >= signature.length - 1) {
throw new IndexOutOfBoundsException(String.valueOf(index) + "/" + throw new IndexOutOfBoundsException(String.valueOf(index) + "/" + (signature.length - 1));
(signature.length - 1));
} }
return signature[index]; return signature[index];
} }

View File

@ -127,7 +127,7 @@ public class MethodReference {
if (!(obj instanceof MethodReference)) { if (!(obj instanceof MethodReference)) {
return false; return false;
} }
MethodReference other = (MethodReference)obj; MethodReference other = (MethodReference) obj;
return toString().equals(other.toString()); return toString().equals(other.toString());
} }

View File

@ -296,7 +296,7 @@ public abstract class ValueType {
if (supertype instanceof ValueType.Object) { if (supertype instanceof ValueType.Object) {
return !(this instanceof Primitive); return !(this instanceof Primitive);
} else if (supertype instanceof Array && this instanceof Array) { } else if (supertype instanceof Array && this instanceof Array) {
return ((Array)this).getItemType().isSubtypeOf(((Array)supertype).getItemType()); return ((Array) this).getItemType().isSubtypeOf(((Array) supertype).getItemType());
} else { } else {
return false; return false;
} }

View File

@ -138,10 +138,10 @@ public class AsyncMethodFinder {
if (method == null) { if (method == null) {
return; return;
} }
if (method.getAnnotations().get(Sync.class.getName()) != null || if (method.getAnnotations().get(Sync.class.getName()) != null
method.getAnnotations().get(InjectedBy.class.getName()) != null) { || method.getAnnotations().get(InjectedBy.class.getName()) != null) {
diagnostics.error(new CallLocation(methodRef), "Method {{m0}} is claimed to be synchronous, " + diagnostics.error(new CallLocation(methodRef), "Method {{m0}} is claimed to be synchronous, "
"but it is has invocations of asynchronous methods", methodRef); + "but it is has invocations of asynchronous methods", methodRef);
return; return;
} }
for (CallSite callSite : node.getCallerCallSites()) { for (CallSite callSite : node.getCallerCallSites()) {

View File

@ -64,7 +64,7 @@ public class AsyncProgramSplitter {
for (int i = 0; i < sourceBlock.getInstructions().size(); ++i) { for (int i = 0; i < sourceBlock.getInstructions().size(); ++i) {
Instruction insn = sourceBlock.getInstructions().get(i); Instruction insn = sourceBlock.getInstructions().get(i);
if (insn instanceof InvokeInstruction) { if (insn instanceof InvokeInstruction) {
InvokeInstruction invoke = (InvokeInstruction)insn; InvokeInstruction invoke = (InvokeInstruction) insn;
if (!asyncMethods.contains(findRealMethod(invoke.getMethod()))) { if (!asyncMethods.contains(findRealMethod(invoke.getMethod()))) {
continue; continue;
} }
@ -92,7 +92,7 @@ public class AsyncProgramSplitter {
// If this instruction already separates program, end with current block and refer to the // If this instruction already separates program, end with current block and refer to the
// existing part // existing part
long key = ((long)step.source << 32) | i; long key = ((long) step.source << 32) | i;
if (partMap.containsKey(key)) { if (partMap.containsKey(key)) {
step.targetPart.blockSuccessors[targetBlock.getIndex()] = partMap.get(key); step.targetPart.blockSuccessors[targetBlock.getIndex()] = partMap.get(key);
continue taskLoop; continue taskLoop;

View File

@ -107,7 +107,7 @@ class InterferenceGraphBuilder {
for (int i = 0; i < program.basicBlockCount(); ++i) { for (int i = 0; i < program.basicBlockCount(); ++i) {
BasicBlock block = program.basicBlockAt(i); BasicBlock block = program.basicBlockAt(i);
for (Phi phi : block.getPhis()) { for (Phi phi : block.getPhis()) {
for(Incoming incoming : phi.getIncomings()) { for (Incoming incoming : phi.getIncomings()) {
outgoings.get(incoming.getSource().getIndex()).add(incoming); outgoings.get(incoming.getSource().getIndex()).add(incoming);
} }
} }

View File

@ -67,8 +67,8 @@ public class ListingBuilder {
block.readInstruction(j, stringifier); block.readInstruction(j, stringifier);
if (!Objects.equals(location, stringifier.getLocation())) { if (!Objects.equals(location, stringifier.getLocation())) {
location = stringifier.getLocation(); location = stringifier.getLocation();
sb.append(prefix).append(" at ").append(location != null ? location.toString() : sb.append(prefix).append(" at ").append(location != null ? location.toString()
"unknown location").append('\n'); : "unknown location").append('\n');
} }
sb.append(prefix).append(" ").append(insnSb).append("\n"); sb.append(prefix).append(" ").append(insnSb).append("\n");
} }

View File

@ -35,7 +35,7 @@ public class LivenessAnalyzer {
} }
public BitSet liveIn(int block) { public BitSet liveIn(int block) {
return (BitSet)liveVars[block].clone(); return (BitSet) liveVars[block].clone();
} }
public void analyze(Program program) { public void analyze(Program program) {

View File

@ -137,10 +137,10 @@ public class MissingItemsProcessor {
private boolean checkClass(InstructionLocation location, ValueType type) { private boolean checkClass(InstructionLocation location, ValueType type) {
while (type instanceof ValueType.Array) { while (type instanceof ValueType.Array) {
type = ((ValueType.Array)type).getItemType(); type = ((ValueType.Array) type).getItemType();
} }
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
return checkClass(location, ((ValueType.Object)type).getClassName()); return checkClass(location, ((ValueType.Object) type).getClassName());
} }
return true; return true;
} }

View File

@ -171,7 +171,7 @@ public class RegisterAllocator {
if (!(insn instanceof AssignInstruction)) { if (!(insn instanceof AssignInstruction)) {
continue; continue;
} }
AssignInstruction assignment = (AssignInstruction)insn; AssignInstruction assignment = (AssignInstruction) insn;
boolean interfere = false; boolean interfere = false;
int copyClass = congruenceClasses.find(assignment.getReceiver().getIndex()); int copyClass = congruenceClasses.find(assignment.getReceiver().getIndex());
int origClass = congruenceClasses.find(assignment.getAssignee().getIndex()); int origClass = congruenceClasses.find(assignment.getAssignee().getIndex());

View File

@ -62,8 +62,8 @@ public class TypeInferer {
Graph graph = builder.build(); Graph graph = builder.build();
Graph arrayElemGraph = builder.build(); Graph arrayElemGraph = builder.build();
for (int i = 0; i < sz; ++i) { for (int i = 0; i < sz; ++i) {
if ((i >= graph.size() || graph.incomingEdgesCount(i) == 0) && if ((i >= graph.size() || graph.incomingEdgesCount(i) == 0)
(i >= arrayElemGraph.size() || arrayElemGraph.incomingEdgesCount(i) == 0)) { && (i >= arrayElemGraph.size() || arrayElemGraph.incomingEdgesCount(i) == 0)) {
stack.push(i); stack.push(i);
} }
} }
@ -110,7 +110,7 @@ public class TypeInferer {
VariableType convert(ValueType type) { VariableType convert(ValueType type) {
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
case BYTE: case BYTE:
case SHORT: case SHORT:
@ -125,7 +125,7 @@ public class TypeInferer {
return VariableType.LONG; return VariableType.LONG;
} }
} else if (type instanceof ValueType.Array) { } else if (type instanceof ValueType.Array) {
ValueType item = ((ValueType.Array)type).getItemType(); ValueType item = ((ValueType.Array) type).getItemType();
return convertArray(item); return convertArray(item);
} }
return VariableType.OBJECT; return VariableType.OBJECT;
@ -189,7 +189,7 @@ public class TypeInferer {
VariableType convertArray(ValueType type) { VariableType convertArray(ValueType type) {
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
case BYTE: case BYTE:
return VariableType.BYTE_ARRAY; return VariableType.BYTE_ARRAY;

View File

@ -151,8 +151,8 @@ public class UsageExtractor implements InstructionVisitor {
@Override @Override
public void visit(PutFieldInstruction insn) { public void visit(PutFieldInstruction insn) {
usedVariables = insn.getInstance() != null ? new Variable[] { insn.getInstance(), insn.getValue() } : usedVariables = insn.getInstance() != null ? new Variable[] { insn.getInstance(), insn.getValue() }
new Variable[] { insn.getValue() }; : new Variable[] { insn.getValue() };
} }
@Override @Override

View File

@ -40,7 +40,7 @@ public class ArrayUnwrapMotion implements MethodOptimization {
for (int i = 0; i < instructions.size(); ++i) { for (int i = 0; i < instructions.size(); ++i) {
Instruction insn = instructions.get(i); Instruction insn = instructions.get(i);
if (insn instanceof UnwrapArrayInstruction) { if (insn instanceof UnwrapArrayInstruction) {
UnwrapArrayInstruction unwrap = (UnwrapArrayInstruction)insn; UnwrapArrayInstruction unwrap = (UnwrapArrayInstruction) insn;
instructions.set(i, new EmptyInstruction()); instructions.set(i, new EmptyInstruction());
int def = whereDefined(instructions, i, unwrap.getArray()); int def = whereDefined(instructions, i, unwrap.getArray());
if (def < 0) { if (def < 0) {

View File

@ -49,7 +49,7 @@ public class Devirtualization {
if (!(insn instanceof InvokeInstruction)) { if (!(insn instanceof InvokeInstruction)) {
continue; continue;
} }
InvokeInstruction invoke = (InvokeInstruction)insn; InvokeInstruction invoke = (InvokeInstruction) insn;
if (invoke.getType() != InvocationType.VIRTUAL) { if (invoke.getType() != InvocationType.VIRTUAL) {
continue; continue;
} }

View File

@ -35,9 +35,9 @@ public class EmptyBlockElimination implements MethodOptimization {
int lastNonEmpty = program.basicBlockCount() - 1; int lastNonEmpty = program.basicBlockCount() - 1;
for (int i = program.basicBlockCount() - 2; i > 0; --i) { for (int i = program.basicBlockCount() - 2; i > 0; --i) {
BasicBlock block = program.basicBlockAt(i); BasicBlock block = program.basicBlockAt(i);
if (block.getPhis().isEmpty() && block.getInstructions().size() == 1 && if (block.getPhis().isEmpty() && block.getInstructions().size() == 1
block.getLastInstruction() instanceof JumpInstruction) { && block.getLastInstruction() instanceof JumpInstruction) {
JumpInstruction insn = (JumpInstruction)block.getLastInstruction(); JumpInstruction insn = (JumpInstruction) block.getLastInstruction();
if (insn.getTarget().getIndex() == i + 1) { if (insn.getTarget().getIndex() == i + 1) {
blockMapping[i] = lastNonEmpty; blockMapping[i] = lastNonEmpty;
} }

View File

@ -91,10 +91,10 @@ public class ClassRefsRenamer implements InstructionVisitor {
private ValueType rename(ValueType type) { private ValueType rename(ValueType type) {
if (type instanceof ValueType.Array) { if (type instanceof ValueType.Array) {
ValueType itemType = ((ValueType.Array)type).getItemType(); ValueType itemType = ((ValueType.Array) type).getItemType();
return ValueType.arrayOf(rename(itemType)); return ValueType.arrayOf(rename(itemType));
} else if (type instanceof ValueType.Object) { } else if (type instanceof ValueType.Object) {
String className = ((ValueType.Object)type).getClassName(); String className = ((ValueType.Object) type).getClassName();
return ValueType.object(classNameMapper.map(className)); return ValueType.object(classNameMapper.map(className));
} else { } else {
return type; return type;
@ -103,8 +103,8 @@ public class ClassRefsRenamer implements InstructionVisitor {
private void rename(AnnotationContainer source, AnnotationContainer target) { private void rename(AnnotationContainer source, AnnotationContainer target) {
for (AnnotationHolder annot : source.all()) { for (AnnotationHolder annot : source.all()) {
if (!annot.getType().equals(Rename.class.getName()) && if (!annot.getType().equals(Rename.class.getName())
!annot.getType().equals(Superclass.class.getName())) { && !annot.getType().equals(Superclass.class.getName())) {
target.add(rename(annot)); target.add(rename(annot));
} }
} }
@ -287,11 +287,9 @@ public class ClassRefsRenamer implements InstructionVisitor {
@Override @Override
public void visit(MonitorEnterInstruction insn) { public void visit(MonitorEnterInstruction insn) {
} }
@Override @Override
public void visit(MonitorExitInstruction insn) { public void visit(MonitorExitInstruction insn) {
} }
} }

View File

@ -99,8 +99,8 @@ public class ClasspathResourceMapper implements Mapper<String, ClassHolder>, Cla
int index = name.lastIndexOf('.'); int index = name.lastIndexOf('.');
String className = name.substring(index + 1); String className = name.substring(index + 1);
String packageName = index > 0 ? name.substring(0, index) : ""; String packageName = index > 0 ? name.substring(0, index) : "";
ClassHolder classHolder = innerMapper.map(transformation.packagePrefix + packageName + ClassHolder classHolder = innerMapper.map(transformation.packagePrefix + packageName
"." + transformation.classPrefix + className); + "." + transformation.classPrefix + className);
if (classHolder != null) { if (classHolder != null) {
classHolder = renamer.rename(classHolder); classHolder = renamer.rename(classHolder);
} }
@ -117,8 +117,8 @@ public class ClasspathResourceMapper implements Mapper<String, ClassHolder>, Cla
String className = name.substring(index + 1); String className = name.substring(index + 1);
String packageName = name.substring(0, index); String packageName = name.substring(0, index);
if (className.startsWith(transformation.classPrefix)) { if (className.startsWith(transformation.classPrefix)) {
return packageName.substring(transformation.packagePrefix.length()) + "." + return packageName.substring(transformation.packagePrefix.length()) + "."
className.substring(transformation.classPrefix.length()); + className.substring(transformation.classPrefix.length());
} }
} }
} }

View File

@ -75,7 +75,7 @@ public final class Parser {
} }
} }
for (Object obj : node.fields) { for (Object obj : node.fields) {
FieldNode fieldNode = (FieldNode)obj; FieldNode fieldNode = (FieldNode) obj;
cls.addField(parseField(fieldNode)); cls.addField(parseField(fieldNode));
} }
String fullFileName = node.name.substring(0, node.name.lastIndexOf('/') + 1) + node.sourceFile; String fullFileName = node.name.substring(0, node.name.lastIndexOf('/') + 1) + node.sourceFile;
@ -172,7 +172,7 @@ public final class Parser {
annotNodes.addAll(invisibleAnnotations); annotNodes.addAll(invisibleAnnotations);
} }
for (Object obj : annotNodes) { for (Object obj : annotNodes) {
AnnotationNode annotNode = (AnnotationNode)obj; AnnotationNode annotNode = (AnnotationNode) obj;
String desc = annotNode.desc; String desc = annotNode.desc;
if (desc.startsWith("L") && desc.endsWith(";")) { if (desc.startsWith("L") && desc.endsWith(";")) {
desc = desc.substring(1, desc.length() - 1); desc = desc.substring(1, desc.length() - 1);
@ -189,7 +189,7 @@ public final class Parser {
return; return;
} }
for (int i = 0; i < values.size(); i += 2) { for (int i = 0; i < values.size(); i += 2) {
String key = (String)values.get(i); String key = (String) values.get(i);
Object value = values.get(i + 1); Object value = values.get(i + 1);
annot.getValues().put(key, parseAnnotationValue(value)); annot.getValues().put(key, parseAnnotationValue(value));
} }
@ -197,41 +197,41 @@ public final class Parser {
private static AnnotationValue parseAnnotationValue(Object value) { private static AnnotationValue parseAnnotationValue(Object value) {
if (value instanceof String[]) { if (value instanceof String[]) {
String[] enumInfo = (String[])value; String[] enumInfo = (String[]) value;
ValueType.Object object = (ValueType.Object)ValueType.parse(enumInfo[0]); ValueType.Object object = (ValueType.Object) ValueType.parse(enumInfo[0]);
return new AnnotationValue(new FieldReference(object.getClassName(), enumInfo[1])); return new AnnotationValue(new FieldReference(object.getClassName(), enumInfo[1]));
} else if (value instanceof Type) { } else if (value instanceof Type) {
Type cls = (Type)value; Type cls = (Type) value;
return new AnnotationValue(ValueType.parse(cls.getDescriptor())); return new AnnotationValue(ValueType.parse(cls.getDescriptor()));
} else if (value instanceof List<?>) { } else if (value instanceof List<?>) {
List<?> originalList = (List<?>)value; List<?> originalList = (List<?>) value;
List<AnnotationValue> resultList = new ArrayList<>(); List<AnnotationValue> resultList = new ArrayList<>();
for (Object item : originalList) { for (Object item : originalList) {
resultList.add(parseAnnotationValue(item)); resultList.add(parseAnnotationValue(item));
} }
return new AnnotationValue(resultList); return new AnnotationValue(resultList);
} else if (value instanceof AnnotationNode) { } else if (value instanceof AnnotationNode) {
AnnotationNode annotNode = (AnnotationNode)value; AnnotationNode annotNode = (AnnotationNode) value;
ValueType.Object object = (ValueType.Object)ValueType.parse(annotNode.desc); ValueType.Object object = (ValueType.Object) ValueType.parse(annotNode.desc);
AnnotationHolder annotation = new AnnotationHolder(object.getClassName()); AnnotationHolder annotation = new AnnotationHolder(object.getClassName());
parseAnnotationValues(annotation, annotNode.values); parseAnnotationValues(annotation, annotNode.values);
return new AnnotationValue(annotation); return new AnnotationValue(annotation);
} else if (value instanceof String) { } else if (value instanceof String) {
return new AnnotationValue((String)value); return new AnnotationValue((String) value);
} else if (value instanceof Boolean) { } else if (value instanceof Boolean) {
return new AnnotationValue((Boolean)value); return new AnnotationValue((Boolean) value);
} else if (value instanceof Byte) { } else if (value instanceof Byte) {
return new AnnotationValue((Byte)value); return new AnnotationValue((Byte) value);
} else if (value instanceof Short) { } else if (value instanceof Short) {
return new AnnotationValue((Short)value); return new AnnotationValue((Short) value);
} else if (value instanceof Integer) { } else if (value instanceof Integer) {
return new AnnotationValue((Integer)value); return new AnnotationValue((Integer) value);
} else if (value instanceof Long) { } else if (value instanceof Long) {
return new AnnotationValue((Long)value); return new AnnotationValue((Long) value);
} else if (value instanceof Float) { } else if (value instanceof Float) {
return new AnnotationValue((Float)value); return new AnnotationValue((Float) value);
} else if (value instanceof Double) { } else if (value instanceof Double) {
return new AnnotationValue((Double)value); return new AnnotationValue((Double) value);
} else if (value.getClass().isArray()) { } else if (value.getClass().isArray()) {
List<AnnotationValue> resultList = new ArrayList<>(); List<AnnotationValue> resultList = new ArrayList<>();
int size = Array.getLength(value); int size = Array.getLength(value);

View File

@ -176,10 +176,10 @@ public class ProgramParser implements VariableDebugInformation {
for (int i = 0; i < instructions.size(); ++i) { for (int i = 0; i < instructions.size(); ++i) {
AbstractInsnNode node = instructions.get(i); AbstractInsnNode node = instructions.get(i);
if (node instanceof LabelNode) { if (node instanceof LabelNode) {
labelIndexes.put(((LabelNode)node).getLabel(), i); labelIndexes.put(((LabelNode) node).getLabel(), i);
} }
if (node instanceof LineNumberNode) { if (node instanceof LineNumberNode) {
LineNumberNode lineNumberNode = (LineNumberNode)node; LineNumberNode lineNumberNode = (LineNumberNode) node;
lineNumbers.put(lineNumberNode.start.getLabel(), lineNumberNode.line); lineNumbers.put(lineNumberNode.start.getLabel(), lineNumberNode.line);
} }
} }
@ -203,7 +203,7 @@ public class ProgramParser implements VariableDebugInformation {
InsnList instructions = method.instructions; InsnList instructions = method.instructions;
Deque<Step> workStack = new ArrayDeque<>(); Deque<Step> workStack = new ArrayDeque<>();
for (Object obj : method.tryCatchBlocks) { for (Object obj : method.tryCatchBlocks) {
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj; TryCatchBlockNode tryCatchNode = (TryCatchBlockNode) obj;
if (tryCatchNode.start == tryCatchNode.handler) { if (tryCatchNode.start == tryCatchNode.handler) {
continue; continue;
} }
@ -241,7 +241,7 @@ public class ProgramParser implements VariableDebugInformation {
} }
} }
for (Object obj : method.tryCatchBlocks) { for (Object obj : method.tryCatchBlocks) {
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj; TryCatchBlockNode tryCatchNode = (TryCatchBlockNode) obj;
if (tryCatchNode.start == tryCatchNode.handler) { if (tryCatchNode.start == tryCatchNode.handler) {
continue; continue;
} }
@ -298,7 +298,7 @@ public class ProgramParser implements VariableDebugInformation {
} }
AbstractInsnNode insnNode = methodNode.instructions.get(i); AbstractInsnNode insnNode = methodNode.instructions.get(i);
if (insnNode instanceof LabelNode) { if (insnNode instanceof LabelNode) {
Label label = ((LabelNode)insnNode).getLabel(); Label label = ((LabelNode) insnNode).getLabel();
Integer lineNumber = lineNumbers.get(label); Integer lineNumber = lineNumbers.get(label);
if (lineNumber != null && !lineNumber.equals(lastLineNumber)) { if (lineNumber != null && !lineNumber.equals(lastLineNumber)) {
lastLineNumber = lineNumber; lastLineNumber = lineNumber;
@ -340,7 +340,7 @@ public class ProgramParser implements VariableDebugInformation {
private void emitNextBasicBlock() { private void emitNextBasicBlock() {
if (index + 1 < basicBlocks.size()) { if (index + 1 < basicBlocks.size()) {
getBasicBlock(index+ 1); getBasicBlock(index + 1);
} }
} }
@ -591,21 +591,21 @@ public class ProgramParser implements VariableDebugInformation {
@Override @Override
public void visitLdcInsn(Object cst) { public void visitLdcInsn(Object cst) {
if (cst instanceof Integer) { if (cst instanceof Integer) {
pushConstant((Integer)cst); pushConstant((Integer) cst);
} else if (cst instanceof Float) { } else if (cst instanceof Float) {
pushConstant((Float)cst); pushConstant((Float) cst);
} else if (cst instanceof Long) { } else if (cst instanceof Long) {
pushConstant((Long)cst); pushConstant((Long) cst);
} else if (cst instanceof Double) { } else if (cst instanceof Double) {
pushConstant((Double)cst); pushConstant((Double) cst);
} else if (cst instanceof String) { } else if (cst instanceof String) {
StringConstantInstruction insn = new StringConstantInstruction(); StringConstantInstruction insn = new StringConstantInstruction();
insn.setConstant((String)cst); insn.setConstant((String) cst);
insn.setReceiver(getVariable(pushSingle())); insn.setReceiver(getVariable(pushSingle()));
addInstruction(insn); addInstruction(insn);
} else if (cst instanceof Type) { } else if (cst instanceof Type) {
ClassConstantInstruction insn = new ClassConstantInstruction(); ClassConstantInstruction insn = new ClassConstantInstruction();
insn.setConstant(ValueType.parse(((Type)cst).getDescriptor())); insn.setConstant(ValueType.parse(((Type) cst).getDescriptor()));
insn.setReceiver(getVariable(pushSingle())); insn.setReceiver(getVariable(pushSingle()));
addInstruction(insn); addInstruction(insn);
} else { } else {
@ -1055,7 +1055,7 @@ public class ProgramParser implements VariableDebugInformation {
} }
break; break;
} }
case Opcodes.DUP2_X1:{ case Opcodes.DUP2_X1: {
if (stack.type == SINGLE) { if (stack.type == SINGLE) {
popSingle(); popSingle();
popSingle(); popSingle();

View File

@ -77,7 +77,7 @@ public class SSATransformer {
++index; ++index;
ValueType arg = arguments[i]; ValueType arg = arguments[i];
if (arg instanceof ValueType.Primitive) { if (arg instanceof ValueType.Primitive) {
PrimitiveType kind = ((ValueType.Primitive)arg).getKind(); PrimitiveType kind = ((ValueType.Primitive) arg).getKind();
if (kind == PrimitiveType.LONG || kind == PrimitiveType.DOUBLE) { if (kind == PrimitiveType.LONG || kind == PrimitiveType.DOUBLE) {
variableMap[index] = variableMap[index - 1]; variableMap[index] = variableMap[index - 1];
++index; ++index;

View File

@ -51,7 +51,7 @@ public class JUnitTestAdapter implements TestAdapter {
AnnotationReader annot = method.getAnnotations().get(Test.class.getName()); AnnotationReader annot = method.getAnnotations().get(Test.class.getName());
AnnotationValue expectedAnnot = annot.getValue("expected"); AnnotationValue expectedAnnot = annot.getValue("expected");
if (expectedAnnot != null) { if (expectedAnnot != null) {
String className = ((ValueType.Object)expectedAnnot.getJavaClass()).getClassName(); String className = ((ValueType.Object) expectedAnnot.getJavaClass()).getClassName();
return Collections.singletonList(className); return Collections.singletonList(className);
} }
return Collections.emptyList(); return Collections.emptyList();

View File

@ -221,8 +221,8 @@ public class TeaVMTestTool {
allTestsWriter.append(","); allTestsWriter.append(",");
} }
firstMethod = false; firstMethod = false;
allTestsWriter.append("\n { name : \"" + methodRef.getName() + "\", script : \"" + allTestsWriter.append("\n { name : \"" + methodRef.getName() + "\", script : \""
scriptName + "\", expected : ["); + scriptName + "\", expected : [");
MethodHolder methodHolder = classSource.get(testClass).getMethod( MethodHolder methodHolder = classSource.get(testClass).getMethod(
methodRef.getDescriptor()); methodRef.getDescriptor());
boolean firstException = true; boolean firstException = true;
@ -322,7 +322,7 @@ public class TeaVMTestTool {
if (!file.exists()) { if (!file.exists()) {
file.createNewFile(); file.createNewFile();
} }
try(OutputStream out = new FileOutputStream(file)) { try (OutputStream out = new FileOutputStream(file)) {
IOUtils.copy(in, out); IOUtils.copy(in, out);
} }
} catch (IOException e) { } catch (IOException e) {
@ -348,8 +348,8 @@ public class TeaVMTestTool {
vm.add(transformer); vm.add(transformer);
} }
File file = new File(outputDir, targetName); File file = new File(outputDir, targetName);
DebugInformationBuilder debugInfoBuilder = sourceMapsGenerated || debugInformationGenerated ? DebugInformationBuilder debugInfoBuilder = sourceMapsGenerated || debugInformationGenerated
new DebugInformationBuilder() : null; ? new DebugInformationBuilder() : null;
try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) { try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) {
MethodReference cons = new MethodReference(methodRef.getClassName(), "<init>", ValueType.VOID); MethodReference cons = new MethodReference(methodRef.getClassName(), "<init>", ValueType.VOID);
MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException", MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException",

View File

@ -282,8 +282,8 @@ public class TeaVMTool {
vm.setMinifying(minifying); vm.setMinifying(minifying);
vm.setBytecodeLogging(bytecodeLogging); vm.setBytecodeLogging(bytecodeLogging);
vm.setProperties(properties); vm.setProperties(properties);
DebugInformationBuilder debugEmitter = debugInformationGenerated || sourceMapsFileGenerated ? DebugInformationBuilder debugEmitter = debugInformationGenerated || sourceMapsFileGenerated
new DebugInformationBuilder() : null; ? new DebugInformationBuilder() : null;
vm.setDebugEmitter(debugEmitter); vm.setDebugEmitter(debugEmitter);
vm.setIncremental(incremental); vm.setIncremental(incremental);
if (incremental) { if (incremental) {

View File

@ -240,8 +240,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
public TeaVMEntryPoint entryPoint(String name, MethodReference ref) { public TeaVMEntryPoint entryPoint(String name, MethodReference ref) {
if (name != null) { if (name != null) {
if (entryPoints.containsKey(name)) { if (entryPoints.containsKey(name)) {
throw new IllegalArgumentException("Entry point with public name `" + name + "' already defined " + throw new IllegalArgumentException("Entry point with public name `" + name + "' already defined "
"for method " + ref); + "for method " + ref);
} }
} }
TeaVMEntryPoint entryPoint = new TeaVMEntryPoint(name, ref, dependencyChecker.linkMethod(ref, null)); TeaVMEntryPoint entryPoint = new TeaVMEntryPoint(name, ref, dependencyChecker.linkMethod(ref, null));
@ -276,8 +276,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
public void exportType(String name, String className) { public void exportType(String name, String className) {
if (exportedClasses.containsKey(name)) { if (exportedClasses.containsKey(name)) {
throw new IllegalArgumentException("Class with public name `" + name + "' already defined for class " + throw new IllegalArgumentException("Class with public name `" + name + "' already defined for class "
className); + className);
} }
dependencyChecker.linkClass(className, null).initClass(null); dependencyChecker.linkClass(className, null).initClass(null);
exportedClasses.put(name, className); exportedClasses.put(name, className);
@ -562,8 +562,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
List<String> classOrder = decompiler.getClassOrdering(classes.getClassNames()); List<String> classOrder = decompiler.getClassOrdering(classes.getClassNames());
List<ClassNode> classNodes = new ArrayList<>(); List<ClassNode> classNodes = new ArrayList<>();
int index = 0; int index = 0;
try (PrintWriter bytecodeLogger = bytecodeLogging ? try (PrintWriter bytecodeLogger = bytecodeLogging
new PrintWriter(new OutputStreamWriter(logStream, "UTF-8")) : null) { ? new PrintWriter(new OutputStreamWriter(logStream, "UTF-8")) : null) {
for (String className : classOrder) { for (String className : classOrder) {
ClassHolder cls = classes.get(className); ClassHolder cls = classes.get(className);
for (MethodHolder method : cls.getMethods()) { for (MethodHolder method : cls.getMethods()) {
@ -583,11 +583,11 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
} }
private void preprocessNativeMethod(MethodHolder method) { private void preprocessNativeMethod(MethodHolder method) {
if (!method.getModifiers().contains(ElementModifier.NATIVE) || if (!method.getModifiers().contains(ElementModifier.NATIVE)
methodGenerators.get(method.getReference()) != null || || methodGenerators.get(method.getReference()) != null
methodInjectors.get(method.getReference()) != null || || methodInjectors.get(method.getReference()) != null
method.getAnnotations().get(GeneratedBy.class.getName()) != null || || method.getAnnotations().get(GeneratedBy.class.getName()) != null
method.getAnnotations().get(InjectedBy.class.getName()) != null) { || method.getAnnotations().get(InjectedBy.class.getName()) != null) {
return; return;
} }
method.getModifiers().remove(ElementModifier.NATIVE); method.getModifiers().remove(ElementModifier.NATIVE);
@ -628,8 +628,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
} }
boolean noCache = method.getAnnotations().get(NoCache.class.getName()) != null; boolean noCache = method.getAnnotations().get(NoCache.class.getName()) != null;
Program optimizedProgram = incremental && !noCache && programCache != null ? Program optimizedProgram = incremental && !noCache && programCache != null
programCache.get(method.getReference()) : null; ? programCache.get(method.getReference()) : null;
if (optimizedProgram == null) { if (optimizedProgram == null) {
optimizedProgram = ProgramUtils.copy(method.getProgram()); optimizedProgram = ProgramUtils.copy(method.getProgram());
if (optimizedProgram.basicBlockCount() > 0) { if (optimizedProgram.basicBlockCount() > 0) {
@ -681,12 +681,12 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
private void printType(PrintWriter writer, ValueType type) { private void printType(PrintWriter writer, ValueType type) {
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
writer.print(((ValueType.Object)type).getClassName()); writer.print(((ValueType.Object) type).getClassName());
} else if (type instanceof ValueType.Array) { } else if (type instanceof ValueType.Array) {
printType(writer, ((ValueType.Array)type).getItemType()); printType(writer, ((ValueType.Array) type).getItemType());
writer.print("[]"); writer.print("[]");
} else if (type instanceof ValueType.Primitive) { } else if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
writer.print("boolean"); writer.print("boolean");
break; break;

View File

@ -36,8 +36,8 @@ public abstract class IDBFactory implements JSObject {
return factory; return factory;
} }
@JSBody(params = {}, script = "return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || " + @JSBody(params = {}, script = "return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || "
"window.msIndexedDB;") + "window.msIndexedDB;")
static native IDBFactory getInstanceImpl(); static native IDBFactory getInstanceImpl();
public abstract IDBOpenDBRequest open(String name, int version); public abstract IDBOpenDBRequest open(String name, int version);

View File

@ -37,7 +37,7 @@ public abstract class IDBIndex implements JSObject, IDBCursorSource {
if (JS.getType(result) == JSType.STRING) { if (JS.getType(result) == JSType.STRING) {
return new String[] { JS.unwrapString(result) }; return new String[] { JS.unwrapString(result) };
} else { } else {
return JS.unwrapStringArray((JSStringArray)result); return JS.unwrapStringArray((JSStringArray) result);
} }
} }

View File

@ -33,7 +33,7 @@ public abstract class IDBObjectStore implements JSObject, IDBCursorSource {
if (JS.getType(result) == JSType.STRING) { if (JS.getType(result) == JSType.STRING) {
return new String[] { JS.unwrapString(result) }; return new String[] { JS.unwrapString(result) };
} else { } else {
return JS.unwrapStringArray((JSStringArray)result); return JS.unwrapStringArray((JSStringArray) result);
} }
} }

View File

@ -33,7 +33,7 @@ public class HTML4JPlugin implements TeaVMPlugin {
host.add(new JavaScriptResourceInterceptor()); host.add(new JavaScriptResourceInterceptor());
EntryPointGenerator entryPointGen = new EntryPointGenerator(host.getProperties() EntryPointGenerator entryPointGen = new EntryPointGenerator(host.getProperties()
.getProperty("html4j.entryPoints", "")); .getProperty("html4j.entryPoints", ""));
host.add((DependencyListener)entryPointGen); host.add((DependencyListener) entryPointGen);
host.add((RendererListener)entryPointGen); host.add((RendererListener) entryPointGen);
} }
} }

View File

@ -63,8 +63,8 @@ public class JavaScriptBodyDependency extends AbstractDependencyListener {
@Override @Override
public void classReached(DependencyAgent agent, String className, CallLocation location) { public void classReached(DependencyAgent agent, String className, CallLocation location) {
ClassReader cls = agent.getClassSource().get(className); ClassReader cls = agent.getClassSource().get(className);
if (cls != null && !cls.hasModifier(ElementModifier.ABSTRACT) && if (cls != null && !cls.hasModifier(ElementModifier.ABSTRACT)
!cls.hasModifier(ElementModifier.INTERFACE)) { && !cls.hasModifier(ElementModifier.INTERFACE)) {
allClassesNode.propagate(agent.getType(className)); allClassesNode.propagate(agent.getType(className));
} }
} }

View File

@ -51,8 +51,8 @@ public class JavaScriptBodyGenerator implements Generator {
} }
writer.append(")").ws().append("{").indent().softNewLine(); writer.append(")").ws().append("{").indent().softNewLine();
writer.append(body).softNewLine(); writer.append(body).softNewLine();
writer.outdent().append("}).call(").append(!method.hasModifier(ElementModifier.STATIC) ? writer.outdent().append("}).call(").append(!method.hasModifier(ElementModifier.STATIC)
context.getParameterName(0) : "null"); ? context.getParameterName(0) : "null");
for (int i = 0; i < args.size(); ++i) { for (int i = 0; i < args.size(); ++i) {
writer.append(",").ws(); writer.append(",").ws();
wrapParameter(writer, context.getParameterName(i + 1)); wrapParameter(writer, context.getParameterName(i + 1));
@ -121,7 +121,7 @@ public class JavaScriptBodyGenerator implements Generator {
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
return ValueType.object("java.lang.Object"); return ValueType.object("java.lang.Object");
} else if (type instanceof ValueType.Array) { } else if (type instanceof ValueType.Array) {
ValueType.Array array = (ValueType.Array)type; ValueType.Array array = (ValueType.Array) type;
return ValueType.arrayOf(simplifyParamType(array.getItemType())); return ValueType.arrayOf(simplifyParamType(array.getItemType()));
} else { } else {
return type; return type;

View File

@ -116,14 +116,14 @@ public class JavaScriptConvGenerator implements Generator {
private void generateFromJavaScript(GeneratorContext context, SourceWriter writer) throws IOException { private void generateFromJavaScript(GeneratorContext context, SourceWriter writer) throws IOException {
String obj = context.getParameterName(1); String obj = context.getParameterName(1);
String type = context.getParameterName(2); String type = context.getParameterName(2);
writer.append("if (" + obj +" === null || " + obj + " === undefined)").ws().append("{") writer.append("if (" + obj + " === null || " + obj + " === undefined)").ws().append("{")
.softNewLine().indent(); .softNewLine().indent();
writer.append("return " + obj +";").softNewLine(); writer.append("return " + obj + ";").softNewLine();
writer.outdent().append("} else if (" + type + ".$meta.item) {").indent().softNewLine(); writer.outdent().append("} else if (" + type + ".$meta.item) {").indent().softNewLine();
writer.append("var arr = $rt_createArray(" + type + ".$meta.item, " + obj + ".length);").softNewLine(); writer.append("var arr = $rt_createArray(" + type + ".$meta.item, " + obj + ".length);").softNewLine();
writer.append("for (var i = 0; i < arr.data.length; ++i) {").indent().softNewLine(); writer.append("for (var i = 0; i < arr.data.length; ++i) {").indent().softNewLine();
writer.append("arr.data[i] = ").appendMethodBody(fromJsMethod).append("(" + obj + "[i], " + writer.append("arr.data[i] = ").appendMethodBody(fromJsMethod).append("(" + obj + "[i], "
type + ".$meta.item);").softNewLine(); + type + ".$meta.item);").softNewLine();
writer.outdent().append("}").softNewLine(); writer.outdent().append("}").softNewLine();
writer.append("return arr;").softNewLine(); writer.append("return arr;").softNewLine();
@ -137,8 +137,8 @@ public class JavaScriptConvGenerator implements Generator {
writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Character") writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Character")
.append(") {").indent().softNewLine(); .append(") {").indent().softNewLine();
writer.append("return ").appendMethodBody(valueOfCharMethod).append("(typeof " + obj + " === 'number' ? " + writer.append("return ").appendMethodBody(valueOfCharMethod).append("(typeof " + obj + " === 'number' ? "
obj + "0xFFFF : " + obj + ".charCodeAt(0));").softNewLine(); + obj + "0xFFFF : " + obj + ".charCodeAt(0));").softNewLine();
writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Byte") writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Byte")
.append(") {").indent().softNewLine(); .append(") {").indent().softNewLine();
@ -161,8 +161,8 @@ public class JavaScriptConvGenerator implements Generator {
.append(") {").indent().softNewLine(); .append(") {").indent().softNewLine();
writer.append("return ").appendMethodBody(valueOfDoubleMethod).append("(" + obj + ");").softNewLine(); writer.append("return ").appendMethodBody(valueOfDoubleMethod).append("(" + obj + ");").softNewLine();
writer.outdent().append("} else if (" + type + " === $rt_intcls() || " + type + " === $rt_bytecls() || " + writer.outdent().append("} else if (" + type + " === $rt_intcls() || " + type + " === $rt_bytecls() || "
type + " === $rt_shortcls() ||" + type + " == $rt_charcls()) {").indent().softNewLine(); + type + " === $rt_shortcls() ||" + type + " == $rt_charcls()) {").indent().softNewLine();
writer.append("return " + obj + "|0;").softNewLine(); writer.append("return " + obj + "|0;").softNewLine();
writer.outdent().append("} else if (" + type + " === $rt_longcls()) {").indent().softNewLine(); writer.outdent().append("} else if (" + type + " === $rt_longcls()) {").indent().softNewLine();

View File

@ -46,8 +46,8 @@ public class JavaScriptResourceInterceptor extends AbstractRendererListener {
String resourceName = packageName.replace('.', '/') + "/" + path; String resourceName = packageName.replace('.', '/') + "/" + path;
try (InputStream input = context.getClassLoader().getResourceAsStream(resourceName)) { try (InputStream input = context.getClassLoader().getResourceAsStream(resourceName)) {
if (input == null) { if (input == null) {
throw new RenderingException("Error processing JavaScriptResource annotation on class " + throw new RenderingException("Error processing JavaScriptResource annotation on class "
className + ". Resource not found: " + resourceName); + className + ". Resource not found: " + resourceName);
} }
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
IOUtils.copy(input, writer); IOUtils.copy(input, writer);

View File

@ -87,8 +87,8 @@ abstract class JsCallback {
int sigEnd = body.indexOf(')', sigBeg); int sigEnd = body.indexOf(')', sigBeg);
int colon4 = body.indexOf("::", next); int colon4 = body.indexOf("::", next);
if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) {
throw new IllegalStateException("Wrong format of instance callback. Should be: " + throw new IllegalStateException("Wrong format of instance callback. Should be: "
"'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body); + "'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body);
} }
String fqn = body.substring(next + 2, colon4); String fqn = body.substring(next + 2, colon4);
String method = body.substring(colon4 + 2, sigBeg); String method = body.substring(colon4 + 2, sigBeg);
@ -96,8 +96,8 @@ abstract class JsCallback {
int paramBeg = body.indexOf('(', sigEnd + 1); int paramBeg = body.indexOf('(', sigEnd + 1);
if (paramBeg == -1) { if (paramBeg == -1) {
throw new IllegalStateException("Wrong format of instance callback. " + throw new IllegalStateException("Wrong format of instance callback. "
"Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body); + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body);
} }
sb.append(callMethod(refId, fqn, method, params)); sb.append(callMethod(refId, fqn, method, params));
@ -127,8 +127,8 @@ abstract class JsCallback {
int sigEnd = body.indexOf(')', sigBeg); int sigEnd = body.indexOf(')', sigBeg);
int colon4 = body.indexOf("::", next); int colon4 = body.indexOf("::", next);
if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) {
throw new IllegalStateException("Wrong format of static callback. Should be: " + throw new IllegalStateException("Wrong format of static callback. Should be: "
"'@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body); + "'@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body);
} }
String fqn = body.substring(next + 1, colon4); String fqn = body.substring(next + 1, colon4);
String method = body.substring(colon4 + 2, sigBeg); String method = body.substring(colon4 + 2, sigBeg);

View File

@ -50,23 +50,23 @@ public final class JS {
} }
public static <T extends JSObject> JSArray<T> createArray(int size) { public static <T extends JSObject> JSArray<T> createArray(int size) {
return ((JSGlobal)JS.getGlobal()).newArray(size); return ((JSGlobal) JS.getGlobal()).newArray(size);
} }
public static JSIntArray createIntArray(int size) { public static JSIntArray createIntArray(int size) {
return ((JSGlobal)JS.getGlobal()).newIntArray(size); return ((JSGlobal) JS.getGlobal()).newIntArray(size);
} }
public static JSStringArray createStringArray(int size) { public static JSStringArray createStringArray(int size) {
return ((JSGlobal)JS.getGlobal()).newStringArray(size); return ((JSGlobal) JS.getGlobal()).newStringArray(size);
} }
public static JSBooleanArray createBooleanArray(int size) { public static JSBooleanArray createBooleanArray(int size) {
return ((JSGlobal)JS.getGlobal()).newBooleanArray(size); return ((JSGlobal) JS.getGlobal()).newBooleanArray(size);
} }
public static JSDoubleArray createDoubleArray(int size) { public static JSDoubleArray createDoubleArray(int size) {
return ((JSGlobal)JS.getGlobal()).newDoubleArray(size); return ((JSGlobal) JS.getGlobal()).newDoubleArray(size);
} }
@InjectedBy(JSNativeGenerator.class) @InjectedBy(JSNativeGenerator.class)
@ -326,11 +326,11 @@ public final class JS {
public static native boolean unwrapBoolean(JSObject obj); public static native boolean unwrapBoolean(JSObject obj);
public static byte unwrapByte(JSObject obj) { public static byte unwrapByte(JSObject obj) {
return (byte)unwrapInt(obj); return (byte) unwrapInt(obj);
} }
public static short unwrapShort(JSObject obj) { public static short unwrapShort(JSObject obj) {
return (short)unwrapInt(obj); return (short) unwrapInt(obj);
} }
@InjectedBy(JSNativeGenerator.class) @InjectedBy(JSNativeGenerator.class)
@ -351,7 +351,7 @@ public final class JS {
public static <T extends JSObject> T[] unwrapArray(Class<T> type, JSArray<T> array) { public static <T extends JSObject> T[] unwrapArray(Class<T> type, JSArray<T> array) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T[] result = (T[])Array.newInstance(type, array.getLength()); T[] result = (T[]) Array.newInstance(type, array.getLength());
for (int i = 0; i < result.length; ++i) { for (int i = 0; i < result.length; ++i) {
result[i] = array.get(i); result[i] = array.get(i);
} }
@ -360,7 +360,7 @@ public final class JS {
public static <T extends JSObject> T[][] unwrapArray2(Class<T> type, JSArray<JSArray<T>> array) { public static <T extends JSObject> T[][] unwrapArray2(Class<T> type, JSArray<JSArray<T>> array) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T[][] result = (T[][])Array.newInstance(Array.newInstance(type, 0).getClass(), array.getLength()); T[][] result = (T[][]) Array.newInstance(Array.newInstance(type, 0).getClass(), array.getLength());
for (int i = 0; i < result.length; ++i) { for (int i = 0; i < result.length; ++i) {
result[i] = unwrapArray(type, array.get(i)); result[i] = unwrapArray(type, array.get(i));
} }
@ -370,7 +370,7 @@ public final class JS {
public static <T extends JSObject> T[][][] unwrapArray3(Class<T> type, JSArray<JSArray<JSArray<T>>> array) { public static <T extends JSObject> T[][][] unwrapArray3(Class<T> type, JSArray<JSArray<JSArray<T>>> array) {
Class<?> baseType = Array.newInstance(type, 0).getClass(); Class<?> baseType = Array.newInstance(type, 0).getClass();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T[][][] result = (T[][][])Array.newInstance(Array.newInstance(baseType, 0).getClass(), array.getLength()); T[][][] result = (T[][][]) Array.newInstance(Array.newInstance(baseType, 0).getClass(), array.getLength());
for (int i = 0; i < result.length; ++i) { for (int i = 0; i < result.length; ++i) {
result[i] = unwrapArray2(type, array.get(i)); result[i] = unwrapArray2(type, array.get(i));
} }

View File

@ -129,9 +129,9 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
case "wrap": case "wrap":
if (methodRef.getDescriptor().parameterType(0).isObject("java.lang.String")) { if (methodRef.getDescriptor().parameterType(0).isObject("java.lang.String")) {
if (context.getArgument(0) instanceof ConstantExpr) { if (context.getArgument(0) instanceof ConstantExpr) {
ConstantExpr constant = (ConstantExpr)context.getArgument(0); ConstantExpr constant = (ConstantExpr) context.getArgument(0);
if (constant.getValue() instanceof String) { if (constant.getValue() instanceof String) {
writer.append('"').append(Renderer.escapeString((String)constant.getValue())).append('"'); writer.append('"').append(Renderer.escapeString((String) constant.getValue())).append('"');
break; break;
} }
} }
@ -219,20 +219,20 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
if (!(propertyName instanceof InvocationExpr)) { if (!(propertyName instanceof InvocationExpr)) {
return null; return null;
} }
InvocationExpr invoke = (InvocationExpr)propertyName; InvocationExpr invoke = (InvocationExpr) propertyName;
if (!invoke.getMethod().getClassName().equals(JS.class.getName())) { if (!invoke.getMethod().getClassName().equals(JS.class.getName())) {
return null; return null;
} }
if (!invoke.getMethod().getName().equals("wrap") || if (!invoke.getMethod().getName().equals("wrap")
!invoke.getMethod().getDescriptor().parameterType(0).isObject("java.lang.String")) { || !invoke.getMethod().getDescriptor().parameterType(0).isObject("java.lang.String")) {
return null; return null;
} }
Expr arg = invoke.getArguments().get(0); Expr arg = invoke.getArguments().get(0);
if (!(arg instanceof ConstantExpr)) { if (!(arg instanceof ConstantExpr)) {
return null; return null;
} }
ConstantExpr constant = (ConstantExpr)arg; ConstantExpr constant = (ConstantExpr) arg;
return constant.getValue() instanceof String ? (String)constant.getValue() : null; return constant.getValue() instanceof String ? (String) constant.getValue() : null;
} }
private boolean isIdentifier(String name) { private boolean isIdentifier(String name) {

View File

@ -94,8 +94,8 @@ class JSODependencyListener extends AbstractDependencyListener {
} }
addInterfaces(exposedCls, cls); addInterfaces(exposedCls, cls);
for (MethodReader method : cls.getMethods()) { for (MethodReader method : cls.getMethods()) {
if (exposedCls.inheritedMethods.containsKey(method.getDescriptor()) || if (exposedCls.inheritedMethods.containsKey(method.getDescriptor())
exposedCls.methods.containsKey(method.getDescriptor())) { || exposedCls.methods.containsKey(method.getDescriptor())) {
MethodDependency methodDep = agent.linkMethod(method.getReference(), null); MethodDependency methodDep = agent.linkMethod(method.getReference(), null);
methodDep.getVariable(0).propagate(agent.getType(name)); methodDep.getVariable(0).propagate(agent.getType(name));
methodDep.use(); methodDep.use();

View File

@ -48,8 +48,8 @@ public class JSObjectClassTransformer implements ClassHolderTransformer {
for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) { for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) {
if (method.getAnnotations().get(JSBody.class.getName()) != null) { if (method.getAnnotations().get(JSBody.class.getName()) != null) {
processor.processJSBody(cls, method); processor.processJSBody(cls, method);
} else if (method.getProgram() != null && } else if (method.getProgram() != null
method.getAnnotations().get(JSBodyImpl.class.getName()) == null) { && method.getAnnotations().get(JSBodyImpl.class.getName()) == null) {
processor.processProgram(method); processor.processProgram(method);
} }
} }

View File

@ -172,8 +172,8 @@ class JavascriptNativeProcessor {
if (method.hasModifier(ElementModifier.STATIC)) { if (method.hasModifier(ElementModifier.STATIC)) {
continue; continue;
} }
if (method.hasModifier(ElementModifier.FINAL) && method.getProgram() != null && if (method.hasModifier(ElementModifier.FINAL) && method.getProgram() != null
method.getProgram().basicBlockCount() > 0) { && method.getProgram().basicBlockCount() > 0) {
ValueType[] staticSignature = getStaticSignature(method.getReference()); ValueType[] staticSignature = getStaticSignature(method.getReference());
MethodHolder callerMethod = new MethodHolder(new MethodDescriptor(method.getName() + "$static", MethodHolder callerMethod = new MethodHolder(new MethodDescriptor(method.getName() + "$static",
staticSignature)); staticSignature));
@ -282,8 +282,8 @@ class JavascriptNativeProcessor {
} }
if (isNative(cls.getName())) { if (isNative(cls.getName())) {
for (MethodReader method : cls.getMethods()) { for (MethodReader method : cls.getMethods()) {
if (!method.hasModifier(ElementModifier.STATIC) && !method.hasModifier(ElementModifier.FINAL) && if (!method.hasModifier(ElementModifier.STATIC) && !method.hasModifier(ElementModifier.FINAL)
method.getLevel() != AccessLevel.PRIVATE) { && method.getLevel() != AccessLevel.PRIVATE) {
methods.add(method.getDescriptor()); methods.add(method.getDescriptor());
} }
} }
@ -323,7 +323,7 @@ class JavascriptNativeProcessor {
if (!(insn instanceof InvokeInstruction)) { if (!(insn instanceof InvokeInstruction)) {
continue; continue;
} }
InvokeInstruction invoke = (InvokeInstruction)insn; InvokeInstruction invoke = (InvokeInstruction) insn;
if (!nativeRepos.isJavaScriptClass(invoke.getMethod().getClassName())) { if (!nativeRepos.isJavaScriptClass(invoke.getMethod().getClassName())) {
continue; continue;
} }
@ -339,8 +339,8 @@ class JavascriptNativeProcessor {
if (overriden != null) { if (overriden != null) {
CallLocation callLocation = new CallLocation(methodToProcess.getReference(), CallLocation callLocation = new CallLocation(methodToProcess.getReference(),
insn.getLocation()); insn.getLocation());
diagnostics.error(callLocation, "JS final method {{m0}} overrides {{M1}}. " + diagnostics.error(callLocation, "JS final method {{m0}} overrides {{M1}}. "
"Overriding final method of overlay types is prohibited.", + "Overriding final method of overlay types is prohibited.",
method.getReference(), overriden.getReference()); method.getReference(), overriden.getReference());
} }
if (method.getProgram() != null && method.getProgram().basicBlockCount() > 0) { if (method.getProgram() != null && method.getProgram().basicBlockCount() > 0) {
@ -361,8 +361,8 @@ class JavascriptNativeProcessor {
if (annot.getValue("value") != null) { if (annot.getValue("value") != null) {
propertyName = annot.getValue("value").getString(); propertyName = annot.getValue("value").getString();
} else { } else {
propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2) : propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2)
cutPrefix(method.getName(), 3); : cutPrefix(method.getName(), 3);
} }
Variable result = invoke.getReceiver() != null ? program.createVariable() : null; Variable result = invoke.getReceiver() != null ? program.createVariable() : null;
addPropertyGet(propertyName, invoke.getInstance(), result, invoke.getLocation()); addPropertyGet(propertyName, invoke.getInstance(), result, invoke.getLocation());
@ -382,8 +382,8 @@ class JavascriptNativeProcessor {
method.parameterType(0)); method.parameterType(0));
addPropertySet(propertyName, invoke.getInstance(), wrapped, invoke.getLocation()); addPropertySet(propertyName, invoke.getInstance(), wrapped, invoke.getLocation());
} else { } else {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript property " + diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript property "
"declaration", invoke.getMethod()); + "declaration", invoke.getMethod());
continue; continue;
} }
} else if (method.getAnnotations().get(JSIndexer.class.getName()) != null) { } else if (method.getAnnotations().get(JSIndexer.class.getName()) != null) {
@ -402,8 +402,8 @@ class JavascriptNativeProcessor {
invoke.getLocation()); invoke.getLocation());
addIndexerSet(invoke.getInstance(), index, value, invoke.getLocation()); addIndexerSet(invoke.getInstance(), index, value, invoke.getLocation());
} else { } else {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript indexer " + diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript indexer "
"declaration", invoke.getMethod()); + "declaration", invoke.getMethod());
continue; continue;
} }
} else { } else {
@ -412,16 +412,16 @@ class JavascriptNativeProcessor {
boolean isConstructor = false; boolean isConstructor = false;
if (constructorAnnot != null) { if (constructorAnnot != null) {
if (!isSupportedType(method.getResultType())) { if (!isSupportedType(method.getResultType())) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript " + diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript "
"constructor declaration", invoke.getMethod()); + "constructor declaration", invoke.getMethod());
continue; continue;
} }
AnnotationValue nameVal = constructorAnnot.getValue("value"); AnnotationValue nameVal = constructorAnnot.getValue("value");
name = nameVal != null ? constructorAnnot.getValue("value").getString() : ""; name = nameVal != null ? constructorAnnot.getValue("value").getString() : "";
if (name.isEmpty()) { if (name.isEmpty()) {
if (!method.getName().startsWith("new") || method.getName().length() == 3) { if (!method.getName().startsWith("new") || method.getName().length() == 3) {
diagnostics.error(callLocation, "Method {{m0}} is not declared as a native " + diagnostics.error(callLocation, "Method {{m0}} is not declared as a native "
"JavaScript constructor, but its name does not satisfy conventions", + "JavaScript constructor, but its name does not satisfy conventions",
invoke.getMethod()); invoke.getMethod());
continue; continue;
} }
@ -437,15 +437,15 @@ class JavascriptNativeProcessor {
} }
} }
if (method.getResultType() != ValueType.VOID && !isSupportedType(method.getResultType())) { if (method.getResultType() != ValueType.VOID && !isSupportedType(method.getResultType())) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " + diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
"declaration", invoke.getMethod()); + "declaration", invoke.getMethod());
continue; continue;
} }
} }
for (ValueType arg : method.getParameterTypes()) { for (ValueType arg : method.getParameterTypes()) {
if (!isSupportedType(arg)) { if (!isSupportedType(arg)) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " + diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
"or constructor declaration", invoke.getMethod()); + "or constructor declaration", invoke.getMethod());
continue; continue;
} }
} }
@ -487,8 +487,8 @@ class JavascriptNativeProcessor {
AnnotationHolder bodyAnnot = methodToProcess.getAnnotations().get(JSBody.class.getName()); AnnotationHolder bodyAnnot = methodToProcess.getAnnotations().get(JSBody.class.getName());
int jsParamCount = bodyAnnot.getValue("params").getList().size(); int jsParamCount = bodyAnnot.getValue("params").getList().size();
if (methodToProcess.parameterCount() != jsParamCount) { if (methodToProcess.parameterCount() != jsParamCount) {
diagnostics.error(location, "JSBody method {{m0}} declares " + methodToProcess.parameterCount() + diagnostics.error(location, "JSBody method {{m0}} declares " + methodToProcess.parameterCount()
" parameters, but annotation specifies " + jsParamCount, methodToProcess); + " parameters, but annotation specifies " + jsParamCount, methodToProcess);
return; return;
} }
@ -524,8 +524,9 @@ class JavascriptNativeProcessor {
for (int i = 0; i < paramCount; ++i) { for (int i = 0; i < paramCount; ++i) {
proxyParamTypes[i] = ValueType.parse(JSObject.class); proxyParamTypes[i] = ValueType.parse(JSObject.class);
} }
proxyParamTypes[paramCount] = methodToProcess.getResultType() == ValueType.VOID ? ValueType.VOID : proxyParamTypes[paramCount] = methodToProcess.getResultType() == ValueType.VOID
ValueType.parse(JSObject.class); ? ValueType.VOID
: ValueType.parse(JSObject.class);
// create proxy method // create proxy method
MethodHolder proxyMethod = new MethodHolder("$js_body$_" + methodIndexGenerator++, proxyParamTypes); MethodHolder proxyMethod = new MethodHolder("$js_body$_" + methodIndexGenerator++, proxyParamTypes);
@ -649,7 +650,7 @@ class JavascriptNativeProcessor {
private Variable unwrap(CallLocation location, Variable var, ValueType type) { private Variable unwrap(CallLocation location, Variable var, ValueType type) {
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
return unwrap(var, "unwrapBoolean", ValueType.parse(JSObject.class), ValueType.BOOLEAN, return unwrap(var, "unwrapBoolean", ValueType.parse(JSObject.class), ValueType.BOOLEAN,
location.getSourceLocation()); location.getSourceLocation());
@ -675,7 +676,7 @@ class JavascriptNativeProcessor {
break; break;
} }
} else if (type instanceof ValueType.Object) { } else if (type instanceof ValueType.Object) {
String className = ((ValueType.Object)type).getClassName(); String className = ((ValueType.Object) type).getClassName();
if (className.equals(JSObject.class.getName())) { if (className.equals(JSObject.class.getName())) {
return var; return var;
} else if (className.equals("java.lang.String")) { } else if (className.equals("java.lang.String")) {
@ -692,7 +693,7 @@ class JavascriptNativeProcessor {
return result; return result;
} }
} else if (type instanceof ValueType.Array) { } else if (type instanceof ValueType.Array) {
return unwrapArray(location, var, (ValueType.Array)type); return unwrapArray(location, var, (ValueType.Array) type);
} }
diagnostics.error(location, "Unsupported type: {{t0}}", type); diagnostics.error(location, "Unsupported type: {{t0}}", type);
return var; return var;
@ -703,7 +704,7 @@ class JavascriptNativeProcessor {
int degree = 0; int degree = 0;
while (itemType instanceof ValueType.Array) { while (itemType instanceof ValueType.Array) {
++degree; ++degree;
itemType = ((ValueType.Array)itemType).getItemType(); itemType = ((ValueType.Array) itemType).getItemType();
} }
if (degree > 3) { if (degree > 3) {
diagnostics.error(location, "Unsupported type: {{t0}}", type); diagnostics.error(location, "Unsupported type: {{t0}}", type);
@ -711,14 +712,15 @@ class JavascriptNativeProcessor {
} }
if (itemType instanceof ValueType.Object) { if (itemType instanceof ValueType.Object) {
String className = ((ValueType.Object)itemType).getClassName(); String className = ((ValueType.Object) itemType).getClassName();
if (className.equals("java.lang.String")) { if (className.equals("java.lang.String")) {
String methodName = "unwrapStringArray"; String methodName = "unwrapStringArray";
if (degree > 1) { if (degree > 1) {
methodName += degree; methodName += degree;
} }
ValueType argType = degree == 1 ? ValueType.parse(JSStringArray.class) : ValueType argType = degree == 1
ValueType.parse(JSArray.class); ? ValueType.parse(JSStringArray.class)
: ValueType.parse(JSArray.class);
return unwrap(var, methodName, argType, type, location.getSourceLocation()); return unwrap(var, methodName, argType, type, location.getSourceLocation());
} else if (isNative(className)) { } else if (isNative(className)) {
return unwrapObjectArray(location, var, degree, itemType, type); return unwrapObjectArray(location, var, degree, itemType, type);
@ -804,7 +806,7 @@ class JavascriptNativeProcessor {
private Variable wrapArgument(CallLocation location, Variable var, ValueType type) { private Variable wrapArgument(CallLocation location, Variable var, ValueType type) {
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
String className = ((ValueType.Object)type).getClassName(); String className = ((ValueType.Object) type).getClassName();
ClassReader cls = classSource.get(className); ClassReader cls = classSource.get(className);
if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) { if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
return wrapFunctor(location, var, cls); return wrapFunctor(location, var, cls);
@ -838,7 +840,7 @@ class JavascriptNativeProcessor {
private Variable wrap(Variable var, ValueType type, InstructionLocation location) { private Variable wrap(Variable var, ValueType type, InstructionLocation location) {
if (type instanceof ValueType.Object) { if (type instanceof ValueType.Object) {
String className = ((ValueType.Object)type).getClassName(); String className = ((ValueType.Object) type).getClassName();
if (!className.equals("java.lang.String")) { if (!className.equals("java.lang.String")) {
return var; return var;
} }
@ -856,7 +858,7 @@ class JavascriptNativeProcessor {
private ValueType getWrappedType(ValueType type) { private ValueType getWrappedType(ValueType type) {
if (type instanceof ValueType.Array) { if (type instanceof ValueType.Array) {
ValueType itemType = ((ValueType.Array)type).getItemType(); ValueType itemType = ((ValueType.Array) type).getItemType();
return ValueType.arrayOf(getWrappedType(itemType)); return ValueType.arrayOf(getWrappedType(itemType));
} else if (type instanceof ValueType.Object) { } else if (type instanceof ValueType.Object) {
if (type.isObject("java.lang.String")) { if (type.isObject("java.lang.String")) {
@ -871,9 +873,9 @@ class JavascriptNativeProcessor {
private ValueType getWrapperType(ValueType type) { private ValueType getWrapperType(ValueType type) {
if (type instanceof ValueType.Array) { if (type instanceof ValueType.Array) {
ValueType itemType = ((ValueType.Array)type).getItemType(); ValueType itemType = ((ValueType.Array) type).getItemType();
if (itemType instanceof ValueType.Primitive) { if (itemType instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)itemType).getKind()) { switch (((ValueType.Primitive) itemType).getKind()) {
case BOOLEAN: case BOOLEAN:
return ValueType.parse(JSBooleanArray.class); return ValueType.parse(JSBooleanArray.class);
case BYTE: case BYTE:
@ -926,8 +928,8 @@ class JavascriptNativeProcessor {
} }
private boolean isProperSetter(MethodDescriptor desc) { private boolean isProperSetter(MethodDescriptor desc) {
if (desc.parameterCount() != 1 || !isSupportedType(desc.parameterType(0)) || if (desc.parameterCount() != 1 || !isSupportedType(desc.parameterType(0))
desc.getResultType() != ValueType.VOID) { || desc.getResultType() != ValueType.VOID) {
return false; return false;
} }
return isProperPrefix(desc.getName(), "set"); return isProperPrefix(desc.getName(), "set");
@ -942,13 +944,13 @@ class JavascriptNativeProcessor {
} }
private boolean isProperGetIndexer(MethodDescriptor desc) { private boolean isProperGetIndexer(MethodDescriptor desc) {
return desc.parameterCount() == 1 && isSupportedType(desc.parameterType(0)) && return desc.parameterCount() == 1 && isSupportedType(desc.parameterType(0))
isSupportedType(desc.getResultType()); && isSupportedType(desc.getResultType());
} }
private boolean isProperSetIndexer(MethodDescriptor desc) { private boolean isProperSetIndexer(MethodDescriptor desc) {
return desc.parameterCount() == 2 && isSupportedType(desc.parameterType(0)) && return desc.parameterCount() == 2 && isSupportedType(desc.parameterType(0))
isSupportedType(desc.parameterType(0)) && desc.getResultType() == ValueType.VOID; && isSupportedType(desc.parameterType(0)) && desc.getResultType() == ValueType.VOID;
} }
private String cutPrefix(String name, int prefixLength) { private String cutPrefix(String name, int prefixLength) {
@ -967,16 +969,16 @@ class JavascriptNativeProcessor {
return false; return false;
} }
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case LONG: case LONG:
return false; return false;
default: default:
return true; return true;
} }
} else if (type instanceof ValueType.Array) { } else if (type instanceof ValueType.Array) {
return isSupportedType(((ValueType.Array)type).getItemType()); return isSupportedType(((ValueType.Array) type).getItemType());
} else if (type instanceof ValueType.Object) { } else if (type instanceof ValueType.Object) {
String typeName = ((ValueType.Object)type).getClassName(); String typeName = ((ValueType.Object) type).getClassName();
return typeName.equals("java.lang.String") || nativeRepos.isJavaScriptClass(typeName); return typeName.equals("java.lang.String") || nativeRepos.isJavaScriptClass(typeName);
} else { } else {
return false; return false;

View File

@ -33,7 +33,7 @@ public final class Platform {
} }
public static PlatformObject getPlatformObject(Object obj) { public static PlatformObject getPlatformObject(Object obj) {
return (PlatformObject)JS.marshall(obj); return (PlatformObject) JS.marshall(obj);
} }
@GeneratedBy(PlatformGenerator.class) @GeneratedBy(PlatformGenerator.class)
@ -41,8 +41,8 @@ public final class Platform {
public static native Object clone(Object obj); public static native Object clone(Object obj);
public static boolean isInstance(PlatformObject obj, PlatformClass cls) { public static boolean isInstance(PlatformObject obj, PlatformClass cls) {
return obj != null && !JS.isUndefined(obj.getPlatformClass().getMetadata()) && return obj != null && !JS.isUndefined(obj.getPlatformClass().getMetadata())
isAssignable(obj.getPlatformClass(), cls); && isAssignable(obj.getPlatformClass(), cls);
} }
public static boolean isAssignable(PlatformClass from, PlatformClass to) { public static boolean isAssignable(PlatformClass from, PlatformClass to) {
@ -63,15 +63,15 @@ public final class Platform {
public static native Class<?> asJavaClass(PlatformObject obj); public static native Class<?> asJavaClass(PlatformObject obj);
public static PlatformPrimitives getPrimitives() { public static PlatformPrimitives getPrimitives() {
return (PlatformPrimitives)JS.getGlobal(); return (PlatformPrimitives) JS.getGlobal();
} }
public static PlatformConsole getConsole() { public static PlatformConsole getConsole() {
return (PlatformConsole)JS.getGlobal(); return (PlatformConsole) JS.getGlobal();
} }
public static int nextObjectId() { public static int nextObjectId() {
return ((PlatformHelper)JS.getGlobal()).nextId(); return ((PlatformHelper) JS.getGlobal()).nextId();
} }
public static <T> T newInstance(PlatformClass cls) { public static <T> T newInstance(PlatformClass cls) {
@ -127,14 +127,14 @@ public final class Platform {
public static native int schedule(PlatformRunnable runnable, int timeout); public static native int schedule(PlatformRunnable runnable, int timeout);
public static void killSchedule(int id) { public static void killSchedule(int id) {
((PlatformHelper)JS.getGlobal()).killSchedule(id); ((PlatformHelper) JS.getGlobal()).killSchedule(id);
} }
public static <T> PlatformQueue<T> createQueue() { public static <T> PlatformQueue<T> createQueue() {
return ((PlatformHelper)JS.getGlobal()).newQueue(); return ((PlatformHelper) JS.getGlobal()).newQueue();
} }
public static PlatformString stringFromCharCode(int charCode) { public static PlatformString stringFromCharCode(int charCode) {
return ((PlatformHelper)JS.getGlobal()).getStringClass().fromCharCode(charCode); return ((PlatformHelper) JS.getGlobal()).getStringClass().fromCharCode(charCode);
} }
} }

View File

@ -45,8 +45,8 @@ public class AnnotationDependencySupport extends AbstractDependencyListener {
@Override @Override
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
if (method.getReference().getClassName().equals(Platform.class.getName()) && if (method.getReference().getClassName().equals(Platform.class.getName())
method.getReference().getName().equals("getAnnotations")) { && method.getReference().getName().equals("getAnnotations")) {
method.getResult().propagate(agent.getType("[" + Annotation.class.getName())); method.getResult().propagate(agent.getType("[" + Annotation.class.getName()));
agent.linkMethod(new MethodReference(PlatformAnnotationProvider.class, "getAnnotations", agent.linkMethod(new MethodReference(PlatformAnnotationProvider.class, "getAnnotations",
Annotation[].class), location); Annotation[].class), location);

View File

@ -133,7 +133,7 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
} else if (returnType instanceof ValueType.Array) { } else if (returnType instanceof ValueType.Array) {
return className.startsWith("["); return className.startsWith("[");
} else { } else {
return isSubclass(classSource, className, ((ValueType.Object)returnType).getClassName()); return isSubclass(classSource, className, ((ValueType.Object) returnType).getClassName());
} }
} }

View File

@ -31,9 +31,9 @@ public class AsyncMethodProcessor implements ClassHolderTransformer {
@Override @Override
public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) { public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {
for (MethodHolder method : cls.getMethods()) { for (MethodHolder method : cls.getMethods()) {
if (method.hasModifier(ElementModifier.NATIVE) && if (method.hasModifier(ElementModifier.NATIVE)
method.getAnnotations().get(Async.class.getName()) != null && && method.getAnnotations().get(Async.class.getName()) != null
method.getAnnotations().get(GeneratedBy.class.getName()) == null) { && method.getAnnotations().get(GeneratedBy.class.getName()) == null) {
ValueType[] signature = new ValueType[method.parameterCount() + 2]; ValueType[] signature = new ValueType[method.parameterCount() + 2];
for (int i = 0; i < method.parameterCount(); ++i) { for (int i = 0; i < method.parameterCount(); ++i) {
signature[i] = method.parameterType(i); signature[i] = method.parameterType(i);
@ -43,10 +43,10 @@ public class AsyncMethodProcessor implements ClassHolderTransformer {
MethodDescriptor asyncDesc = new MethodDescriptor(method.getName(), signature); MethodDescriptor asyncDesc = new MethodDescriptor(method.getName(), signature);
MethodHolder asyncMethod = cls.getMethod(asyncDesc); MethodHolder asyncMethod = cls.getMethod(asyncDesc);
if (asyncMethod != null) { if (asyncMethod != null) {
if (asyncMethod.hasModifier(ElementModifier.STATIC) != if (asyncMethod.hasModifier(ElementModifier.STATIC)
method.hasModifier(ElementModifier.STATIC)) { != method.hasModifier(ElementModifier.STATIC)) {
diagnostics.error(new CallLocation(method.getReference()), "Methods {{m0}} and {{m1}} must " + diagnostics.error(new CallLocation(method.getReference()), "Methods {{m0}} and {{m1}} must "
"both be either static or non-static", + "both be either static or non-static",
method.getReference(), asyncMethod.getReference()); method.getReference(), asyncMethod.getReference());
} }
AnnotationHolder annot = new AnnotationHolder(GeneratedBy.class.getName()); AnnotationHolder annot = new AnnotationHolder(GeneratedBy.class.getName());

View File

@ -35,8 +35,8 @@ class BuildTimeResourceProxyBuilder {
static { static {
defaultValues.put(boolean.class, false); defaultValues.put(boolean.class, false);
defaultValues.put(byte.class, (byte)0); defaultValues.put(byte.class, (byte) 0);
defaultValues.put(short.class, (short)0); defaultValues.put(short.class, (short) 0);
defaultValues.put(int.class, 0); defaultValues.put(int.class, 0);
defaultValues.put(float.class, 0F); defaultValues.put(float.class, 0F);
defaultValues.put(double.class, 0.0); defaultValues.put(double.class, 0.0);
@ -70,8 +70,8 @@ class BuildTimeResourceProxyBuilder {
BuildTimeResourceProxyFactory create() { BuildTimeResourceProxyFactory create() {
if (!rootIface.isInterface()) { if (!rootIface.isInterface()) {
throw new IllegalArgumentException("Error creating a new resource of type " + rootIface.getName() + throw new IllegalArgumentException("Error creating a new resource of type " + rootIface.getName()
" that is not an interface"); + " that is not an interface");
} }
scanIface(rootIface); scanIface(rootIface);
@ -102,8 +102,8 @@ class BuildTimeResourceProxyBuilder {
private void scanIface(Class<?> iface) { private void scanIface(Class<?> iface) {
if (!Resource.class.isAssignableFrom(iface)) { if (!Resource.class.isAssignableFrom(iface)) {
throw new IllegalArgumentException("Error creating a new resource of type " + iface.getName() + "." + throw new IllegalArgumentException("Error creating a new resource of type " + iface.getName() + "."
" This type does not implement the " + Resource.class.getName() + " interface"); + " This type does not implement the " + Resource.class.getName() + " interface");
} }
// Scan methods // Scan methods
@ -127,18 +127,18 @@ class BuildTimeResourceProxyBuilder {
Class<?> getterType = property.getValue(); Class<?> getterType = property.getValue();
Class<?> setterType = setters.get(propertyName); Class<?> setterType = setters.get(propertyName);
if (setterType == null) { if (setterType == null) {
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName + throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName
" has a getter, but does not have a setter"); + " has a getter, but does not have a setter");
} }
if (!setterType.equals(getterType)) { if (!setterType.equals(getterType)) {
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName + throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName
" has a getter and a setter of different types"); + " has a getter and a setter of different types");
} }
} }
for (String propertyName : setters.keySet()) { for (String propertyName : setters.keySet()) {
if (!getters.containsKey(propertyName)) { if (!getters.containsKey(propertyName)) {
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName + throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName
" has a setter, but does not have a getter"); + " has a setter, but does not have a getter");
} }
} }
@ -148,8 +148,8 @@ class BuildTimeResourceProxyBuilder {
Class<?> propertyType = property.getValue(); Class<?> propertyType = property.getValue();
if (!allowedPropertyTypes.contains(propertyType)) { if (!allowedPropertyTypes.contains(propertyType)) {
if (!propertyType.isInterface() || !Resource.class.isAssignableFrom(propertyType)) { if (!propertyType.isInterface() || !Resource.class.isAssignableFrom(propertyType)) {
throw new IllegalArgumentException("Property " + rootIface.getName() + "." + propertyName + throw new IllegalArgumentException("Property " + rootIface.getName() + "." + propertyName
" has an illegal type " + propertyType.getName()); + " has an illegal type " + propertyType.getName());
} }
} }
if (!propertyTypes.containsKey(propertyName)) { if (!propertyTypes.containsKey(propertyName)) {
@ -164,45 +164,45 @@ class BuildTimeResourceProxyBuilder {
} }
private void throwInvalidMethod(Method method) { private void throwInvalidMethod(Method method) {
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." + throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
method.getName() + " is not likely to be either getter or setter"); + method.getName() + " is not likely to be either getter or setter");
} }
private void scanGetter(Method method) { private void scanGetter(Method method) {
String propertyName = extractPropertyName(method.getName().substring(3)); String propertyName = extractPropertyName(method.getName().substring(3));
if (propertyName == null || method.getReturnType().equals(void.class) || if (propertyName == null || method.getReturnType().equals(void.class)
method.getParameterTypes().length > 0) { || method.getParameterTypes().length > 0) {
throwInvalidMethod(method); throwInvalidMethod(method);
} }
if (getters.put(propertyName, method.getReturnType()) != null) { if (getters.put(propertyName, method.getReturnType()) != null) {
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." + throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
method.getName() + " is a duplicate getter for property " + propertyName); + method.getName() + " is a duplicate getter for property " + propertyName);
} }
methods.put(method, new BuildTimeResourceGetter(getPropertyIndex(propertyName))); methods.put(method, new BuildTimeResourceGetter(getPropertyIndex(propertyName)));
} }
private void scanBooleanGetter(Method method) { private void scanBooleanGetter(Method method) {
String propertyName = extractPropertyName(method.getName().substring(2)); String propertyName = extractPropertyName(method.getName().substring(2));
if (propertyName == null || !method.getReturnType().equals(boolean.class) || if (propertyName == null || !method.getReturnType().equals(boolean.class)
method.getParameterTypes().length > 0) { || method.getParameterTypes().length > 0) {
throwInvalidMethod(method); throwInvalidMethod(method);
} }
if (getters.put(propertyName, method.getReturnType()) != null) { if (getters.put(propertyName, method.getReturnType()) != null) {
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." + throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
method.getName() + " is a duplicate getter for property " + propertyName); + method.getName() + " is a duplicate getter for property " + propertyName);
} }
methods.put(method, new BuildTimeResourceGetter(getPropertyIndex(propertyName))); methods.put(method, new BuildTimeResourceGetter(getPropertyIndex(propertyName)));
} }
private void scanSetter(Method method) { private void scanSetter(Method method) {
String propertyName = extractPropertyName(method.getName().substring(3)); String propertyName = extractPropertyName(method.getName().substring(3));
if (propertyName == null || !method.getReturnType().equals(void.class) || if (propertyName == null || !method.getReturnType().equals(void.class)
method.getParameterTypes().length != 1) { || method.getParameterTypes().length != 1) {
throwInvalidMethod(method); throwInvalidMethod(method);
} }
if (setters.put(propertyName, method.getParameterTypes()[0]) != null) { if (setters.put(propertyName, method.getParameterTypes()[0]) != null) {
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." + throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
method.getName() + " is a duplicate setter for property " + propertyName); + method.getName() + " is a duplicate setter for property " + propertyName);
} }
methods.put(method, new BuildTimeResourceSetter(getPropertyIndex(propertyName))); methods.put(method, new BuildTimeResourceSetter(getPropertyIndex(propertyName)));
} }

View File

@ -30,7 +30,7 @@ class BuildTimeResourceWriterMethod implements BuildTimeResourceMethod {
@Override @Override
public Object invoke(BuildTimeResourceProxy proxy, Object[] args) throws Throwable { public Object invoke(BuildTimeResourceProxy proxy, Object[] args) throws Throwable {
SourceWriter writer = (SourceWriter)args[0]; SourceWriter writer = (SourceWriter) args[0];
writer.append('{'); writer.append('{');
for (int i = 0; i < propertyNames.length; ++i) { for (int i = 0; i < propertyNames.length; ++i) {
if (i > 0) { if (i > 0) {

View File

@ -43,14 +43,15 @@ public class ClassScopedMetadataProviderNativeGenerator implements Generator {
return; return;
} }
if (!method.hasModifier(ElementModifier.NATIVE)) { if (!method.hasModifier(ElementModifier.NATIVE)) {
context.getDiagnostics().error(new CallLocation(methodRef), "Method {{m0}} is marked with " + context.getDiagnostics().error(new CallLocation(methodRef), "Method {{m0}} is marked with "
"{{c1}} annotation, but it is not native", methodRef, ClassScopedMetadataProvider.class.getName()); + "{{c1}} annotation, but it is not native", methodRef,
ClassScopedMetadataProvider.class.getName());
return; return;
} }
// Find and instantiate metadata generator // Find and instantiate metadata generator
ValueType generatorType = providerAnnot.getValue("value").getJavaClass(); ValueType generatorType = providerAnnot.getValue("value").getJavaClass();
String generatorClassName = ((ValueType.Object)generatorType).getClassName(); String generatorClassName = ((ValueType.Object) generatorType).getClassName();
Class<?> generatorClass; Class<?> generatorClass;
try { try {
generatorClass = Class.forName(generatorClassName, true, context.getClassLoader()); generatorClass = Class.forName(generatorClassName, true, context.getClassLoader());
@ -63,24 +64,24 @@ public class ClassScopedMetadataProviderNativeGenerator implements Generator {
try { try {
cons = generatorClass.getConstructor(); cons = generatorClass.getConstructor();
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have " + context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have "
"a public no-arg constructor", generatorClassName); + "a public no-arg constructor", generatorClassName);
return; return;
} }
ClassScopedMetadataGenerator generator; ClassScopedMetadataGenerator generator;
try { try {
generator = (ClassScopedMetadataGenerator)cons.newInstance(); generator = (ClassScopedMetadataGenerator) cons.newInstance();
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata " + context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata "
"generator {{c0}}", generatorClassName); + "generator {{c0}}", generatorClassName);
return; return;
} }
DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(), DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(),
context.getClassLoader(), context.getProperties(), context); context.getClassLoader(), context.getProperties(), context);
Map<String, Resource> resourceMap = generator.generateMetadata(metadataContext, methodRef); Map<String, Resource> resourceMap = generator.generateMetadata(metadataContext, methodRef);
writer.append("var p").ws().append("=").ws().append("\"" + Renderer.escapeString("$$res_" + writer.append("var p").ws().append("=").ws().append("\"" + Renderer.escapeString("$$res_"
writer.getNaming().getFullNameFor(methodRef)) + "\"").append(";").softNewLine(); + writer.getNaming().getFullNameFor(methodRef)) + "\"").append(";").softNewLine();
for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) { for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
writer.appendClass(entry.getKey()).append("[p]").ws().append("=").ws(); writer.appendClass(entry.getKey()).append("[p]").ws().append("=").ws();
ResourceWriterHelper.write(writer, entry.getValue()); ResourceWriterHelper.write(writer, entry.getValue());

View File

@ -50,8 +50,8 @@ public class EnumDependencySupport extends AbstractDependencyListener {
@Override @Override
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
if (method.getReference().getClassName().equals(Platform.class.getName()) && if (method.getReference().getClassName().equals(Platform.class.getName())
method.getReference().getName().equals("getEnumConstants")) { && method.getReference().getName().equals("getEnumConstants")) {
allEnums.connect(method.getResult().getArrayItem()); allEnums.connect(method.getResult().getArrayItem());
final MethodReference ref = method.getReference(); final MethodReference ref = method.getReference();
allEnums.addConsumer(type -> { allEnums.addConsumer(type -> {

View File

@ -42,7 +42,7 @@ public class MetadataProviderNativeGenerator implements Generator {
// Find and instantiate metadata generator // Find and instantiate metadata generator
ValueType generatorType = providerAnnot.getValue("value").getJavaClass(); ValueType generatorType = providerAnnot.getValue("value").getJavaClass();
String generatorClassName = ((ValueType.Object)generatorType).getClassName(); String generatorClassName = ((ValueType.Object) generatorType).getClassName();
Class<?> generatorClass; Class<?> generatorClass;
try { try {
generatorClass = Class.forName(generatorClassName, true, context.getClassLoader()); generatorClass = Class.forName(generatorClassName, true, context.getClassLoader());
@ -55,16 +55,16 @@ public class MetadataProviderNativeGenerator implements Generator {
try { try {
cons = generatorClass.getConstructor(); cons = generatorClass.getConstructor();
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have " + context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have "
"a public no-arg constructor", generatorClassName); + "a public no-arg constructor", generatorClassName);
return; return;
} }
MetadataGenerator generator; MetadataGenerator generator;
try { try {
generator = (MetadataGenerator)cons.newInstance(); generator = (MetadataGenerator) cons.newInstance();
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata " + context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata "
"generator {{c0}}", generatorClassName); + "generator {{c0}}", generatorClassName);
return; return;
} }
DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(), DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(),

View File

@ -45,8 +45,8 @@ class MetadataProviderTransformer implements ClassHolderTransformer {
if (providerAnnot != null) { if (providerAnnot != null) {
ValueType[] params = method.getParameterTypes(); ValueType[] params = method.getParameterTypes();
if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) { if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) {
diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} " + diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} "
"must take exactly one parameter of type {{c2}}", + "must take exactly one parameter of type {{c2}}",
method.getReference(), ClassScopedMetadataProvider.class.getName(), method.getReference(), ClassScopedMetadataProvider.class.getName(),
PlatformClass.class.getName()); PlatformClass.class.getName());
} }
@ -111,8 +111,8 @@ class MetadataProviderTransformer implements ClassHolderTransformer {
return false; return false;
} }
if (!method.hasModifier(ElementModifier.NATIVE)) { if (!method.hasModifier(ElementModifier.NATIVE)) {
diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} is marked with " + diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} is marked with "
"{{c1}} annotation, but it is not native", method.getReference(), + "{{c1}} annotation, but it is not native", method.getReference(),
MetadataProvider.class.getName()); MetadataProvider.class.getName());
return false; return false;
} }

View File

@ -108,7 +108,7 @@ class ResourceAccessorInjector implements Injector {
private void writePropertyAccessor(InjectorContext context, Expr property) throws IOException { private void writePropertyAccessor(InjectorContext context, Expr property) throws IOException {
if (property instanceof ConstantExpr) { if (property instanceof ConstantExpr) {
String str = (String)((ConstantExpr)property).getValue(); String str = (String) ((ConstantExpr) property).getValue();
if (str.isEmpty()) { if (str.isEmpty()) {
context.getWriter().append("[\"\"]"); context.getWriter().append("[\"\"]");
return; return;
@ -125,7 +125,7 @@ class ResourceAccessorInjector implements Injector {
private void writeStringExpr(InjectorContext context, Expr expr) throws IOException { private void writeStringExpr(InjectorContext context, Expr expr) throws IOException {
if (expr instanceof ConstantExpr) { if (expr instanceof ConstantExpr) {
String str = (String)((ConstantExpr)expr).getValue(); String str = (String) ((ConstantExpr) expr).getValue();
context.getWriter().append('"'); context.getWriter().append('"');
context.writeEscaped(str); context.writeEscaped(str);
context.getWriter().append('"'); context.getWriter().append('"');

View File

@ -46,7 +46,7 @@ class ResourceProgramTransformer {
for (int i = 0; i < instructions.size(); ++i) { for (int i = 0; i < instructions.size(); ++i) {
Instruction insn = instructions.get(i); Instruction insn = instructions.get(i);
if (insn instanceof InvokeInstruction) { if (insn instanceof InvokeInstruction) {
InvokeInstruction invoke = (InvokeInstruction)insn; InvokeInstruction invoke = (InvokeInstruction) insn;
List<Instruction> replacement = transformInvoke(invoke); List<Instruction> replacement = transformInvoke(invoke);
if (replacement != null) { if (replacement != null) {
instructions.set(i, new EmptyInstruction()); instructions.set(i, new EmptyInstruction());
@ -62,8 +62,8 @@ class ResourceProgramTransformer {
return null; return null;
} }
MethodReference method = insn.getMethod(); MethodReference method = insn.getMethod();
if (method.getClassName().equals(ResourceArray.class.getName()) || if (method.getClassName().equals(ResourceArray.class.getName())
method.getClassName().equals(ResourceMap.class.getName())) { || method.getClassName().equals(ResourceMap.class.getName())) {
if (method.getName().equals("keys")) { if (method.getName().equals("keys")) {
return transformKeys(insn); return transformKeys(insn);
} }
@ -142,7 +142,7 @@ class ResourceProgramTransformer {
ValueType type = insn.getMethod().getDescriptor().getResultType(); ValueType type = insn.getMethod().getDescriptor().getResultType();
List<Instruction> instructions = new ArrayList<>(); List<Instruction> instructions = new ArrayList<>();
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
getAndCastProperty(insn, property, instructions, boolean.class); getAndCastProperty(insn, property, instructions, boolean.class);
return instructions; return instructions;
@ -166,7 +166,7 @@ class ResourceProgramTransformer {
break; break;
} }
} else if (type instanceof ValueType.Object) { } else if (type instanceof ValueType.Object) {
switch (((ValueType.Object)type).getClassName()) { switch (((ValueType.Object) type).getClassName()) {
case "java.lang.String": { case "java.lang.String": {
Variable resultVar = insn.getProgram().createVariable(); Variable resultVar = insn.getProgram().createVariable();
getProperty(insn, property, instructions, resultVar); getProperty(insn, property, instructions, resultVar);
@ -218,8 +218,8 @@ class ResourceProgramTransformer {
InvokeInstruction castInvoke = new InvokeInstruction(); InvokeInstruction castInvoke = new InvokeInstruction();
castInvoke.setType(InvocationType.SPECIAL); castInvoke.setType(InvocationType.SPECIAL);
String primitiveCapitalized = primitive.getName(); String primitiveCapitalized = primitive.getName();
primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0)) + primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0))
primitiveCapitalized.substring(1); + primitiveCapitalized.substring(1);
castInvoke.setMethod(new MethodReference(ResourceAccessor.class, "castTo" + primitiveCapitalized, castInvoke.setMethod(new MethodReference(ResourceAccessor.class, "castTo" + primitiveCapitalized,
Object.class, primitive)); Object.class, primitive));
castInvoke.getArguments().add(resultVar); castInvoke.getArguments().add(resultVar);
@ -231,7 +231,7 @@ class ResourceProgramTransformer {
ValueType type = insn.getMethod().getDescriptor().parameterType(0); ValueType type = insn.getMethod().getDescriptor().parameterType(0);
List<Instruction> instructions = new ArrayList<>(); List<Instruction> instructions = new ArrayList<>();
if (type instanceof ValueType.Primitive) { if (type instanceof ValueType.Primitive) {
switch (((ValueType.Primitive)type).getKind()) { switch (((ValueType.Primitive) type).getKind()) {
case BOOLEAN: case BOOLEAN:
castAndSetProperty(insn, property, instructions, boolean.class); castAndSetProperty(insn, property, instructions, boolean.class);
return instructions; return instructions;
@ -255,7 +255,7 @@ class ResourceProgramTransformer {
break; break;
} }
} else if (type instanceof ValueType.Object) { } else if (type instanceof ValueType.Object) {
switch (((ValueType.Object)type).getClassName()) { switch (((ValueType.Object) type).getClassName()) {
case "java.lang.String": { case "java.lang.String": {
Variable castVar = insn.getProgram().createVariable(); Variable castVar = insn.getProgram().createVariable();
InvokeInstruction castInvoke = new InvokeInstruction(); InvokeInstruction castInvoke = new InvokeInstruction();
@ -300,8 +300,8 @@ class ResourceProgramTransformer {
InvokeInstruction castInvoke = new InvokeInstruction(); InvokeInstruction castInvoke = new InvokeInstruction();
castInvoke.setType(InvocationType.SPECIAL); castInvoke.setType(InvocationType.SPECIAL);
String primitiveCapitalized = primitive.getName(); String primitiveCapitalized = primitive.getName();
primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0)) + primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0))
primitiveCapitalized.substring(1); + primitiveCapitalized.substring(1);
castInvoke.setMethod(new MethodReference(ResourceAccessor.class, "castFrom" + primitiveCapitalized, castInvoke.setMethod(new MethodReference(ResourceAccessor.class, "castFrom" + primitiveCapitalized,
primitive, Object.class)); primitive, Object.class));
castInvoke.getArguments().add(insn.getArguments().get(0)); castInvoke.getArguments().add(insn.getArguments().get(0));

View File

@ -31,16 +31,16 @@ final class ResourceWriterHelper {
writer.append("null"); writer.append("null");
} else { } else {
if (resource instanceof ResourceWriter) { if (resource instanceof ResourceWriter) {
((ResourceWriter)resource).write(writer); ((ResourceWriter) resource).write(writer);
} else if (resource instanceof Number) { } else if (resource instanceof Number) {
writer.append(resource); writer.append(resource);
} else if (resource instanceof Boolean) { } else if (resource instanceof Boolean) {
writer.append(resource == Boolean.TRUE ? "true" : "false"); writer.append(resource == Boolean.TRUE ? "true" : "false");
} else if (resource instanceof String) { } else if (resource instanceof String) {
writeString(writer, (String)resource); writeString(writer, (String) resource);
} else { } else {
throw new RuntimeException("Error compiling resources. Value of illegal type found: " + throw new RuntimeException("Error compiling resources. Value of illegal type found: "
resource.getClass()); + resource.getClass());
} }
} }
} }

View File

@ -77,7 +77,7 @@ public final class AsyncProgram {
prime[2] = true; prime[2] = true;
prime[3] = true; prime[3] = true;
nextPrime: for (int i = 5; i < prime.length; i += 2) { nextPrime: for (int i = 5; i < prime.length; i += 2) {
int maxPrime = (int)Math.sqrt(i); int maxPrime = (int) Math.sqrt(i);
for (int j = 3; j <= maxPrime; j += 2) { for (int j = 3; j <= maxPrime; j += 2) {
Thread.yield(); Thread.yield();
if (prime[j] && i % j == 0) { if (prime[j] && i % j == 0) {

View File

@ -71,18 +71,18 @@ public class Scene {
int parts = 30; int parts = 30;
for (int i = 0; i < parts; ++i) { for (int i = 0; i < parts; ++i) {
PolygonShape shape = new PolygonShape(); PolygonShape shape = new PolygonShape();
double angle1 = i / (double)parts * 2 * Math.PI; double angle1 = i / (double) parts * 2 * Math.PI;
double x1 = 2.7 * Math.cos(angle1); double x1 = 2.7 * Math.cos(angle1);
double y1 = 2.7 * Math.sin(angle1); double y1 = 2.7 * Math.sin(angle1);
double angle2 = (i + 1) / (double)parts * 2 * Math.PI; double angle2 = (i + 1) / (double) parts * 2 * Math.PI;
double x2 = 2.7 * Math.cos(angle2); double x2 = 2.7 * Math.cos(angle2);
double y2 = 2.7 * Math.sin(angle2); double y2 = 2.7 * Math.sin(angle2);
double angle = (angle1 + angle2) / 2; double angle = (angle1 + angle2) / 2;
double x = 0.01 * Math.cos(angle); double x = 0.01 * Math.cos(angle);
double y = 0.01 * Math.sin(angle); double y = 0.01 * Math.sin(angle);
shape.set(new Vec2[] { new Vec2((float)x1, (float)y1), new Vec2((float)x2, (float)y2), shape.set(new Vec2[] { new Vec2((float) x1, (float) y1), new Vec2((float) x2, (float) y2),
new Vec2((float)(x2 - x), (float)(y2 - y)), new Vec2((float)(x1 - x), (float)(y1 - y)) }, 4); new Vec2((float) (x2 - x), (float) (y2 - y)), new Vec2((float) (x1 - x), (float) (y1 - y)) }, 4);
fixture.shape = shape; fixture.shape = shape;
reel.createFixture(fixture); reel.createFixture(fixture);
} }
@ -137,10 +137,10 @@ public class Scene {
public void calculate() { public void calculate() {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
int timeToCalculate = (int)(currentTime - lastCalculated); int timeToCalculate = (int) (currentTime - lastCalculated);
long relativeTime = currentTime - startTime; long relativeTime = currentTime - startTime;
while (timeToCalculate > 10) { while (timeToCalculate > 10) {
int period = (int)((relativeTime + 5000) / 10000); int period = (int) ((relativeTime + 5000) / 10000);
reel.applyTorque(period % 2 == 0 ? 8f : -8f); reel.applyTorque(period % 2 == 0 ? 8f : -8f);
world.step(0.01f, 20, 40); world.step(0.01f, 20, 40);
lastCalculated += 10; lastCalculated += 10;
@ -149,7 +149,7 @@ public class Scene {
} }
public int timeUntilNextStep() { public int timeUntilNextStep() {
return (int)Math.max(0, lastCalculated + 10 - System.currentTimeMillis()); return (int) Math.max(0, lastCalculated + 10 - System.currentTimeMillis());
} }
public World getWorld() { public World getWorld() {

View File

@ -43,7 +43,7 @@ public class BenchmarkStarter implements EntryPoint {
@Override @Override
public void onModuleLoad() { public void onModuleLoad() {
document = RootPanel.getBodyElement().getOwnerDocument(); document = RootPanel.getBodyElement().getOwnerDocument();
canvas = (CanvasElement)document.getElementById("benchmark-canvas"); canvas = (CanvasElement) document.getElementById("benchmark-canvas");
resultTableBody = document.getElementById("result-table-body"); resultTableBody = document.getElementById("result-table-body");
startMillisecond = System.currentTimeMillis(); startMillisecond = System.currentTimeMillis();
makeStep(); makeStep();
@ -53,7 +53,7 @@ public class BenchmarkStarter implements EntryPoint {
double start = Performance.now(); double start = Performance.now();
scene.calculate(); scene.calculate();
double end = Performance.now(); double end = Performance.now();
int second = (int)((System.currentTimeMillis() - startMillisecond) / 1000); int second = (int) ((System.currentTimeMillis() - startMillisecond) / 1000);
if (second > currentSecond) { if (second > currentSecond) {
Element row = document.createElement("tr"); Element row = document.createElement("tr");
resultTableBody.appendChild(row); resultTableBody.appendChild(row);
@ -94,13 +94,13 @@ public class BenchmarkStarter implements EntryPoint {
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) { for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
Shape shape = fixture.getShape(); Shape shape = fixture.getShape();
if (shape.getType() == ShapeType.CIRCLE) { if (shape.getType() == ShapeType.CIRCLE) {
CircleShape circle = (CircleShape)shape; CircleShape circle = (CircleShape) shape;
context.beginPath(); context.beginPath();
context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true); context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
context.closePath(); context.closePath();
context.stroke(); context.stroke();
} else if (shape.getType() == ShapeType.POLYGON) { } else if (shape.getType() == ShapeType.POLYGON) {
PolygonShape poly = (PolygonShape)shape; PolygonShape poly = (PolygonShape) shape;
Vec2[] vertices = poly.getVertices(); Vec2[] vertices = poly.getVertices();
context.beginPath(); context.beginPath();
context.moveTo(vertices[0].x, vertices[0].y); context.moveTo(vertices[0].x, vertices[0].y);

Some files were not shown because too many files have changed in this diff Show More