You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by bu...@apache.org on 2003/03/23 21:02:09 UTC

DO NOT REPLY [Bug 18031] - ConstantPoolGen.lookupClass(String) finds LAST entry rather than first

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18031>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18031

ConstantPoolGen.lookupClass(String) finds LAST entry rather than first





------- Additional Comments From mcrocker@markcrocker.com  2003-03-23 20:02 -------

The fix is quite simple.  Basically, the class_table is stored in a HashMap. 
HashMaps assume that there is only one entry per key, which is not the case in
these bizarre obfuscated classes.  The solution is to check to see if the key
exists already before put'ing another one.  This explains why BCEL's
ConstantPoolGen.lookupClass(String) was always finding the LAST case, rather
than the first.  The fix is:

original line 118:
	class_table.put(u8Bytes, new Index(i));

suggested replacement:

	String u8Bytes = u8.getBytes();
	if (!class_table.containsKey(u8Bytes)) {
		class_table.put(u8Bytes, new Index(i));
	}

Note that this problem occurs with ALL of the HashMaps that are used to store
non-trivial types in the ConstantPoolGen class.  This fix should be applied to
all of those cases as well.

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org