You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/08/25 18:30:53 UTC

svn commit: r1377319 - in /tomcat/trunk/java/org/apache/jasper: JspC.java JspCompilationContext.java

Author: markt
Date: Sat Aug 25 16:30:53 2012
New Revision: 1377319

URL: http://svn.apache.org/viewvc?rev=1377319&view=rev
Log:
A little Java 7 / UCDetector clean-up

Modified:
    tomcat/trunk/java/org/apache/jasper/JspC.java
    tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java

Modified: tomcat/trunk/java/org/apache/jasper/JspC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspC.java?rev=1377319&r1=1377318&r2=1377319&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspC.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspC.java Sat Aug 25 16:30:53 2012
@@ -132,7 +132,7 @@ public class JspC extends Task implement
     protected static final int ALL_WEBXML = 20;
     protected static final int DEFAULT_DIE_LEVEL = 1;
     protected static final int NO_DIE_LEVEL = 0;
-    protected static final Set<String> insertBefore = new HashSet<String>();
+    protected static final Set<String> insertBefore = new HashSet<>();
 
     static {
         insertBefore.add("</web-app>");
@@ -171,8 +171,7 @@ public class JspC extends Task implement
     protected boolean smapSuppressed = true;
     protected boolean smapDumped = false;
     protected boolean caching = true;
-    protected final Map<String, TagLibraryInfo> cache =
-        new HashMap<String, TagLibraryInfo>();
+    protected final Map<String, TagLibraryInfo> cache = new HashMap<>();
 
     protected String compiler = null;
 
@@ -196,7 +195,7 @@ public class JspC extends Task implement
     /**
      * The pages.
      */
-    protected final List<String> pages = new Vector<String>();
+    protected final List<String> pages = new Vector<>();
 
     /**
      * Needs better documentation, this data member does.
@@ -775,7 +774,7 @@ public class JspC extends Task implement
     protected void addExtension(final String extension) {
         if(extension != null) {
             if(extensions == null) {
-                extensions = new Vector<String>();
+                extensions = new Vector<>();
             }
 
             extensions.add(extension);
@@ -1222,7 +1221,7 @@ public class JspC extends Task implement
      * jsps are specified.
      */
     public void scanFiles( File base ) throws JasperException {
-        Stack<String> dirs = new Stack<String>();
+        Stack<String> dirs = new Stack<>();
         dirs.push(base.toString());
 
         // Make sure default extensions are always included
@@ -1450,7 +1449,7 @@ public class JspC extends Task implement
         }
 
         // Turn the classPath into URLs
-        ArrayList<URL> urls = new ArrayList<URL>();
+        ArrayList<URL> urls = new ArrayList<>();
         StringTokenizer tokenizer = new StringTokenizer(classPath,
                                                         File.pathSeparator);
         while (tokenizer.hasMoreTokens()) {

Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=1377319&r1=1377318&r2=1377319&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java Sat Aug 25 16:30:53 2012
@@ -62,27 +62,27 @@ public class JspCompilationContext {
 
     private final Log log = LogFactory.getLog(JspCompilationContext.class); // must not be static
 
-    protected Map<String, JarResource> tagFileJarUrls;
+    protected final Map<String, JarResource> tagFileJarUrls;
 
     protected String className;
-    protected String jspUri;
+    protected final String jspUri;
     protected String basePackageName;
     protected String derivedPackageName;
     protected String servletJavaFileName;
     protected String javaPath;
     protected String classFileName;
     protected ServletWriter writer;
-    protected Options options;
-    protected JspServletWrapper jsw;
+    protected final Options options;
+    protected final JspServletWrapper jsw;
     protected Compiler jspCompiler;
     protected String classPath;
 
-    protected String baseURI;
+    protected final String baseURI;
     protected String outputDir;
-    protected ServletContext context;
+    protected final ServletContext context;
     protected ClassLoader loader;
 
-    protected JspRuntimeContext rctxt;
+    protected final JspRuntimeContext rctxt;
 
     protected volatile int removed = 0;
 
@@ -90,10 +90,10 @@ public class JspCompilationContext {
     protected URL baseUrl;
     protected Class<?> servletClass;
 
-    protected boolean isTagFile;
+    protected final boolean isTagFile;
     protected boolean protoTypeMode;
     protected TagInfo tagInfo;
-    protected JarResource tagJarResource;
+    protected final JarResource tagJarResource;
 
     // jspURI _must_ be relative to the context
     public JspCompilationContext(String jspUri,
@@ -102,12 +102,35 @@ public class JspCompilationContext {
                                  JspServletWrapper jsw,
                                  JspRuntimeContext rctxt) {
 
+        this(jspUri, null, options, context, jsw, rctxt, null, false);
+    }
+
+    public JspCompilationContext(String tagfile,
+                                 TagInfo tagInfo,
+                                 Options options,
+                                 ServletContext context,
+                                 JspServletWrapper jsw,
+                                 JspRuntimeContext rctxt,
+                                 JarResource tagJarResource) {
+        this(tagfile, tagInfo, options, context, jsw, rctxt, tagJarResource,
+                true);
+    }
+
+    private JspCompilationContext(String jspUri,
+            TagInfo tagInfo,
+            Options options,
+            ServletContext context,
+            JspServletWrapper jsw,
+            JspRuntimeContext rctxt,
+            JarResource tagJarResource,
+            boolean isTagFile) {
+
         this.jspUri = canonicalURI(jspUri);
         this.options = options;
         this.jsw = jsw;
         this.context = context;
 
-        this.baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
+        String baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
         // hack fix for resolveRelativeURI
         if (baseURI == null) {
             baseURI = "/";
@@ -119,25 +142,18 @@ public class JspCompilationContext {
         if (baseURI.charAt(baseURI.length() - 1) != '/') {
             baseURI += '/';
         }
+        this.baseURI = baseURI;
 
         this.rctxt = rctxt;
-        this.tagFileJarUrls = new HashMap<String, JarResource>();
+        this.tagFileJarUrls = new HashMap<>();
         this.basePackageName = Constants.JSP_PACKAGE_NAME;
-    }
 
-    public JspCompilationContext(String tagfile,
-                                 TagInfo tagInfo,
-                                 Options options,
-                                 ServletContext context,
-                                 JspServletWrapper jsw,
-                                 JspRuntimeContext rctxt,
-                                 JarResource tagJarResource) {
-        this(tagfile, options, context, jsw, rctxt);
-        this.isTagFile = true;
         this.tagInfo = tagInfo;
         this.tagJarResource = tagJarResource;
+        this.isTagFile = isTagFile;
     }
 
+
     /* ==================== Methods to override ==================== */
 
     /** ---------- Class path and loader ---------- */
@@ -656,7 +672,7 @@ public class JspCompilationContext {
 
     // ==================== protected methods ====================
 
-    static Object outputDirLock = new Object();
+    static final Object outputDirLock = new Object();
 
     public void checkOutputDir() {
         if (outputDir != null) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org