The preprocess branch assumes public transform method, so make it public
authorJaroslav Tulach <jaroslav.tulach@netbeans.org>
Sun, 12 Jan 2014 07:49:00 +0100
changeset 45681cb90970dd3
parent 455 7782138f7491
child 457 0dfde9892f4a
The preprocess branch assumes public transform method, so make it public
boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java
     1.1 --- a/boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java	Sun Jan 12 07:41:23 2014 +0100
     1.2 +++ b/boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java	Sun Jan 12 07:49:00 2014 +0100
     1.3 @@ -172,6 +172,40 @@
     1.4          } 
     1.5      }
     1.6      
     1.7 +    /** Checks bytecode for usage of {@link JavaScriptBody} annotation
     1.8 +     * and rewrites it to invoke {@link Fn.Presenter} directly. 
     1.9 +     * 
    1.10 +     * @param arr the byte code to check
    1.11 +     * @param loader loader to load additional resources and classes
    1.12 +     * @return the same <code>arr</code> (if no change needed) or new
    1.13 +     *    array with rewritten bytecode
    1.14 +     * @since 0.7
    1.15 +     */
    1.16 +    public static byte[] transform(byte[] arr, ClassLoader loader) {
    1.17 +        ClassReader cr = new ClassReader(arr) {
    1.18 +            // to allow us to compile with -profile compact1 on 
    1.19 +            // JDK8 while processing the class as JDK7, the highest
    1.20 +            // class format asm 4.1 understands to
    1.21 +            @Override
    1.22 +            public short readShort(int index) {
    1.23 +                short s = super.readShort(index);
    1.24 +                if (index == 6 && s > Opcodes.V1_7) {
    1.25 +                    return Opcodes.V1_7;
    1.26 +                }
    1.27 +                return s;
    1.28 +            }
    1.29 +        };
    1.30 +        FindInClass tst = new FindInClass(loader, null);
    1.31 +        cr.accept(tst, 0);
    1.32 +        if (tst.found > 0) {
    1.33 +            ClassWriter w = new ClassWriterEx(loader, cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    1.34 +            FindInClass fic = new FindInClass(loader, w);
    1.35 +            cr.accept(fic, 0);
    1.36 +            arr = w.toByteArray();
    1.37 +        }
    1.38 +        return arr;
    1.39 +    }
    1.40 +    
    1.41      private static final class FindInClass extends ClassVisitor {
    1.42          private String name;
    1.43          private int found;
    1.44 @@ -573,31 +607,6 @@
    1.45          }
    1.46      }
    1.47  
    1.48 -    static byte[] transform(ClassLoader loader, byte[] arr) {
    1.49 -        ClassReader cr = new ClassReader(arr) {
    1.50 -            // to allow us to compile with -profile compact1 on 
    1.51 -            // JDK8 while processing the class as JDK7, the highest
    1.52 -            // class format asm 4.1 understands to
    1.53 -            @Override
    1.54 -            public short readShort(int index) {
    1.55 -                short s = super.readShort(index);
    1.56 -                if (index == 6 && s > Opcodes.V1_7) {
    1.57 -                    return Opcodes.V1_7;
    1.58 -                }
    1.59 -                return s;
    1.60 -            }
    1.61 -        };
    1.62 -        FindInClass tst = new FindInClass(loader, null);
    1.63 -        cr.accept(tst, 0);
    1.64 -        if (tst.found > 0) {
    1.65 -            ClassWriter w = new ClassWriterEx(loader, cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    1.66 -            FindInClass fic = new FindInClass(loader, w);
    1.67 -            cr.accept(fic, 0);
    1.68 -            arr = w.toByteArray();
    1.69 -        }
    1.70 -        return arr;
    1.71 -    }
    1.72 -
    1.73      private static final class TrueFn extends Fn implements Fn.Presenter {
    1.74          @Override
    1.75          public Object invoke(Object thiz, Object... args) throws Exception {