From c604ed6c1a306ae963500fc63177bc9b6ae5569a Mon Sep 17 00:00:00 2001 From: "JesusFreke@JesusFreke.com" Date: Fri, 28 Aug 2009 03:58:42 +0000 Subject: [PATCH] Add .hashcode and .equals to EncodedCatchHandler and EncodedTypeAddrPair, so that the TryListBuilder can build a unique hash to avoid duplicate EncodedCatchHandler entries git-svn-id: https://smali.googlecode.com/svn/trunk@424 55b6fa8a-2a1e-11de-a435-ffa8d773f76a --- .../src/main/java/org/jf/dexlib/CodeItem.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dexlib/src/main/java/org/jf/dexlib/CodeItem.java b/dexlib/src/main/java/org/jf/dexlib/CodeItem.java index 7372ef3f..06ad5353 100644 --- a/dexlib/src/main/java/org/jf/dexlib/CodeItem.java +++ b/dexlib/src/main/java/org/jf/dexlib/CodeItem.java @@ -572,6 +572,39 @@ public class CodeItem extends Item { } } } + + @Override + public int hashCode() { + int hash = 0; + for (EncodedTypeAddrPair handler: handlers) { + hash = hash * 31 + handler.hashCode(); + } + hash = hash * 31 + catchAllHandlerAddress; + return hash; + } + + @Override + public boolean equals(Object o) { + if (this==o) { + return true; + } + if (o==null || !this.getClass().equals(o.getClass())) { + return false; + } + + EncodedCatchHandler other = (EncodedCatchHandler)o; + if (handlers.length != other.handlers.length || catchAllHandlerAddress != other.catchAllHandlerAddress) { + return false; + } + + for (int i=0; i { out.writeUnsignedLeb128(handlerAddress); } } + + @Override + public int hashCode() { + return exceptionType.hashCode() * 31 + handlerAddress; + } + + @Override + public boolean equals(Object o) { + if (this==o) { + return true; + } + if (o==null || !this.getClass().equals(o.getClass())) { + return false; + } + + EncodedTypeAddrPair other = (EncodedTypeAddrPair)o; + return exceptionType == other.exceptionType && handlerAddress == other.handlerAddress; + } } }