diff --git a/.gitignore b/.gitignore
index eb16d6f43..4b4a81240 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/.directory
/.project
/.settings
+.checkstyle
diff --git a/teavm-core/checkstyle.xml b/teavm-core/checkstyle.xml
new file mode 100644
index 000000000..ada1c9ec6
--- /dev/null
+++ b/teavm-core/checkstyle.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/teavm-core/license-regexp.txt b/teavm-core/license-regexp.txt
new file mode 100644
index 000000000..05bf0b063
--- /dev/null
+++ b/teavm-core/license-regexp.txt
@@ -0,0 +1,15 @@
+/\*
+ \* Copyright 2[0-9]{3} .+
+ \*
+ \* Licensed under the Apache License, Version 2.0 \(the "License"\);
+ \* you may not use this file except in compliance with the License.
+ \* You may obtain a copy of the License at
+ \*
+ \* http://www\.apache\.org/licenses/LICENSE-2.0
+ \*
+ \* Unless required by applicable law or agreed to in writing, software
+ \* distributed under the License is distributed on an "AS IS" BASIS,
+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ \* See the License for the specific language governing permissions and
+ \* limitations under the License.
+ \*/
\ No newline at end of file
diff --git a/teavm-core/pom.xml b/teavm-core/pom.xml
index 249886d86..b0423ce65 100644
--- a/teavm-core/pom.xml
+++ b/teavm-core/pom.xml
@@ -42,4 +42,41 @@
3.3.1
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 2.11
+
+
+ validate
+ validate
+
+ config_loc=${basedir}
+ checkstyle.xml
+ UTF-8
+ true
+ true
+ false
+
+
+ check
+
+
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 2.5.2
+
+
+
\ No newline at end of file
diff --git a/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java b/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java
index 2a9684fc5..477a25121 100644
--- a/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java
+++ b/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java
@@ -87,12 +87,13 @@ public class DefaultNamingStrategy implements NamingStrategy {
@Override
public String getFullNameFor(MethodReference method) throws NamingException {
+ MethodReference originalMethod = method;
if (!minifying) {
return getNameFor(method.getClassName()) + "_" + getNameFor(method);
}
method = getRealMethod(method);
if (method == null) {
- throw new NamingException("Can't provide name for method as it was not found: " + method);
+ throw new NamingException("Can't provide name for method as it was not found: " + originalMethod);
}
String key = method.toString();
String alias = privateAliases.get(key);
diff --git a/teavm-core/src/main/java/org/teavm/codegen/SourceWriter.java b/teavm-core/src/main/java/org/teavm/codegen/SourceWriter.java
index f3a22dff2..8551956cd 100644
--- a/teavm-core/src/main/java/org/teavm/codegen/SourceWriter.java
+++ b/teavm-core/src/main/java/org/teavm/codegen/SourceWriter.java
@@ -27,7 +27,7 @@ import org.teavm.model.ValueType;
*/
public class SourceWriter implements Appendable {
private Appendable innerWriter;
- private int indentSize = 0;
+ private int indentSize;
private NamingStrategy naming;
private boolean lineStart;
private boolean minified;
diff --git a/teavm-core/src/main/java/org/teavm/common/ConcurrentCachedMapper.java b/teavm-core/src/main/java/org/teavm/common/ConcurrentCachedMapper.java
index 9ba058e3b..c6cebba65 100644
--- a/teavm-core/src/main/java/org/teavm/common/ConcurrentCachedMapper.java
+++ b/teavm-core/src/main/java/org/teavm/common/ConcurrentCachedMapper.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2013 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.teavm.common;
import java.util.ArrayList;
@@ -71,7 +86,7 @@ public class ConcurrentCachedMapper implements Mapper {
keyListeners.add(listener);
}
- public static interface KeyListener {
+ public interface KeyListener {
void keyAdded(S key);
}
}
diff --git a/teavm-core/src/main/java/org/teavm/common/DisjointSet.java b/teavm-core/src/main/java/org/teavm/common/DisjointSet.java
index aa9c2bb52..cbdf6cdc9 100644
--- a/teavm-core/src/main/java/org/teavm/common/DisjointSet.java
+++ b/teavm-core/src/main/java/org/teavm/common/DisjointSet.java
@@ -26,7 +26,7 @@ public class DisjointSet {
private int[] rank = new int[16];
private int[] setSize = new int[16];
private int maxRank;
- private int size = 0;
+ private int size;
public int find(int node) {
int initial = node;
diff --git a/teavm-core/src/main/java/org/teavm/common/GraphBuilder.java b/teavm-core/src/main/java/org/teavm/common/GraphBuilder.java
index e3b965916..9180c965c 100644
--- a/teavm-core/src/main/java/org/teavm/common/GraphBuilder.java
+++ b/teavm-core/src/main/java/org/teavm/common/GraphBuilder.java
@@ -27,7 +27,7 @@ import java.util.List;
public class GraphBuilder {
private GraphImpl builtGraph;
private List addedEdges = new ArrayList<>();
- private int sz = 0;
+ private int sz;
public GraphBuilder() {
}
diff --git a/teavm-core/src/main/java/org/teavm/common/GraphIndexer.java b/teavm-core/src/main/java/org/teavm/common/GraphIndexer.java
index 7eb0dfbd2..e65a27dfc 100644
--- a/teavm-core/src/main/java/org/teavm/common/GraphIndexer.java
+++ b/teavm-core/src/main/java/org/teavm/common/GraphIndexer.java
@@ -23,6 +23,9 @@ import java.util.Comparator;
* @author Alexey Andreev
*/
public class GraphIndexer {
+ static final byte NONE = 0;
+ static final byte VISITING = 1;
+ static final byte VISITED = 2;
private int[] indexToNode;
private int[] nodeToIndex;
private Graph graph;
@@ -37,9 +40,6 @@ public class GraphIndexer {
}
private int sort(Graph graph) {
- final byte NONE = 0;
- final byte VISITING = 1;
- final byte VISITED = 2;
LoopGraph loopGraph = new LoopGraph(graph);
int sz = graph.size();
int[] indexToNode = new int[sz + 1];
@@ -89,6 +89,8 @@ public class GraphIndexer {
case NONE:
stack[stackSize++] = next;
break;
+ default:
+ break;
}
}
break;
diff --git a/teavm-core/src/main/java/org/teavm/common/GraphUtils.java b/teavm-core/src/main/java/org/teavm/common/GraphUtils.java
index 38861b8a4..a320cff6d 100644
--- a/teavm-core/src/main/java/org/teavm/common/GraphUtils.java
+++ b/teavm-core/src/main/java/org/teavm/common/GraphUtils.java
@@ -22,7 +22,14 @@ import java.util.Arrays;
*
* @author Alexey Andreev
*/
-public class GraphUtils {
+public final class GraphUtils {
+ static final byte NONE = 0;
+ static final byte VISITING = 1;
+ static final byte VISITED = 2;
+
+ private GraphUtils() {
+ }
+
public static Graph invert(Graph graph) {
int sz = graph.size();
GraphBuilder result = new GraphBuilder();
@@ -52,9 +59,6 @@ public class GraphUtils {
}
public static Graph removeLoops(Graph graph) {
- final byte NONE = 0;
- final byte VISITING = 1;
- final byte VISITED = 2;
int sz = graph.size();
GraphBuilder result = new GraphBuilder();
int[] stack = new int[sz * 2];
diff --git a/teavm-core/src/main/java/org/teavm/common/GraphWithIndexedEdges.java b/teavm-core/src/main/java/org/teavm/common/GraphWithIndexedEdges.java
deleted file mode 100644
index d80457536..000000000
--- a/teavm-core/src/main/java/org/teavm/common/GraphWithIndexedEdges.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2013 Alexey Andreev.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.teavm.common;
-
-import java.util.Arrays;
-
-/**
- *
- * @author Alexey Andreev
- */
-public class GraphWithIndexedEdges implements Graph {
- private int[][] incoming;
- private int[][] outgoing;
- private int[][] edgeIndex;
-
- public GraphWithIndexedEdges(Graph graph) {
- incoming = new int[graph.size()][];
- outgoing = new int[graph.size()][];
- edgeIndex = new int[graph.size()][];
- for (int i = 0; i < graph.size(); ++i) {
- outgoing[i] = graph.outgoingEdges(i);
- incoming[i] = new int[graph.incomingEdgesCount(i)];
- edgeIndex[i] = new int[graph.outgoingEdgesCount(i)];
- }
- int[] lastIncoming = new int[graph.size()];
- for (int i = 0; i < graph.size(); ++i) {
- int[] localOutgoing = outgoing[i];
- int[] localEdgeIndex = edgeIndex[i];
- for (int j = 0; j < localOutgoing.length; ++j) {
- int target = localOutgoing[j];
- int index = lastIncoming[target]++;
- incoming[target][index] = i;
- localEdgeIndex[j] = index;
- }
- }
- }
-
- @Override
- public int size() {
- return incoming.length;
- }
-
- @Override
- public int[] incomingEdges(int node) {
- int[] edges = incoming[node];
- return Arrays.copyOf(edges, edges.length);
- }
-
- @Override
- public int copyIncomingEdges(int node, int[] target) {
- int[] edges = incoming[node];
- System.arraycopy(edges, 0, target, 0, edges.length);
- return edges.length;
- }
-
- @Override
- public int[] outgoingEdges(int node) {
- int[] edges = outgoing[node];
- return Arrays.copyOf(edges, edges.length);
- }
-
- @Override
- public int copyOutgoingEdges(int node, int[] target) {
- int[] edges = outgoing[node];
- System.arraycopy(edges, 0, target, 0, edges.length);
- return edges.length;
- }
-
- @Override
- public int incomingEdgesCount(int node) {
- return incoming[node].length;
- }
-
- @Override
- public int outgoingEdgesCount(int node) {
- return outgoing[node].length;
- }
-
- /**
- * For given edge, identified by source node and index in source node edge array,
- * returns index in target node edge array. Works in constant time.
- */
- public int getEdgeIndex(int sourceNode, int sourceEdgeIndex) {
- return edgeIndex[sourceNode][sourceEdgeIndex];
- }
-}
diff --git a/teavm-core/src/main/java/org/teavm/common/RangeTree.java b/teavm-core/src/main/java/org/teavm/common/RangeTree.java
index f80e55acf..2815f155a 100644
--- a/teavm-core/src/main/java/org/teavm/common/RangeTree.java
+++ b/teavm-core/src/main/java/org/teavm/common/RangeTree.java
@@ -37,7 +37,7 @@ public class RangeTree {
}
}
- public static interface Node {
+ public interface Node {
Node getParent();
int getStart();
diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java
index 73f29c400..f69a51bca 100644
--- a/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java
+++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyChecker.java
@@ -410,10 +410,11 @@ public class DependencyChecker implements DependencyInfo {
DependencyStack stack = stackMap.get(item);
if (stack == null) {
sb.append(" at unknown location\n");
- }
- while (stack.getMethod() != null) {
- sb.append(" at " + stack.getMethod() + "\n");
- stack = stack.getCause();
+ } else {
+ while (stack.getMethod() != null) {
+ sb.append(" at " + stack.getMethod() + "\n");
+ stack = stack.getCause();
+ }
}
sb.append('\n');
}
diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java
index 6b3de2d65..a00ec8f88 100644
--- a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java
+++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java
@@ -414,7 +414,7 @@ class DependencyGraphBuilder {
public void invoke(VariableReader receiver, VariableReader instance, MethodReference method,
List extends VariableReader> arguments, InvocationType type) {
if (instance == null) {
- invokeSpecial(receiver, instance, method, arguments);
+ invokeSpecial(receiver, null, method, arguments);
} else {
switch (type) {
case SPECIAL:
diff --git a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
index 7a9a23ffa..a23806533 100644
--- a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
+++ b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java
@@ -55,7 +55,7 @@ public class Decompiler {
return this.graph.size();
}
- class Block {
+ static class Block {
public final IdentifiedStatement statement;
public final List body;
public final int end;
diff --git a/teavm-core/src/main/java/org/teavm/javascript/ExprOptimizer.java b/teavm-core/src/main/java/org/teavm/javascript/ExprOptimizer.java
index 2674985de..e1c6300d5 100644
--- a/teavm-core/src/main/java/org/teavm/javascript/ExprOptimizer.java
+++ b/teavm-core/src/main/java/org/teavm/javascript/ExprOptimizer.java
@@ -21,7 +21,10 @@ import org.teavm.javascript.ast.*;
*
* @author Alexey Andreev
*/
-class ExprOptimizer {
+final class ExprOptimizer {
+ private ExprOptimizer() {
+ }
+
public static Expr invert(Expr expr) {
if (expr instanceof UnaryExpr) {
UnaryExpr unary = (UnaryExpr)expr;
diff --git a/teavm-core/src/main/java/org/teavm/javascript/PhiEliminator.java b/teavm-core/src/main/java/org/teavm/javascript/PhiEliminator.java
deleted file mode 100644
index f06399a0e..000000000
--- a/teavm-core/src/main/java/org/teavm/javascript/PhiEliminator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2014 Alexey Andreev.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.teavm.javascript;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.teavm.model.*;
-import org.teavm.model.util.InstructionTransitionExtractor;
-import org.teavm.model.util.UsageExtractor;
-
-/**
- *
- * @author Alexey Andreev
- */
-class PhiEliminator {
- public static void eliminatePhis(Program program) {
- // Count how many times each variable is used
- int[] variableUsageCount = new int[program.variableCount()];
- int[] definitionRenamings = new int[program.variableCount()];
- for (int i = 0; i < definitionRenamings.length; ++i) {
- definitionRenamings[i] = i;
- }
- UsageExtractor usageExtractor = new UsageExtractor();
- InstructionTransitionExtractor transitionExtractor = new InstructionTransitionExtractor();
- int blockCount = program.basicBlockCount();
- for (int i = 0; i < blockCount; ++i) {
- BasicBlock block = program.basicBlockAt(i);
- for (Instruction insn : block.getInstructions()) {
- insn.acceptVisitor(usageExtractor);
- for (Variable var : usageExtractor.getUsedVariables()) {
- variableUsageCount[var.getIndex()]++;
- }
- }
- for (Phi phi : block.getPhis()) {
- for (Incoming incoming : phi.getIncomings()) {
- variableUsageCount[incoming.getValue().getIndex()]++;
- }
- }
- }
-
- // Places assignments at the end of each block
- for (int i = 0; i < blockCount; ++i) {
- BasicBlock block = program.basicBlockAt(i);
- block.getLastInstruction().acceptVisitor(transitionExtractor);
- BasicBlock[] targets = transitionExtractor.getTargets();
- if (targets.length == 1) {
-
- } else {
- for (BasicBlock targetBlock : transitionExtractor.getTargets()) {
- List incomings = new ArrayList<>();
- for (Incoming incoming : getIncomings(block, targetBlock)) {
- if (variableUsageCount[incoming.getSource().getIndex()] <= 1) {
- definitionRenamings[incoming.getValue().getIndex()] =
- incoming.getPhi().getReceiver().getIndex();
- } else {
- incomings.add(incoming);
- }
- }
- }
- }
- }
-
- // Removes phi functions
- for (int i = 0; i < blockCount; ++i) {
- BasicBlock block = program.basicBlockAt(i);
- block.getPhis().clear();
- }
- }
-
- private static List getIncomings(BasicBlock block, BasicBlock targetBlock) {
- List incomings = new ArrayList<>();
- for (Phi phi : targetBlock.getPhis()) {
- for (Incoming incoming : phi.getIncomings()) {
- if (incoming.getSource() == block) {
- incomings.add(incoming);
- }
- }
- }
- return incomings;
- }
-}
diff --git a/teavm-core/src/main/java/org/teavm/javascript/StatementGenerator.java b/teavm-core/src/main/java/org/teavm/javascript/StatementGenerator.java
index f7f124cdd..df1362583 100644
--- a/teavm-core/src/main/java/org/teavm/javascript/StatementGenerator.java
+++ b/teavm-core/src/main/java/org/teavm/javascript/StatementGenerator.java
@@ -396,7 +396,7 @@ class StatementGenerator implements InstructionVisitor {
Map> switchMap = new HashMap<>();
for (int i = 0; i < insn.getEntries().size(); ++i) {
SwitchTableEntry entry = insn.getEntries().get(i);
- List conditions = switchMap.get(entry.getTarget());
+ List conditions = switchMap.get(entry.getTarget().getIndex());
if (conditions == null) {
conditions = new ArrayList<>();
switchMap.put(entry.getTarget().getIndex(), conditions);
diff --git a/teavm-core/src/main/java/org/teavm/model/util/DefinitionExtractor.java b/teavm-core/src/main/java/org/teavm/model/util/DefinitionExtractor.java
index 7d409f059..5d0d42f43 100644
--- a/teavm-core/src/main/java/org/teavm/model/util/DefinitionExtractor.java
+++ b/teavm-core/src/main/java/org/teavm/model/util/DefinitionExtractor.java
@@ -41,7 +41,7 @@ public class DefinitionExtractor implements InstructionVisitor {
@Override
public void visit(NullConstantInstruction insn) {
- definedVariables = new Variable[] { insn.getReceiver() };
+ definedVariables = new Variable[] {insn.getReceiver()};
}
@Override
diff --git a/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java b/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java
index 4110c2f60..c49f852de 100644
--- a/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java
+++ b/teavm-core/src/main/java/org/teavm/model/util/ProgramUtils.java
@@ -24,7 +24,10 @@ import org.teavm.model.instructions.*;
*
* @author Alexey Andreev
*/
-public class ProgramUtils {
+public final class ProgramUtils {
+ private ProgramUtils() {
+ }
+
public static Graph buildControlFlowGraphWithoutTryCatch(Program program) {
GraphBuilder graphBuilder = new GraphBuilder(program.basicBlockCount());
InstructionTransitionExtractor transitionExtractor = new InstructionTransitionExtractor();
diff --git a/teavm-core/src/main/java/org/teavm/model/util/RegisterAllocator.java b/teavm-core/src/main/java/org/teavm/model/util/RegisterAllocator.java
index 709affd0a..fc57a134b 100644
--- a/teavm-core/src/main/java/org/teavm/model/util/RegisterAllocator.java
+++ b/teavm-core/src/main/java/org/teavm/model/util/RegisterAllocator.java
@@ -161,9 +161,8 @@ public class RegisterAllocator {
if (!interfere) {
int newClass = congruenceClasses.union(copyClass, origClass);
block.getInstructions().set(j, new EmptyInstruction());
- MutableGraphNode newNode = interferenceGraph.get(origClass);
if (newClass == interferenceGraph.size()) {
- newNode = new MutableGraphNode(interferenceGraph.size());
+ MutableGraphNode newNode = new MutableGraphNode(interferenceGraph.size());
interferenceGraph.add(newNode);
}
for (MutableGraphEdge edge : interferenceGraph.get(origClass).getEdges()
diff --git a/teavm-core/src/main/java/org/teavm/optimization/CommonSubexpressionElimination.java b/teavm-core/src/main/java/org/teavm/optimization/CommonSubexpressionElimination.java
index 22535d1bd..eb95f54da 100644
--- a/teavm-core/src/main/java/org/teavm/optimization/CommonSubexpressionElimination.java
+++ b/teavm-core/src/main/java/org/teavm/optimization/CommonSubexpressionElimination.java
@@ -117,7 +117,7 @@ public class CommonSubexpressionElimination implements MethodOptimization {
}
program.pack();
- program = null;
+ this.program = null;
}
private List> findOutgoings(Program program) {
diff --git a/teavm-core/src/main/java/org/teavm/optimization/UnusedVariableElimination.java b/teavm-core/src/main/java/org/teavm/optimization/UnusedVariableElimination.java
index 657de1456..64f1f4cc5 100644
--- a/teavm-core/src/main/java/org/teavm/optimization/UnusedVariableElimination.java
+++ b/teavm-core/src/main/java/org/teavm/optimization/UnusedVariableElimination.java
@@ -73,7 +73,7 @@ public class UnusedVariableElimination implements MethodOptimization {
}
}
- private class InstructionOptimizer implements InstructionVisitor {
+ private static class InstructionOptimizer implements InstructionVisitor {
private boolean[] used;
boolean eliminate;
diff --git a/teavm-core/src/main/java/org/teavm/optimization/VariableEscapeAnalyzer.java b/teavm-core/src/main/java/org/teavm/optimization/VariableEscapeAnalyzer.java
index 5e9b1b0a0..ca185b27b 100644
--- a/teavm-core/src/main/java/org/teavm/optimization/VariableEscapeAnalyzer.java
+++ b/teavm-core/src/main/java/org/teavm/optimization/VariableEscapeAnalyzer.java
@@ -25,7 +25,10 @@ import org.teavm.model.instructions.*;
*
* @author Alexey Andreev
*/
-public class VariableEscapeAnalyzer {
+public final class VariableEscapeAnalyzer {
+ private VariableEscapeAnalyzer() {
+ }
+
public static boolean[] findEscapingVariables(Program program) {
boolean[] escaping = new boolean[program.variableCount()];
InstructionAnalyzer analyzer = new InstructionAnalyzer(escaping);
diff --git a/teavm-core/src/main/java/org/teavm/optimization/VariableUsageGraphBuilder.java b/teavm-core/src/main/java/org/teavm/optimization/VariableUsageGraphBuilder.java
index 5047b2951..b16104866 100644
--- a/teavm-core/src/main/java/org/teavm/optimization/VariableUsageGraphBuilder.java
+++ b/teavm-core/src/main/java/org/teavm/optimization/VariableUsageGraphBuilder.java
@@ -24,7 +24,10 @@ import org.teavm.model.instructions.*;
*
* @author Alexey Andreev
*/
-public class VariableUsageGraphBuilder {
+public final class VariableUsageGraphBuilder {
+ private VariableUsageGraphBuilder() {
+ }
+
public static Graph build(Program program) {
GraphBuilder builder = new GraphBuilder(program.variableCount());
InstructionAnalyzer analyzer = new InstructionAnalyzer(builder);
diff --git a/teavm-core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java b/teavm-core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java
index 8cac260bf..3adb19233 100644
--- a/teavm-core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java
+++ b/teavm-core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java
@@ -28,8 +28,8 @@ import org.teavm.model.ClassHolder;
* @author Alexey Andreev
*/
public class ClasspathResourceMapper implements Mapper {
- private static String PACKAGE_PREFIX = "packagePrefix.";
- private static String CLASS_PREFIX = "classPrefix.";
+ private static final String PACKAGE_PREFIX = "packagePrefix.";
+ private static final String CLASS_PREFIX = "classPrefix.";
private Mapper innerMapper;
private List transformations = new ArrayList<>();
private ClassRefsRenamer renamer;
diff --git a/teavm-core/src/main/java/org/teavm/parsing/Parser.java b/teavm-core/src/main/java/org/teavm/parsing/Parser.java
index e77d25a0e..e12c76590 100644
--- a/teavm-core/src/main/java/org/teavm/parsing/Parser.java
+++ b/teavm-core/src/main/java/org/teavm/parsing/Parser.java
@@ -27,7 +27,10 @@ import org.teavm.optimization.UnreachableBasicBlockEliminator;
*
* @author Alexey Andreev
*/
-public class Parser {
+public final class Parser {
+ private Parser() {
+ }
+
public static MethodHolder parseMethod(MethodNode node, String className) {
ValueType[] signature = MethodDescriptor.parseSignature(node.desc);
MethodHolder method = new MethodHolder(node.name, signature);
diff --git a/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java b/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java
index 3b3469423..ac8cb63ba 100644
--- a/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java
+++ b/teavm-core/src/main/java/org/teavm/parsing/ProgramParser.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2011 Alexey Andreev.
+ * Copyright 2011 Alexey Andreev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/teavm-core/src/main/java/org/teavm/vm/TeaVM.java b/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
index f10824d88..12ce43a40 100644
--- a/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
+++ b/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
@@ -199,7 +199,7 @@ public class TeaVM implements TeaVMHost {
if (bytecodeLogging) {
try {
logBytecode(new PrintWriter(new OutputStreamWriter(logStream, "UTF-8")), classSet);
- } catch (IOException e) {
+ } catch (UnsupportedEncodingException e) {
// Just don't do anything
}
}
diff --git a/teavm-html4j/src/test/java/org/teavm/html4j/test/A.java b/teavm-html4j/src/test/java/org/teavm/html4j/test/A.java
index df6aaf128..37addfdd8 100644
--- a/teavm-html4j/src/test/java/org/teavm/html4j/test/A.java
+++ b/teavm-html4j/src/test/java/org/teavm/html4j/test/A.java
@@ -19,6 +19,6 @@ package org.teavm.html4j.test;
*
* @author Alexey Andreev
*/
-interface A {
+public interface A {
int foo();
}