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 2020/04/28 15:37:44 UTC

[tomcat] branch 8.5.x updated (1871935 -> 5bc5ed2)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from 1871935  Use javax for 9
     new 10d4ef6  Formatting clean-up to improve clarity. No functional change.
     new 5bc5ed2  Fix compilation of JSPs with inner classes with ECJ 4.14 onwards

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/jasper/compiler/JDTCompiler.java | 79 ++++++++++--------------
 webapps/docs/changelog.xml                       |  5 ++
 2 files changed, 39 insertions(+), 45 deletions(-)


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


[tomcat] 01/02: Formatting clean-up to improve clarity. No functional change.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 10d4ef6b4d94cd2d8d89d7e60a51814a88c28201
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 28 10:28:50 2020 +0100

    Formatting clean-up to improve clarity. No functional change.
---
 java/org/apache/jasper/compiler/JDTCompiler.java | 77 ++++++++++--------------
 1 file changed, 33 insertions(+), 44 deletions(-)

diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java
index 5daea81..a6638f1 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -108,8 +108,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
         final String outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath();
         String packageName = ctxt.getServletPackageName();
         final String targetClassName =
-            ((packageName.length() != 0) ? (packageName + ".") : "")
-                    + ctxt.getServletClassName();
+                ((packageName.length() != 0) ? (packageName + ".") : "") + ctxt.getServletClassName();
         final ClassLoader classLoader = ctxt.getJspLoader();
         String[] fileNames = new String[] {sourceFile};
         String[] classNames = new String[] {targetClassName};
