< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java

Print this page
rev 47452 : imported patch jdk-new-asmv6.patch


 129         i = 4;
 130         while ((l = s.indexOf(',', j)) > 0) {
 131             TYPES[i++] = s.substring(j, l);
 132             j = l + 1;
 133         }
 134 
 135         s = "H_GETFIELD,H_GETSTATIC,H_PUTFIELD,H_PUTSTATIC,"
 136                 + "H_INVOKEVIRTUAL,H_INVOKESTATIC,H_INVOKESPECIAL,"
 137                 + "H_NEWINVOKESPECIAL,H_INVOKEINTERFACE,";
 138         HANDLE_TAG = new String[10];
 139         j = 0;
 140         i = 1;
 141         while ((l = s.indexOf(',', j)) > 0) {
 142             HANDLE_TAG[i++] = s.substring(j, l);
 143             j = l + 1;
 144         }
 145     }
 146 
 147     /**
 148      * The ASM API version implemented by this class. The value of this field
 149      * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 150      */
 151     protected final int api;
 152 
 153     /**
 154      * A buffer that can be used to create strings.
 155      */
 156     protected final StringBuffer buf;
 157 
 158     /**
 159      * The text to be printed. Since the code of methods is not necessarily
 160      * visited in sequential order, one method after the other, but can be
 161      * interlaced (some instructions from method one, then some instructions
 162      * from method two, then some instructions from method one again...), it is
 163      * not possible to print the visited instructions directly to a sequential
 164      * stream. A class is therefore printed in a two steps process: a string
 165      * tree is constructed during the visit, and printed to a sequential stream
 166      * at the end of the visit. This string tree is stored in this field, as a
 167      * string list that can contain other string lists, which can themselves
 168      * contain other string lists, and so on.
 169      */
 170     public final List<Object> text;
 171 
 172     /**
 173      * Constructs a new {@link Printer}.
 174      *
 175      * @param api
 176      *            the ASM API version implemented by this printer. Must be one
 177      *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 178      */
 179     protected Printer(final int api) {
 180         this.api = api;
 181         this.buf = new StringBuffer();
 182         this.text = new ArrayList<Object>();
 183     }
 184 
 185     /**
 186      * Class header.
 187      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visit}.
 188      *
 189      * @param version
 190      *            the class version.
 191      * @param access
 192      *            the class's access flags (see {@link Opcodes}). This parameter
 193      *            also indicates if the class is deprecated.
 194      * @param name
 195      *            the internal name of the class (see
 196      *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
 197      * @param signature


 209      *            May be <tt>null</tt>.
 210      */
 211     public abstract void visit(final int version, final int access,
 212             final String name, final String signature, final String superName,
 213             final String[] interfaces);
 214 
 215     /**
 216      * Class source.
 217      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitSource}.
 218      *
 219      * @param source
 220      *            the name of the source file from which the class was compiled.
 221      *            May be <tt>null</tt>.
 222      * @param debug
 223      *            additional debug information to compute the correspondance
 224      *            between source and compiled elements of the class. May be
 225      *            <tt>null</tt>.
 226      */
 227     public abstract void visitSource(final String source, final String debug);
 228 

 229     /**

















 230      * Class outer class.
 231      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitOuterClass}.
 232      *
 233      * Visits the enclosing class of the class. This method must be called only
 234      * if the class has an enclosing class.
 235      *
 236      * @param owner
 237      *            internal name of the enclosing class of the class.
 238      * @param name
 239      *            the name of the method that contains the class, or
 240      *            <tt>null</tt> if the class is not enclosed in a method of its
 241      *            enclosing class.
 242      * @param desc
 243      *            the descriptor of the method that contains the class, or
 244      *            <tt>null</tt> if the class is not enclosed in a method of its
 245      *            enclosing class.
 246      */
 247     public abstract void visitOuterClass(final String owner, final String name,
 248             final String desc);
 249 


 359      *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
 360      * @param signature
 361      *            the method's signature. May be <tt>null</tt> if the method
 362      *            parameters, return type and exceptions do not use generic
 363      *            types.
 364      * @param exceptions
 365      *            the internal names of the method's exception classes (see
 366      *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}). May be
 367      *            <tt>null</tt>.
 368      * @return the printer
 369      */
 370     public abstract Printer visitMethod(final int access, final String name,
 371             final String desc, final String signature, final String[] exceptions);
 372 
 373     /**
 374      * Class end. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitEnd}.
 375      */
 376     public abstract void visitClassEnd();
 377 
 378     // ------------------------------------------------------------------------







































 379     // Annotations
 380     // ------------------------------------------------------------------------
 381 
 382     /**
 383      * Annotation value.
 384      * See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visit}.
 385      *
 386      * @param name
 387      *            the value name.
 388      * @param value
 389      *            the actual value, whose type must be {@link Byte},
 390      *            {@link Boolean}, {@link Character}, {@link Short},
 391      *            {@link Integer} , {@link Long}, {@link Float}, {@link Double},
 392      *            {@link String} or {@link jdk.internal.org.objectweb.asm.Type}
 393      *            or OBJECT or ARRAY sort.
 394      *            This value can also be an array of byte, boolean, short, char, int,
 395      *            long, float or double values (this is equivalent to using
 396      *            {@link #visitArray visitArray} and visiting each array element
 397      *            in turn, but is more convenient).
 398      */




 129         i = 4;
 130         while ((l = s.indexOf(',', j)) > 0) {
 131             TYPES[i++] = s.substring(j, l);
 132             j = l + 1;
 133         }
 134 
 135         s = "H_GETFIELD,H_GETSTATIC,H_PUTFIELD,H_PUTSTATIC,"
 136                 + "H_INVOKEVIRTUAL,H_INVOKESTATIC,H_INVOKESPECIAL,"
 137                 + "H_NEWINVOKESPECIAL,H_INVOKEINTERFACE,";
 138         HANDLE_TAG = new String[10];
 139         j = 0;
 140         i = 1;
 141         while ((l = s.indexOf(',', j)) > 0) {
 142             HANDLE_TAG[i++] = s.substring(j, l);
 143             j = l + 1;
 144         }
 145     }
 146 
 147     /**
 148      * The ASM API version implemented by this class. The value of this field
 149      * must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
 150      */
 151     protected final int api;
 152 
 153     /**
 154      * A buffer that can be used to create strings.
 155      */
 156     protected final StringBuffer buf;
 157 
 158     /**
 159      * The text to be printed. Since the code of methods is not necessarily
 160      * visited in sequential order, one method after the other, but can be
 161      * interlaced (some instructions from method one, then some instructions
 162      * from method two, then some instructions from method one again...), it is
 163      * not possible to print the visited instructions directly to a sequential
 164      * stream. A class is therefore printed in a two steps process: a string
 165      * tree is constructed during the visit, and printed to a sequential stream
 166      * at the end of the visit. This string tree is stored in this field, as a
 167      * string list that can contain other string lists, which can themselves
 168      * contain other string lists, and so on.
 169      */
 170     public final List<Object> text;
 171 
 172     /**
 173      * Constructs a new {@link Printer}.
 174      *
 175      * @param api
 176      *            the ASM API version implemented by this printer. Must be one
 177      *            of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
 178      */
 179     protected Printer(final int api) {
 180         this.api = api;
 181         this.buf = new StringBuffer();
 182         this.text = new ArrayList<Object>();
 183     }
 184 
 185     /**
 186      * Class header.
 187      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visit}.
 188      *
 189      * @param version
 190      *            the class version.
 191      * @param access
 192      *            the class's access flags (see {@link Opcodes}). This parameter
 193      *            also indicates if the class is deprecated.
 194      * @param name
 195      *            the internal name of the class (see
 196      *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
 197      * @param signature


 209      *            May be <tt>null</tt>.
 210      */
 211     public abstract void visit(final int version, final int access,
 212             final String name, final String signature, final String superName,
 213             final String[] interfaces);
 214 
 215     /**
 216      * Class source.
 217      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitSource}.
 218      *
 219      * @param source
 220      *            the name of the source file from which the class was compiled.
 221      *            May be <tt>null</tt>.
 222      * @param debug
 223      *            additional debug information to compute the correspondance
 224      *            between source and compiled elements of the class. May be
 225      *            <tt>null</tt>.
 226      */
 227     public abstract void visitSource(final String source, final String debug);
 228 
 229 
 230     /**
 231      * Module.
 232      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitModule(String, int)}.
 233      *
 234      * @param name
 235      *            module name.
 236      * @param access
 237      *            module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC}
 238      *            and {@code ACC_MANDATED}.
 239      * @param version
 240      *            module version or null.
 241      * @return
 242      */
 243     public Printer visitModule(String name, int access, String version) {
 244         throw new RuntimeException("Must be overriden");
 245     }
 246 
 247     /**
 248      * Class outer class.
 249      * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitOuterClass}.
 250      *
 251      * Visits the enclosing class of the class. This method must be called only
 252      * if the class has an enclosing class.
 253      *
 254      * @param owner
 255      *            internal name of the enclosing class of the class.
 256      * @param name
 257      *            the name of the method that contains the class, or
 258      *            <tt>null</tt> if the class is not enclosed in a method of its
 259      *            enclosing class.
 260      * @param desc
 261      *            the descriptor of the method that contains the class, or
 262      *            <tt>null</tt> if the class is not enclosed in a method of its
 263      *            enclosing class.
 264      */
 265     public abstract void visitOuterClass(final String owner, final String name,
 266             final String desc);
 267 


 377      *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
 378      * @param signature
 379      *            the method's signature. May be <tt>null</tt> if the method
 380      *            parameters, return type and exceptions do not use generic
 381      *            types.
 382      * @param exceptions
 383      *            the internal names of the method's exception classes (see
 384      *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}). May be
 385      *            <tt>null</tt>.
 386      * @return the printer
 387      */
 388     public abstract Printer visitMethod(final int access, final String name,
 389             final String desc, final String signature, final String[] exceptions);
 390 
 391     /**
 392      * Class end. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitEnd}.
 393      */
 394     public abstract void visitClassEnd();
 395 
 396     // ------------------------------------------------------------------------
 397     // Module
 398     // ------------------------------------------------------------------------
 399 
 400     public void visitMainClass(String mainClass) {
 401         throw new RuntimeException("Must be overriden");
 402     }
 403 
 404     public void visitPackage(String packaze) {
 405         throw new RuntimeException("Must be overriden");
 406     }
 407 
 408     public void visitRequire(String module, int access, String version) {
 409         throw new RuntimeException("Must be overriden");
 410     }
 411 
 412     public void visitExport(String packaze, int access, String... modules) {
 413         throw new RuntimeException("Must be overriden");
 414     }
 415 
 416     public void visitOpen(String packaze, int access, String... modules) {
 417         throw new RuntimeException("Must be overriden");
 418     }
 419 
 420     public void visitUse(String service) {
 421         throw new RuntimeException("Must be overriden");
 422     }
 423 
 424     public void visitProvide(String service, String... providers) {
 425         throw new RuntimeException("Must be overriden");
 426     }
 427 
 428     /**
 429      * Module end. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitEnd}.
 430      */
 431     public void visitModuleEnd() {
 432         throw new RuntimeException("Must be overriden");
 433     }
 434 
 435     // ------------------------------------------------------------------------
 436     // Annotations
 437     // ------------------------------------------------------------------------
 438 
 439     /**
 440      * Annotation value.
 441      * See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visit}.
 442      *
 443      * @param name
 444      *            the value name.
 445      * @param value
 446      *            the actual value, whose type must be {@link Byte},
 447      *            {@link Boolean}, {@link Character}, {@link Short},
 448      *            {@link Integer} , {@link Long}, {@link Float}, {@link Double},
 449      *            {@link String} or {@link jdk.internal.org.objectweb.asm.Type}
 450      *            or OBJECT or ARRAY sort.
 451      *            This value can also be an array of byte, boolean, short, char, int,
 452      *            long, float or double values (this is equivalent to using
 453      *            {@link #visitArray visitArray} and visiting each array element
 454      *            in turn, but is more convenient).
 455      */


< prev index next >