< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java

Print this page

335         String klassName = klass.getName().asString();
336         Short index = (Short) classToIndex.get(klassName);
337         dos.writeShort(index.shortValue());
338         if (DEBUG) debugMessage("this class = " + index);
339     }
340 
341     protected void writeSuperClass() throws IOException {
342         Klass superKlass = klass.getSuper();
343         if (superKlass != null) { // is not java.lang.Object
344             String superName = superKlass.getName().asString();
345             Short index = (Short) classToIndex.get(superName);
346             if (DEBUG) debugMessage("super class = " + index);
347             dos.writeShort(index.shortValue());
348         } else {
349             dos.writeShort(0); // no super class
350         }
351     }
352     protected void writeInterfaces() throws IOException {
353         KlassArray interfaces = klass.getLocalInterfaces();
354         final int len = interfaces.length();




355 
356         if (DEBUG) debugMessage("number of interfaces = " + len);
357 
358         // write interfaces count
359         dos.writeShort((short) len);
360         for (int i = 0; i < len; i++) {
361            Klass k = interfaces.getAt(i);
362            Short index = (Short) classToIndex.get(k.getName().asString());
363            dos.writeShort(index.shortValue());
364            if (DEBUG) debugMessage("\t" + index);


365         }
366     }
367 
368     protected void writeFields() throws IOException {
369         final int javaFieldsCount = klass.getJavaFieldsCount();
370 
371         // write number of fields
372         dos.writeShort((short) javaFieldsCount);
373 
374         if (DEBUG) debugMessage("number of fields = " + javaFieldsCount);
375 
376         for (int index = 0; index < javaFieldsCount; index++) {
377             short accessFlags    = klass.getFieldAccessFlags(index);
378             dos.writeShort(accessFlags & (short) JVM_RECOGNIZED_FIELD_MODIFIERS);
379 
380             short nameIndex    = klass.getFieldNameIndex(index);
381             dos.writeShort(nameIndex);
382 
383             short signatureIndex = klass.getFieldSignatureIndex(index);
384             dos.writeShort(signatureIndex);

335         String klassName = klass.getName().asString();
336         Short index = (Short) classToIndex.get(klassName);
337         dos.writeShort(index.shortValue());
338         if (DEBUG) debugMessage("this class = " + index);
339     }
340 
341     protected void writeSuperClass() throws IOException {
342         Klass superKlass = klass.getSuper();
343         if (superKlass != null) { // is not java.lang.Object
344             String superName = superKlass.getName().asString();
345             Short index = (Short) classToIndex.get(superName);
346             if (DEBUG) debugMessage("super class = " + index);
347             dos.writeShort(index.shortValue());
348         } else {
349             dos.writeShort(0); // no super class
350         }
351     }
352     protected void writeInterfaces() throws IOException {
353         KlassArray interfaces = klass.getLocalInterfaces();
354         final int len = interfaces.length();
355         int nb_interfaces = len;
356         if (klass.hasInjectedIdentityObject() || klass.hasInjectedPrimitiveObject()) {
357             nb_interfaces--;
358         }
359 
360         if (DEBUG) debugMessage("number of interfaces = " + nb_interfaces);
361 
362         // write interfaces count
363         dos.writeShort((short) nb_interfaces);
364         for (int i = 0; i < len; i++) {
365            Klass k = interfaces.getAt(i);
366            Short index = (Short) classToIndex.get(k.getName().asString());
367            if (index != null) { // Injected interfaces have no constant pool entry
368                dos.writeShort(index.shortValue());
369                if (DEBUG) debugMessage("\t" + index);
370            }
371         }
372     }
373 
374     protected void writeFields() throws IOException {
375         final int javaFieldsCount = klass.getJavaFieldsCount();
376 
377         // write number of fields
378         dos.writeShort((short) javaFieldsCount);
379 
380         if (DEBUG) debugMessage("number of fields = " + javaFieldsCount);
381 
382         for (int index = 0; index < javaFieldsCount; index++) {
383             short accessFlags    = klass.getFieldAccessFlags(index);
384             dos.writeShort(accessFlags & (short) JVM_RECOGNIZED_FIELD_MODIFIERS);
385 
386             short nameIndex    = klass.getFieldNameIndex(index);
387             dos.writeShort(nameIndex);
388 
389             short signatureIndex = klass.getFieldSignatureIndex(index);
390             dos.writeShort(signatureIndex);
< prev index next >