Skip to content

Commit 95cee5b

Browse files
authored
[JENKINS-67011] bridge-method-injector creates questionable bytecode (#34)
1 parent 1ba4418 commit 95cee5b

1 file changed

Lines changed: 1 addition & 23 deletions

File tree

injector/src/main/java/com/infradna/tool/bridge_method_injector/MethodInjector.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,7 @@ public void handle(File classFile) throws IOException {
7777
byte[] image;
7878
try (FileInputStream in = new FileInputStream(classFile); BufferedInputStream bis = new BufferedInputStream(in)) {
7979
ClassReader cr = new ClassReader(bis);
80-
/*
81-
working around JENKINS-22525 by not passing in 'cr'
82-
83-
Javac as of 6u31 seems to produce duplicate constant pool entries in some cases.
84-
When such a class is transformed through ClassReader -> ClassWriter, it creates
85-
a class file where reference sites to those duplicate entries get reshuffled
86-
(for example, say #15 and #30 are the duplicate entries, and after a transformation
87-
some references that used to use #15 now refers to #30, and vice versa.)
88-
89-
This is because ClassVisitor interfaces passes around strings, and
90-
ClassWriter looks up its constant pool to assign its index.
91-
92-
For whatever reasons, this triggers "incompatible InnerClasses attribute" problem
93-
in IBM J9VM (observed with R26_Java726_SR7_20140409_1418_B195732), while
94-
it is happy with the original class file.
95-
96-
It appears that this rare situation of having duplicate entries in constant pools
97-
and have various references use them in a certain way induces this J9 VM bug.
98-
99-
To work around this problem, we make ASM rebuild the constant pool from scratch,
100-
which totally eliminates any duplicate entries.
101-
*/
102-
ClassWriter cw = new ClassWriter(/*cr,*/COMPUTE_MAXS);
80+
ClassWriter cw = new ClassWriter(cr,COMPUTE_MAXS);
10381
cr.accept(new Transformer(new ClassAnnotationInjectorImpl(cw)),0);
10482
image = cw.toByteArray();
10583
} catch (AlreadyUpToDate unused) {

0 commit comments

Comments
 (0)