8248348: Regression caused by the update to BCEL 6.0
Reviewed-by: smarks, plevart
This commit is contained in:
parent
6b8bf62a75
commit
e0c26b37fd
@ -30,7 +30,7 @@ import com.sun.org.apache.bcel.internal.util.ByteSequence;
|
||||
* LOOKUPSWITCH and TABLESWITCH.
|
||||
*
|
||||
* @see InstructionList
|
||||
* @LastModified: Jan 2020
|
||||
* @LastModified: July 2020
|
||||
*/
|
||||
public abstract class BranchInstruction extends Instruction implements InstructionTargeter {
|
||||
|
||||
@ -230,6 +230,23 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
||||
return target == ih;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the opcode. Before changing the opcode, reset the target so that
|
||||
* the old instruction is removed from the HashSet and the new one then added.
|
||||
* @param opcode the opcode
|
||||
*/
|
||||
@Override
|
||||
void setOpcode( final short opcode ) {
|
||||
if (target == null) {
|
||||
super.setOpcode(opcode);
|
||||
} else {
|
||||
// reset target before changing the opcode
|
||||
InstructionHandle t = target;
|
||||
setTarget(null);
|
||||
super.setOpcode(opcode);
|
||||
setTarget(t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform target that it's not targeted anymore.
|
||||
|
@ -29,7 +29,7 @@ import com.sun.org.apache.bcel.internal.util.ByteSequence;
|
||||
/**
|
||||
* Abstract super class for all Java byte codes.
|
||||
*
|
||||
* @LastModified: Jan 2020
|
||||
* @LastModified: July 2020
|
||||
*/
|
||||
public abstract class Instruction implements Cloneable {
|
||||
|
||||
@ -511,7 +511,7 @@ public abstract class Instruction implements Cloneable {
|
||||
/**
|
||||
* Needed in readInstruction and subclasses in this package
|
||||
*/
|
||||
final void setOpcode( final short opcode ) {
|
||||
void setOpcode( final short opcode ) {
|
||||
this.opcode = opcode;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package transform;
|
||||
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8248348
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @run testng transform.BCELHashCodeTest
|
||||
* @summary The addition of the hashCode() method to Instruction.java in BCEL 6.0
|
||||
* caused a regression. This test verifies that the issue has been fixed.
|
||||
*/
|
||||
public class BCELHashCodeTest {
|
||||
/**
|
||||
* Verifies the patch by attempting to create a transformer from the stylesheet.
|
||||
* The stylesheet contains an extra table-row with element-id="17921" that
|
||||
* causes the generated bytecode to exceed the 64Kbyte method size limit.
|
||||
* Splitting it into multiple methods requires mutating the instructions that
|
||||
* results in an Exception without the fix. The stylesheet would pass with
|
||||
* or without the fix if the extra table-row is removed.
|
||||
*
|
||||
* @throws TransformerConfigurationException if the test fails
|
||||
*/
|
||||
@Test
|
||||
public void test() throws TransformerConfigurationException {
|
||||
StreamSource stylesheet = new StreamSource(this.getClass()
|
||||
.getResourceAsStream("BCELHashCodeTest.xsl"));
|
||||
TransformerFactory tFactory =TransformerFactory.newInstance();
|
||||
Transformer transformer = tFactory.newTransformer(stylesheet);
|
||||
}
|
||||
}
|
2160
test/jaxp/javax/xml/jaxp/unittest/transform/BCELHashCodeTest.xsl
Normal file
2160
test/jaxp/javax/xml/jaxp/unittest/transform/BCELHashCodeTest.xsl
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user