@@ -134,14 +133,12 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
             public char[] getContents() {
                 char[] result = null;
                 try (FileInputStream is = new FileInputStream(sourceFile);
-                        InputStreamReader isr = new InputStreamReader(
-                                is, ctxt.getOptions().getJavaEncoding());
+                        InputStreamReader isr = new InputStreamReader(is, ctxt.getOptions().getJavaEncoding());
                         Reader reader = new BufferedReader(isr)) {
                     char[] chars = new char[8192];
                     StringBuilder buf = new StringBuilder();
                     int count;
-                    while ((count = reader.read(chars, 0,
-                                                chars.length)) > 0) {
+                    while ((count = reader.read(chars, 0, chars.length)) > 0) {
                         buf.append(chars, 0, count);
                     }
                     result = new char[buf.length()];
@@ -163,8 +160,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
 
             @Override
             public char[][] getPackageName() {
-                StringTokenizer izer =
-                    new StringTokenizer(className, ".");
+                StringTokenizer izer = new StringTokenizer(className, ".");
                 char[][] result = new char[izer.countTokens()-1][];
                 for (int i = 0; i < result.length; i++) {
                     String tok = izer.nextToken();
@@ -182,52 +178,48 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
         final INameEnvironment env = new INameEnvironment() {
 
                 @Override
-                public NameEnvironmentAnswer
-                    findType(char[][] compoundTypeName) {
+                public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
                     StringBuilder result = new StringBuilder();
                     for (int i = 0; i < compoundTypeName.length; i++) {
-                        if(i > 0)
+                        if (i > 0) {
                             result.append('.');
+                        }
                         result.append(compoundTypeName[i]);
                     }
                     return findType(result.toString());
                 }
 
                 @Override
-                public NameEnvironmentAnswer
-                    findType(char[] typeName,
-                             char[][] packageName) {
-                        StringBuilder result = new StringBuilder();
-                        int i=0;
-                        for (; i < packageName.length; i++) {
-                            if(i > 0)
-                                result.append('.');
-                            result.append(packageName[i]);
-                        }
-                        if(i > 0)
+                public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
+                    StringBuilder result = new StringBuilder();
+                    int i=0;
+                    for (; i < packageName.length; i++) {
+                        if (i > 0) {
                             result.append('.');
-                        result.append(typeName);
-                        return findType(result.toString());
+                        }
+                        result.append(packageName[i]);
+                    }
+                    if (i > 0) {
+                        result.append('.');
+                    }
+                    result.append(typeName);
+                    return findType(result.toString());
                 }
 
                 private NameEnvironmentAnswer findType(String className) {
 
                     if (className.equals(targetClassName)) {
-                        ICompilationUnit compilationUnit =
-                            new CompilationUnit(sourceFile, className);
-                        return
-                            new NameEnvironmentAnswer(compilationUnit, null);
+                        ICompilationUnit compilationUnit = new CompilationUnit(sourceFile, className);
+                        return new NameEnvironmentAnswer(compilationUnit, null);
                     }
 
-                    String resourceName =
-                            className.replace('.', '/') + ".class";
+                    String resourceName = className.replace('.', '/') + ".class";
 
                     try (InputStream is = classLoader.getResourceAsStream(resourceName)) {
                         if (is != null) {
                             byte[] classBytes;
                             byte[] buf = new byte[8192];
-                            ByteArrayOutputStream baos =
-                                new ByteArrayOutputStream(buf.length);
+                            ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
                             int count;
                             while ((count = is.read(buf, 0, buf.length)) > 0) {
                                 baos.write(buf, 0, count);
@@ -235,11 +227,8 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
                             baos.flush();
                             classBytes = baos.toByteArray();
                             char[] fileName = className.toCharArray();
-                            ClassFileReader classFileReader =
-                                new ClassFileReader(classBytes, fileName,
-                                                    true);
-                            return
-                                new NameEnvironmentAnswer(classFileReader, null);
+                            ClassFileReader classFileReader = new ClassFileReader(classBytes, fileName, true);
+                            return new NameEnvironmentAnswer(classFileReader, null);
                         }
                     } catch (IOException exc) {
                         log.error("Compilation error", exc);
@@ -264,14 +253,14 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
                 }
 
                 @Override
-                public boolean isPackage(char[][] parentPackageName,
-                                         char[] packageName) {
+                public boolean isPackage(char[][] parentPackageName, char[] packageName) {
                     StringBuilder result = new StringBuilder();
-                    int i=0;
+                    int i = 0;
                     if (parentPackageName != null) {
                         for (; i < parentPackageName.length; i++) {
-                            if(i > 0)
+                            if (i > 0) {
                                 result.append('.');
+                            }
                             result.append(parentPackageName[i]);
                         }
                     }
@@ -281,8 +270,9 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
                             return false;
                         }
                     }
-                    if(i > 0)
+                    if (i > 0) {
                         result.append('.');
+                    }
                     result.append(packageName);
 
                     return isPackage(result.toString());
@@ -294,8 +284,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
 
             };
 
-        final IErrorHandlingPolicy policy =
-            DefaultErrorHandlingPolicies.proceedWithAllProblems();
+        final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
 
         final Map<String,String> settings = new HashMap<>();
         settings.put(CompilerOptions.OPTION_LineNumberAttribute,


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


[tomcat] 02/02: Fix compilation of JSPs with inner classes with ECJ 4.14 onwards

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 5bc5ed209554846c522071da56fe6276053da85b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 28 16:00:03 2020 +0100

    Fix compilation of JSPs with inner classes with ECJ 4.14 onwards
---
 java/org/apache/jasper/compiler/JDTCompiler.java | 2 +-
 webapps/docs/changelog.xml                       | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java
index a6638f1..a561cbe 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -239,7 +239,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
                 }
 
                 private boolean isPackage(String result) {
-                    if (result.equals(targetClassName)) {
+                    if (result.equals(targetClassName) || result.startsWith(targetClassName + '$')) {
                         return false;
                     }
                     String resourceName = result.replace('.', '/') + ".class";
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a8a5930..5853387 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -123,6 +123,11 @@
         is unpacked in <code>/WEB-INF/classes</code> ensure that the tag file
         can still be found. Patch provided by Karl von Randow. (markt)
       </fix>
+      <fix>
+        Ensure that the Jasper code that interfaces with the Eclipse Compiler
+        for Java (ECJ) enables Jasper to compile JSPs using ECJ 4.14 onwards
+        when the JSPs have inner classes. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">


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