< prev index next >
src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java
Print this page
*** 161,170 ****
--- 161,180 ----
* Outputs the modified module-info.class to the given output stream.
* Once this method has been called then the Extender object should
* be discarded.
*/
public void write(OutputStream out) throws IOException {
+ // emit to the output stream
+ out.write(getBytes());
+ }
+
+ /**
+ * Returns the bytes of the modified module-info.class.
+ * Once this method has been called then the Extender object should
+ * be discarded.
+ */
+ public byte[] getBytes() throws IOException {
ClassWriter cw
= new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
AttributeAddingClassVisitor cv
= new AttributeAddingClassVisitor(Opcodes.ASM5, cw);
*** 195,206 ****
cr.accept(cv, attrs.toArray(new Attribute[0]), 0);
// add any attributes that didn't replace previous attributes
cv.finish();
! // emit to the output stream
! out.write(cw.toByteArray());
}
/**
* Returns an {@code Extender} that may be used to add additional
* attributes to the module-info.class read from the given input
--- 205,215 ----
cr.accept(cv, attrs.toArray(new Attribute[0]), 0);
// add any attributes that didn't replace previous attributes
cv.finish();
! return cw.toByteArray();
}
/**
* Returns an {@code Extender} that may be used to add additional
* attributes to the module-info.class read from the given input
< prev index next >