From 4795fab710b0919dba3424cc4cdceab4e9feaf66 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Tue, 22 Aug 2017 10:02:13 +0000 Subject: [PATCH] Fix JDK9 compilation issue, use parser.ast.Module instead of Module In Java 9, there is a new system class java.lang.Module that is implicitly imported everywhere and which clashes with the parser.ast.Module class, resulting in compilation errors, as javac is not able to disambiguate between the two automatically. We are therefore more specific when referencing the PRISM parser's 'Module' class, by using the full 'parser.ast.Module' name. --- prism/src/parser/PrismParser.java | 8 ++++---- prism/src/parser/PrismParser.jj | 8 ++++---- prism/src/parser/VarList.java | 2 +- prism/src/parser/visitor/ASTTraverse.java | 6 +++--- prism/src/parser/visitor/ASTTraverseModify.java | 8 ++++---- prism/src/parser/visitor/ASTVisitor.java | 2 +- .../parser/visitor/ModulesFileSemanticCheck.java | 10 +++++----- prism/src/parser/visitor/Rename.java | 2 +- prism/src/prism/ExplicitModel2MTBDD.java | 2 +- prism/src/prism/Modules2MTBDD.java | 4 ++-- prism/src/pta/DigitalClocks.java | 4 ++-- prism/src/pta/Modules2PTA.java | 16 ++++++++-------- .../simulator/GUISimulatorPathTableModel.java | 8 ++++---- .../userinterface/simulator/SimulationView.java | 4 ++-- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/prism/src/parser/PrismParser.java b/prism/src/parser/PrismParser.java index 6f78f5a89e..51c18ffe55 100644 --- a/prism/src/parser/PrismParser.java +++ b/prism/src/parser/PrismParser.java @@ -375,7 +375,7 @@ static class ExpressionPair { public Expression expr1 = null; public Expression int typeCount = 0; Token typeDupe = null; Declaration global; - Module m = null; + parser.ast.Module m = null; RenamedModule rm = null; RewardStruct rs = null; Expression init = null; @@ -1027,15 +1027,15 @@ static class ExpressionPair { public Expression expr1 = null; public Expression // Module static final public -Module Module() throws ParseException {ExpressionIdent name = null; +parser.ast.Module Module() throws ParseException {ExpressionIdent name = null; Declaration var = null; Expression invar; Command comm = null; - Module module = null; + parser.ast.Module module = null; Token begin = null; begin = jj_consume_token(MODULE); name = IdentifierExpression(); -module = new Module(name.getName()); +module = new parser.ast.Module(name.getName()); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { diff --git a/prism/src/parser/PrismParser.jj b/prism/src/parser/PrismParser.jj index 21f046cfc0..e3b5c87e7e 100644 --- a/prism/src/parser/PrismParser.jj +++ b/prism/src/parser/PrismParser.jj @@ -535,7 +535,7 @@ ModulesFile ModulesFile() throws PrismLangException : int typeCount = 0; Token typeDupe = null; Declaration global; - Module m = null; + parser.ast.Module m = null; RenamedModule rm = null; RewardStruct rs = null; Expression init = null; @@ -791,17 +791,17 @@ DeclarationType DeclarationVarType() : // Module -Module Module() : +parser.ast.Module Module() : { ExpressionIdent name = null; Declaration var = null; Expression invar; Command comm = null; - Module module = null; + parser.ast.Module module = null; Token begin = null; } { - begin = name = IdentifierExpression() { module = new Module(name.getName()); } + begin = name = IdentifierExpression() { module = new parser.ast.Module(name.getName()); } ( var = Declaration() { module.addDeclaration(var); } )* ( invar = Expression(false, false) { module.setInvariant(invar); } )? ( comm = Command() { module.addCommand(comm); } )* diff --git a/prism/src/parser/VarList.java b/prism/src/parser/VarList.java index aae59f2e67..1321a074af 100644 --- a/prism/src/parser/VarList.java +++ b/prism/src/parser/VarList.java @@ -66,7 +66,7 @@ public VarList(ModulesFile modulesFile) throws PrismLangException this(); int i, j, n, n2; - Module module; + parser.ast.Module module; Declaration decl; // First add all globals to the list diff --git a/prism/src/parser/visitor/ASTTraverse.java b/prism/src/parser/visitor/ASTTraverse.java index f006a450ed..d8ee27aaf1 100644 --- a/prism/src/parser/visitor/ASTTraverse.java +++ b/prism/src/parser/visitor/ASTTraverse.java @@ -196,8 +196,8 @@ public Object visit(DeclarationIntUnbounded e) throws PrismLangException } public void visitPost(DeclarationIntUnbounded e) throws PrismLangException { defaultVisitPost(e); } // ----------------------------------------------------------------------------------- - public void visitPre(Module e) throws PrismLangException { defaultVisitPre(e); } - public Object visit(Module e) throws PrismLangException + public void visitPre(parser.ast.Module e) throws PrismLangException { defaultVisitPre(e); } + public Object visit(parser.ast.Module e) throws PrismLangException { // Note: a few classes override this method (e.g. SemanticCheck) // so take care to update those versions if changing this method @@ -216,7 +216,7 @@ public Object visit(Module e) throws PrismLangException visitPost(e); return null; } - public void visitPost(Module e) throws PrismLangException { defaultVisitPost(e); } + public void visitPost(parser.ast.Module e) throws PrismLangException { defaultVisitPost(e); } // ----------------------------------------------------------------------------------- public void visitPre(Command e) throws PrismLangException { defaultVisitPre(e); } public Object visit(Command e) throws PrismLangException diff --git a/prism/src/parser/visitor/ASTTraverseModify.java b/prism/src/parser/visitor/ASTTraverseModify.java index 4701c71634..96670422f1 100644 --- a/prism/src/parser/visitor/ASTTraverseModify.java +++ b/prism/src/parser/visitor/ASTTraverseModify.java @@ -55,7 +55,7 @@ public Object visit(ModulesFile e) throws PrismLangException } n = e.getNumModules(); for (i = 0; i < n; i++) { - if (e.getModule(i) != null) e.setModule(i, (Module)(e.getModule(i).accept(this))); + if (e.getModule(i) != null) e.setModule(i, (parser.ast.Module)(e.getModule(i).accept(this))); } n = e.getNumSystemDefns(); for (i = 0; i < n; i++) { @@ -211,8 +211,8 @@ public Object visit(DeclarationIntUnbounded e) throws PrismLangException } public void visitPost(DeclarationIntUnbounded e) throws PrismLangException { defaultVisitPost(e); } // ----------------------------------------------------------------------------------- - public void visitPre(Module e) throws PrismLangException { defaultVisitPre(e); } - public Object visit(Module e) throws PrismLangException + public void visitPre(parser.ast.Module e) throws PrismLangException { defaultVisitPre(e); } + public Object visit(parser.ast.Module e) throws PrismLangException { visitPre(e); int i, n; @@ -229,7 +229,7 @@ public Object visit(Module e) throws PrismLangException visitPost(e); return e; } - public void visitPost(Module e) throws PrismLangException { defaultVisitPost(e); } + public void visitPost(parser.ast.Module e) throws PrismLangException { defaultVisitPost(e); } // ----------------------------------------------------------------------------------- public void visitPre(Command e) throws PrismLangException { defaultVisitPre(e); } public Object visit(Command e) throws PrismLangException diff --git a/prism/src/parser/visitor/ASTVisitor.java b/prism/src/parser/visitor/ASTVisitor.java index 2ceae67d4e..a5702ef3dc 100644 --- a/prism/src/parser/visitor/ASTVisitor.java +++ b/prism/src/parser/visitor/ASTVisitor.java @@ -44,7 +44,7 @@ public interface ASTVisitor public Object visit(DeclarationArray e) throws PrismLangException; public Object visit(DeclarationClock e) throws PrismLangException; public Object visit(DeclarationIntUnbounded e) throws PrismLangException; - public Object visit(Module e) throws PrismLangException; + public Object visit(parser.ast.Module e) throws PrismLangException; public Object visit(Command e) throws PrismLangException; public Object visit(Updates e) throws PrismLangException; public Object visit(Update e) throws PrismLangException; diff --git a/prism/src/parser/visitor/ModulesFileSemanticCheck.java b/prism/src/parser/visitor/ModulesFileSemanticCheck.java index cb3d259d65..678cea87a4 100644 --- a/prism/src/parser/visitor/ModulesFileSemanticCheck.java +++ b/prism/src/parser/visitor/ModulesFileSemanticCheck.java @@ -54,7 +54,7 @@ public ModulesFileSemanticCheck(ModulesFile modulesFile) public void visitPost(ModulesFile e) throws PrismLangException { int i, j, n, n2; - Module m; + parser.ast.Module m; Vector v; // Check for use of init...endinit _and_ var initial values @@ -174,13 +174,13 @@ public void visitPost(DeclarationClock e) throws PrismLangException } } - public void visitPre(Module e) throws PrismLangException + public void visitPre(parser.ast.Module e) throws PrismLangException { // Register the fact we are entering a module //inModule = e; } - public Object visit(Module e) throws PrismLangException + public Object visit(parser.ast.Module e) throws PrismLangException { // Override this so we can keep track of when we are in an invariant visitPre(e); @@ -201,7 +201,7 @@ public Object visit(Module e) throws PrismLangException return null; } - public void visitPost(Module e) throws PrismLangException + public void visitPost(parser.ast.Module e) throws PrismLangException { // Register the fact we are leaving a module //inModule = null; @@ -230,7 +230,7 @@ public void visitPost(Update e) throws PrismLangException int i, n; String s, var; Command c; - Module m; + parser.ast.Module m; boolean isLocal, isGlobal; // Register the fact we are leaving an update diff --git a/prism/src/parser/visitor/Rename.java b/prism/src/parser/visitor/Rename.java index c7c53fe820..6ca981a33d 100644 --- a/prism/src/parser/visitor/Rename.java +++ b/prism/src/parser/visitor/Rename.java @@ -67,7 +67,7 @@ public void visitPost(Declaration e) throws PrismLangException } } - public void visitPost(Module e) throws PrismLangException + public void visitPost(parser.ast.Module e) throws PrismLangException { // New name for module is specied in RenamedModule e.setName(rm.getName()); diff --git a/prism/src/prism/ExplicitModel2MTBDD.java b/prism/src/prism/ExplicitModel2MTBDD.java index cde9f70b20..0138987869 100644 --- a/prism/src/prism/ExplicitModel2MTBDD.java +++ b/prism/src/prism/ExplicitModel2MTBDD.java @@ -128,7 +128,7 @@ public Model buildModel(explicit.Model modelExpl, List statesList, Module this.modulesFile = modulesFile; } else { this.modulesFile = modulesFile = new ModulesFile(); - Module m = new Module("M"); + parser.ast.Module m = new parser.ast.Module("M"); Declaration d = new Declaration("x", new DeclarationInt(Expression.Int(0), Expression.Int(numStates - 1))); d.setStart(Expression.Int(0)); m.addDeclaration(d); diff --git a/prism/src/prism/Modules2MTBDD.java b/prism/src/prism/Modules2MTBDD.java index 6919947c89..8bba2dee40 100644 --- a/prism/src/prism/Modules2MTBDD.java +++ b/prism/src/prism/Modules2MTBDD.java @@ -902,7 +902,7 @@ else if (sys instanceof SystemReference) { private SystemDDs translateSystemModule(SystemModule sys, int[] synchMin) throws PrismException { SystemDDs sysDDs; - Module module; + parser.ast.Module module; String synch; int i, m; @@ -1366,7 +1366,7 @@ else if (compDDs2.max > compDDs1.max) { // translate a single module to a dd // for a given synchronizing action ("" = none) - private ComponentDDs translateModule(int m, Module module, String synch, int synchMin) throws PrismException + private ComponentDDs translateModule(int m, parser.ast.Module module, String synch, int synchMin) throws PrismException { ComponentDDs compDDs; JDDNode guardDDs[], upDDs[], tmp; diff --git a/prism/src/pta/DigitalClocks.java b/prism/src/pta/DigitalClocks.java index 492ad4af5b..6eff8fe011 100644 --- a/prism/src/pta/DigitalClocks.java +++ b/prism/src/pta/DigitalClocks.java @@ -184,7 +184,7 @@ public Object visit(Declaration e) throws PrismLangException allInVariants = null; mf = (ModulesFile) mf.accept(new ASTTraverseModify() { - public Object visit(Module e) throws PrismLangException + public Object visit(parser.ast.Module e) throws PrismLangException { Command timeCommand; Updates ups; @@ -505,7 +505,7 @@ public void visitPost(ModulesFile e) throws PrismLangException scaleFactor = computeGCD(allClockVals); } - public void visitPre(Module e) throws PrismLangException + public void visitPre(parser.ast.Module e) throws PrismLangException { // Create new array to store clocks for this module currentClockList = new ArrayList(); diff --git a/prism/src/pta/Modules2PTA.java b/prism/src/pta/Modules2PTA.java index bce33a8ea3..1a5df2a721 100644 --- a/prism/src/pta/Modules2PTA.java +++ b/prism/src/pta/Modules2PTA.java @@ -68,7 +68,7 @@ public Modules2PTA(PrismComponent parent, ModulesFile modulesFile) throws PrismE public PTA translate() throws PrismLangException { int i, numModules; - Module module, moduleNew; + parser.ast.Module module, moduleNew; ArrayList nonClocks; ArrayList allNonClocks = new ArrayList(); ArrayList> pcStates; @@ -85,15 +85,15 @@ public PTA translate() throws PrismLangException // Check for inter-module variable references modulesFile.accept(new ASTTraverse() { - private Module inModule = null; + private parser.ast.Module inModule = null; - public void visitPre(Module e) throws PrismLangException + public void visitPre(parser.ast.Module e) throws PrismLangException { // Register the fact we are entering a module inModule = e; } - public void visitPost(Module e) throws PrismLangException + public void visitPost(parser.ast.Module e) throws PrismLangException { // Register the fact we are leaving a module inModule = null; @@ -165,7 +165,7 @@ public void visitPost(ExpressionVar e) throws PrismLangException * Translate a single module. * (Which has been transformed using convertModuleToPCForm) */ - private PTA translateModule(Module module, ArrayList pcStates) throws PrismLangException + private PTA translateModule(parser.ast.Module module, ArrayList pcStates) throws PrismLangException { // Clocks and PC variable stuff ArrayList clocks; @@ -486,7 +486,7 @@ else if (expr2.getType() instanceof TypeClock) { * @param pcVars: The variables that should be converted to a PC. * @param pcStates: An empty ArrayList into which PC value states will be stored. */ - private Module convertModuleToPCForm(Module module, List pcVars, ArrayList pcStates) throws PrismLangException + private parser.ast.Module convertModuleToPCForm(parser.ast.Module module, List pcVars, ArrayList pcStates) throws PrismLangException { // Info about variables in model to be used as program counter int pcNumVars; @@ -494,7 +494,7 @@ private Module convertModuleToPCForm(Module module, List pcVars, ArrayLi // info about new program counter var String pc; // Components of old and new module - Module moduleNew; + parser.ast.Module moduleNew; Declaration decl, declNew; Command command, commandNew; Expression guard, guardNew; @@ -545,7 +545,7 @@ private Module convertModuleToPCForm(Module module, List pcVars, ArrayLi } // Create a new module - moduleNew = new Module(module.getName()); + moduleNew = new parser.ast.Module(module.getName()); // Preserve alphabet of old module (might change if some commands are not enabled) moduleNew.setAlphabet(module.getAllSynchs()); diff --git a/prism/src/userinterface/simulator/GUISimulatorPathTableModel.java b/prism/src/userinterface/simulator/GUISimulatorPathTableModel.java index 1e0bc4b2af..5bb9eb5376 100644 --- a/prism/src/userinterface/simulator/GUISimulatorPathTableModel.java +++ b/prism/src/userinterface/simulator/GUISimulatorPathTableModel.java @@ -112,7 +112,7 @@ public int getGroupCount() } for (int m = 0; m < parsedModel.getNumModules(); m++) { - Module module = parsedModel.getModule(m); + parser.ast.Module module = parsedModel.getModule(m); for (int v = 0; v < module.getNumDeclarations(); v++) { if (varNames.contains(module.getDeclaration(v).getName())) { groupCount++; @@ -182,7 +182,7 @@ public String getGroupName(int groupIndex) } for (int m = 0; m < parsedModel.getNumModules(); m++) { - Module module = parsedModel.getModule(m); + parser.ast.Module module = parsedModel.getModule(m); for (int v = 0; v < module.getNumDeclarations(); v++) { if (varNames.contains(module.getDeclaration(v).getName())) { if (groupCount == groupIndex) { @@ -248,7 +248,7 @@ public String getGroupToolTip(int groupIndex) } for (int m = 0; m < parsedModel.getNumModules(); m++) { - Module module = parsedModel.getModule(m); + parser.ast.Module module = parsedModel.getModule(m); for (int v = 0; v < module.getNumDeclarations(); v++) { if (varNames.contains(module.getDeclaration(v).getName())) { if (groupCount == groupIndex) { @@ -336,7 +336,7 @@ public int getLastColumnOfGroup(int groupIndex) } for (int m = 0; m < parsedModel.getNumModules(); m++) { - Module module = parsedModel.getModule(m); + parser.ast.Module module = parsedModel.getModule(m); boolean atLeastOne = false; for (int v = 0; v < module.getNumDeclarations(); v++) { diff --git a/prism/src/userinterface/simulator/SimulationView.java b/prism/src/userinterface/simulator/SimulationView.java index 28cdabb7e1..c9ba1a796a 100644 --- a/prism/src/userinterface/simulator/SimulationView.java +++ b/prism/src/userinterface/simulator/SimulationView.java @@ -217,7 +217,7 @@ public void refreshToDefaultView(boolean pathActive, ModulesFile parsedModel) canUseCurrentView = false; } for (int m = 0; m < parsedModel.getNumModules(); m++) { - Module module = parsedModel.getModule(m); + parser.ast.Module module = parsedModel.getModule(m); for (int v = 0; v < module.getNumDeclarations(); v++) { if (!allVarNames.remove(module.getDeclaration(v).getName())) canUseCurrentView = false; @@ -275,7 +275,7 @@ public void refreshToDefaultView(boolean pathActive, ModulesFile parsedModel) i++; } for (int m = 0; m < parsedModel.getNumModules(); m++) { - Module module = parsedModel.getModule(m); + parser.ast.Module module = parsedModel.getModule(m); for (int v = 0; v < module.getNumDeclarations(); v++) { visibleVariables.add(new Variable(i, module.getDeclaration(v).getName(), module.getDeclaration(v).getType())); i++;