jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 18031] - ConstantPoolGen.lookupClass(String) finds LAST entry rather than first
Date Sun, 23 Mar 2003 20:02:09 GMT
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


Mime
View raw message