< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java

Print this page




 217      */
 218     protected SerialVersionUIDAdder(final int api, final ClassVisitor cv) {
 219         super(api, cv);
 220         svuidFields = new ArrayList<Item>();
 221         svuidConstructors = new ArrayList<Item>();
 222         svuidMethods = new ArrayList<Item>();
 223     }
 224 
 225     // ------------------------------------------------------------------------
 226     // Overridden methods
 227     // ------------------------------------------------------------------------
 228 
 229     /*
 230      * Visit class header and get class name, access , and interfaces
 231      * information (step 1,2, and 3) for SVUID computation.
 232      */
 233     @Override
 234     public void visit(final int version, final int access, final String name,
 235             final String signature, final String superName,
 236             final String[] interfaces) {
 237         computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0;
 238 
 239         if (computeSVUID) {
 240             this.name = name;
 241             this.access = access;
 242             this.interfaces = new String[interfaces.length];
 243             System.arraycopy(interfaces, 0, this.interfaces, 0,
 244                     interfaces.length);
 245         }
 246 
 247         super.visit(version, access, name, signature, superName, interfaces);
 248     }
 249 
 250     /*
 251      * Visit the methods and get constructor and method information (step 5 and
 252      * 7). Also determine if there is a class initializer (step 6).
 253      */
 254     @Override
 255     public MethodVisitor visitMethod(final int access, final String name,
 256             final String desc, final String signature, final String[] exceptions) {
 257         if (computeSVUID) {


 379      * @throws IOException
 380      *             if an I/O error occurs
 381      */
 382     protected long computeSVUID() throws IOException {
 383         ByteArrayOutputStream bos;
 384         DataOutputStream dos = null;
 385         long svuid = 0;
 386 
 387         try {
 388             bos = new ByteArrayOutputStream();
 389             dos = new DataOutputStream(bos);
 390 
 391             /*
 392              * 1. The class name written using UTF encoding.
 393              */
 394             dos.writeUTF(name.replace('/', '.'));
 395 
 396             /*
 397              * 2. The class modifiers written as a 32-bit integer.
 398              */





 399             dos.writeInt(access
 400                     & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
 401                             | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));
 402 
 403             /*
 404              * 3. The name of each interface sorted by name written using UTF
 405              * encoding.
 406              */
 407             Arrays.sort(interfaces);
 408             for (int i = 0; i < interfaces.length; i++) {
 409                 dos.writeUTF(interfaces[i].replace('/', '.'));
 410             }
 411 
 412             /*
 413              * 4. For each field of the class sorted by field name (except
 414              * private static and private transient fields):
 415              *
 416              * 1. The name of the field in UTF encoding. 2. The modifiers of the
 417              * field written as a 32-bit integer. 3. The descriptor of the field
 418              * in UTF encoding




 217      */
 218     protected SerialVersionUIDAdder(final int api, final ClassVisitor cv) {
 219         super(api, cv);
 220         svuidFields = new ArrayList<Item>();
 221         svuidConstructors = new ArrayList<Item>();
 222         svuidMethods = new ArrayList<Item>();
 223     }
 224 
 225     // ------------------------------------------------------------------------
 226     // Overridden methods
 227     // ------------------------------------------------------------------------
 228 
 229     /*
 230      * Visit class header and get class name, access , and interfaces
 231      * information (step 1,2, and 3) for SVUID computation.
 232      */
 233     @Override
 234     public void visit(final int version, final int access, final String name,
 235             final String signature, final String superName,
 236             final String[] interfaces) {
 237         computeSVUID = (access & Opcodes.ACC_ENUM) == 0;
 238 
 239         if (computeSVUID) {
 240             this.name = name;
 241             this.access = access;
 242             this.interfaces = new String[interfaces.length];
 243             System.arraycopy(interfaces, 0, this.interfaces, 0,
 244                     interfaces.length);
 245         }
 246 
 247         super.visit(version, access, name, signature, superName, interfaces);
 248     }
 249 
 250     /*
 251      * Visit the methods and get constructor and method information (step 5 and
 252      * 7). Also determine if there is a class initializer (step 6).
 253      */
 254     @Override
 255     public MethodVisitor visitMethod(final int access, final String name,
 256             final String desc, final String signature, final String[] exceptions) {
 257         if (computeSVUID) {


 379      * @throws IOException
 380      *             if an I/O error occurs
 381      */
 382     protected long computeSVUID() throws IOException {
 383         ByteArrayOutputStream bos;
 384         DataOutputStream dos = null;
 385         long svuid = 0;
 386 
 387         try {
 388             bos = new ByteArrayOutputStream();
 389             dos = new DataOutputStream(bos);
 390 
 391             /*
 392              * 1. The class name written using UTF encoding.
 393              */
 394             dos.writeUTF(name.replace('/', '.'));
 395 
 396             /*
 397              * 2. The class modifiers written as a 32-bit integer.
 398              */
 399             int access = this.access;
 400             if ((access & Opcodes.ACC_INTERFACE) != 0) {
 401                 access = (svuidMethods.size() > 0) ? (access | Opcodes.ACC_ABSTRACT)
 402                         : (access & ~Opcodes.ACC_ABSTRACT);
 403             }
 404             dos.writeInt(access
 405                     & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
 406                             | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));
 407 
 408             /*
 409              * 3. The name of each interface sorted by name written using UTF
 410              * encoding.
 411              */
 412             Arrays.sort(interfaces);
 413             for (int i = 0; i < interfaces.length; i++) {
 414                 dos.writeUTF(interfaces[i].replace('/', '.'));
 415             }
 416 
 417             /*
 418              * 4. For each field of the class sorted by field name (except
 419              * private static and private transient fields):
 420              *
 421              * 1. The name of the field in UTF encoding. 2. The modifiers of the
 422              * field written as a 32-bit integer. 3. The descriptor of the field
 423              * in UTF encoding


< prev index next >