You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2002/08/12 23:58:49 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Compiler.java SmapUtil.java

kinman      2002/08/12 14:58:48

  Modified:    jasper2/src/share/org/apache/jasper/compiler Compiler.java
                        SmapUtil.java
  Log:
  - Turn on jsr045 support with bug fixes.
    Patch by Shawn Bayern <ba...@essentially.net>
  
  Revision  Changes    Path
  1.26      +5 -5      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Compiler.java	6 Aug 2002 23:40:10 -0000	1.25
  +++ Compiler.java	12 Aug 2002 21:58:48 -0000	1.26
  @@ -253,7 +253,7 @@
           writer.close();
   
           //JSR45 Support - note this needs to be checked by a JSR45 guru
  -	//XXX SmapUtil.generateSmap(ctxt, pageNodes, true);
  +	SmapUtil.generateSmap(ctxt, pageNodes, true);
       }
   
       /** 
  @@ -329,7 +329,7 @@
           }
   
           //JSR45 Support - note this needs to be checked by a JSR45 guru
  -	//XXX SmapUtil.installSmap(ctxt);
  +	SmapUtil.installSmap(ctxt);
       }
   
       /** 
  
  
  
  1.4       +47 -46    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/SmapUtil.java
  
  Index: SmapUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/SmapUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SmapUtil.java	16 Jul 2002 22:35:04 -0000	1.3
  +++ SmapUtil.java	12 Aug 2002 21:58:48 -0000	1.4
  @@ -73,7 +73,7 @@
    */
   public class SmapUtil {
   
  -    static final boolean verbose = false;
  +    private static final boolean verbose = false;
   
       //*********************************************************************
       // Constants
  @@ -139,10 +139,9 @@
           File outSmap = new File(ctxt.getClassFileName() + ".smap");
           File outServlet = new File(ctxt.getClassFileName());
           SDEInstaller.install(outServlet, outSmap);
  -        if( !ctxt.keepGenerated() ) {
  +//        if( !ctxt.keepGenerated() ) {
               outSmap.delete();
  -        }
  -      
  +//        }
       }
   
   
  @@ -186,18 +185,19 @@
               } else if (args.length == 3) {
                   install(new File(args[0]), new File(args[1]), new File(args[2]));
               } else {
  -                abort("Usage: <command> <input class file> " + 
  -                                   "<attribute file> <output class file name>\n" +
  +                System.err.println("Usage: <command> <input class file> " + 
  +                      "<attribute file> <output class file name>\n" +
                         "<command> <input/output class file> <attribute file>");
               }
           }
   
           static void install(File inClassFile, File attrFile, File outClassFile)
  -                                                                throws IOException {
  +                throws IOException {
               new SDEInstaller(inClassFile, attrFile, outClassFile);
           }
   
  -        static void install(File inOutClassFile, File attrFile) throws IOException {
  +        static void install(File inOutClassFile, File attrFile)
  +                throws IOException {
               File tmpFile = new File(inOutClassFile.getPath() + "tmp");
               new SDEInstaller(inOutClassFile, attrFile, tmpFile);
               if (!inOutClassFile.delete()) {
  @@ -208,17 +208,13 @@
               }
           }
   
  -        static void abort(String msg) {
  -            System.err.println(msg);
  -            System.exit(1);
  -        }
  -
  -        SDEInstaller(File inClassFile, File attrFile, File outClassFile) throws IOException {
  +        SDEInstaller(File inClassFile, File attrFile, File outClassFile)
  +                throws IOException {
               if (!inClassFile.exists()) {
  -                abort("no such file: " + inClassFile);
  +                throw new FileNotFoundException("no such file: " + inClassFile);
               }
               if (!attrFile.exists()) {
  -                abort("no such file: " + attrFile);
  +                throw new FileNotFoundException("no such file: " + attrFile);
               }
    
               // get the bytes
  @@ -240,18 +236,22 @@
               int len = (int)input.length();
               byte[] bytes = new byte[len];
               if (inStream.read(bytes, 0, len) != len) {
  -                abort("expected size: " + len);
  +                throw new IOException("expected size: " + len);
               }
               inStream.close();
               return bytes;
           }
   
  -        void addSDE() throws UnsupportedEncodingException {
  +        void addSDE() throws UnsupportedEncodingException, IOException {
               int i;
               copy(4 + 2 + 2); // magic min/maj version
               int constantPoolCountPos = genPos;
               int constantPoolCount = readU2();
  +            if (verbose) {
  +                System.out.println("constant pool count: " + constantPoolCount);
  +            }
               writeU2(constantPoolCount);
  +
               // copy old constant pool return index of SDE symbol, if found
               sdeIndex = copyConstantPool(constantPoolCount);
               if (sdeIndex < 0) {
  @@ -403,7 +403,8 @@
               }
           }
       
  -        int copyConstantPool(int constantPoolCount) throws UnsupportedEncodingException {
  +        int copyConstantPool(int constantPoolCount)
  +                throws UnsupportedEncodingException, IOException {
               int sdeIndex = -1;
               // copy const pool index zero not in class file
               for (int i = 1; i < constantPoolCount; ++i) {
  @@ -412,6 +413,9 @@
                   switch (tag) {
                       case 7:  // Class
                       case 8:  // String
  +                        if (verbose) {
  +                            System.out.println(i + " copying 2 bytes");
  +                        }
                           copy(2); 
                           break;
                       case 9:  // Field
  @@ -420,11 +424,18 @@
                       case 3:  // Integer
                       case 4:  // Float
                       case 12: // NameAndType
  +                        if (verbose) {
  +                            System.out.println(i + " copying 4 bytes");
  +                        }
                           copy(4); 
                           break;
                       case 5:  // Long
                       case 6:  // Double
  +                        if (verbose) {
  +                            System.out.println(i + " copying 8 bytes");
  +                        }
                           copy(8); 
  +                        i++;
                           break;
                       case 1:  // Utf8
                           int len = readU2(); 
  @@ -440,8 +451,7 @@
                           writeBytes(utf8);
                           break;
                       default: 
  -                        abort("unexpected tag: " + tag); 
  -                        break;
  +                        throw new IOException("unexpected tag: " + tag); 
                   }
               }
               return sdeIndex;
  @@ -457,35 +467,26 @@
           }
       }
       public static void evaluateNodes(Node.Nodes nodes, SmapStratum s) {
  -      if( nodes != null && nodes.size()>0) {
  -        int numChildNodes = nodes.size();
  -        for( int i = 0; i < numChildNodes; i++ ) {
  -          Node n = nodes.getNode( i );
  -          Mark mark = n.getStart();
  -
  -          if (verbose) {
  -            System.out.println("Mark(start): line="+ mark.getLineNumber() +
  -                " col="+mark.getColumnNumber() +"Node: begLine="+
  -                n.getBeginJavaLine() +" endLine="+n.getEndJavaLine());
  -          }
  -          String unqualifiedName = unqualify(mark.getFile());
  -          s.addFile(unqualifiedName);
  -          s.addLineData(mark.getLineNumber(),
  +        if( nodes != null && nodes.size()>0) {
  +            int numChildNodes = nodes.size();
  +            for( int i = 0; i < numChildNodes; i++ ) {
  +                Node n = nodes.getNode( i );
  +                Mark mark = n.getStart();
  +
  +                if (verbose) {
  +                System.out.println("Mark(start): line="+ mark.getLineNumber() +
  +                    " col="+mark.getColumnNumber() +"Node: begLine="+
  +                    n.getBeginJavaLine() +" endLine="+n.getEndJavaLine());
  +                }
  +                String unqualifiedName = unqualify(mark.getFile());
  +                s.addFile(unqualifiedName);
  +                s.addLineData(mark.getLineNumber(),
                           unqualifiedName,
                           1,
                           n.getBeginJavaLine(),
                           n.getEndJavaLine() - n.getBeginJavaLine());
  -          evaluateNodes(nodes.getNode(i).getBody(), s);
  -
  -/*
  -int inputStartLine,
  -String inputFileName,
  -int inputLineCount,
  -int outputStartLine,
  -int outputLineIncrement
  -*/
  +                evaluateNodes(nodes.getNode(i).getBody(), s);
  +            }
           }
  -      }
       }
  -
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>