From 1c9e52b5d639a9394ef3227d94fb6ea4073db50e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 4 Apr 2012 09:50:51 -0500 Subject: [PATCH 1/2] Use CopyOnWriteArrayList instead of Collections.synchronizedList --- tool/src/org/antlr/v4/Tool.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/src/org/antlr/v4/Tool.java b/tool/src/org/antlr/v4/Tool.java index dad9c8bab..741107254 100644 --- a/tool/src/org/antlr/v4/Tool.java +++ b/tool/src/org/antlr/v4/Tool.java @@ -74,6 +74,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class Tool { public String VERSION = "4.0-"+new Date(); @@ -166,8 +167,7 @@ public class Tool { public ErrorManager errMgr = new ErrorManager(this); public LogManager logMgr = new LogManager(); - List listeners = - Collections.synchronizedList(new ArrayList()); + List listeners = new CopyOnWriteArrayList(); /** Track separately so if someone adds a listener, it's the only one * instead of it and the default stderr listener. From 2c1f673f621dba72df40ceb161301768dfdbb12a Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 4 Apr 2012 09:51:23 -0500 Subject: [PATCH 2/2] Mark ErrorType fields final --- tool/src/org/antlr/v4/tool/ErrorType.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tool/src/org/antlr/v4/tool/ErrorType.java b/tool/src/org/antlr/v4/tool/ErrorType.java index 3d406d9dd..0d49e560c 100644 --- a/tool/src/org/antlr/v4/tool/ErrorType.java +++ b/tool/src/org/antlr/v4/tool/ErrorType.java @@ -185,16 +185,18 @@ public enum ErrorType { ; - public String msg; - public int code; // unique, deterministic unchanging error code once we release - public ErrorSeverity severity; - public Boolean abortsAnalysis; - public Boolean abortsCodegen; + public final String msg; + public final int code; // unique, deterministic unchanging error code once we release + public final ErrorSeverity severity; + public final Boolean abortsAnalysis; + public final Boolean abortsCodegen; ErrorType(int code, String msg, ErrorSeverity severity) { this.code = code; this.msg = msg; this.severity = severity; + this.abortsAnalysis = false; + this.abortsCodegen = false; } // ErrorType(String msg, ErrorSeverity severity, boolean abortsAnalysis) {