diff options
author | acolyer <acolyer> | 2005-09-21 16:28:36 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-21 16:28:36 +0000 |
commit | 0e1bb192d429beba6a2a8f9b2ab8218f85673405 (patch) | |
tree | 0dac2da21d948cc42bb8fa47c68b4a8861b91af5 /bcel-builder | |
parent | 0bb21718c148e8be91a8e49aad1d3fead4e06849 (diff) | |
download | aspectj-0e1bb192d429beba6a2a8f9b2ab8218f85673405.tar.gz aspectj-0e1bb192d429beba6a2a8f9b2ab8218f85673405.zip |
fix for pr104957: NPE whilst compiling GIJ
Diffstat (limited to 'bcel-builder')
-rw-r--r-- | bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java index 7f9b116f1..029952887 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java @@ -64,46 +64,49 @@ package org.aspectj.apache.bcel.generic; * instructions must have the same target. * * @see Instruction - * @version $Id: InstructionComparator.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: InstructionComparator.java,v 1.3 2005/09/21 16:28:36 acolyer Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public interface InstructionComparator { - public static final InstructionComparator DEFAULT = - new InstructionComparator() { - public boolean equals(Instruction i1, Instruction i2) { - if(i1.opcode == i2.opcode) { - if(i1 instanceof Select) { - InstructionHandle[] t1 = ((Select)i1).getTargets(); - InstructionHandle[] t2 = ((Select)i2).getTargets(); + public static final InstructionComparator DEFAULT = new InstructionComparator() { + public boolean equals(Instruction i1, Instruction i2) { + if (i1.opcode == i2.opcode) { + if (i1 instanceof Select) { + InstructionHandle[] t1 = ((Select) i1).getTargets(); + InstructionHandle[] t2 = ((Select) i2).getTargets(); - if(t1.length == t2.length) { - for(int i = 0; i < t1.length; i++) { - if(t1[i] != t2[i]) { - return false; - } - } - - return true; - } - } else if(i1 instanceof BranchInstruction) { - return ((BranchInstruction)i1).target == - ((BranchInstruction)i2).target; - } else if(i1 instanceof ConstantPushInstruction) { - return ((ConstantPushInstruction)i1).getValue(). - equals(((ConstantPushInstruction)i2).getValue()); - } else if(i1 instanceof IndexedInstruction) { - return ((IndexedInstruction)i1).getIndex() == - ((IndexedInstruction)i2).getIndex(); - } else if(i1 instanceof NEWARRAY) { - return ((NEWARRAY)i1).getTypecode() == ((NEWARRAY)i2).getTypecode(); - } else { - return true; - } - } + // See AspectJ bug 104957 + if (t1 == null && t2 == null) return true; + if (t1 == null || t2 == null) return false; + + if (t1.length == t2.length) { + for (int i = 0; i < t1.length; i++) { + if (t1[i] != t2[i]) { + return false; + } + } - return false; - } - }; + return true; + } + } else if (i1 instanceof BranchInstruction) { + return ((BranchInstruction) i1).target == ((BranchInstruction) i2).target; + } else if (i1 instanceof ConstantPushInstruction) { + return ((ConstantPushInstruction) i1).getValue().equals( + ((ConstantPushInstruction) i2).getValue()); + } else if (i1 instanceof IndexedInstruction) { + return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2) + .getIndex(); + } else if (i1 instanceof NEWARRAY) { + return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2) + .getTypecode(); + } else { + return true; + } + } + + return false; + } + }; public boolean equals(Instruction i1, Instruction i2); } |