[Fb-contrib-commit] SF.net SVN: fb-contrib: [869] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-02-26 08:01:54
|
Revision: 869 http://svn.sourceforge.net/fb-contrib/?rev=869&view=rev Author: dbrosius Date: 2007-02-26 00:01:55 -0800 (Mon, 26 Feb 2007) Log Message: ----------- add detector for BoxedPrimitive.valueOf(1).primitiveValue() Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2007-02-26 07:53:26 UTC (rev 868) +++ trunk/fb-contrib/etc/messages.xml 2007-02-26 08:01:55 UTC (rev 869) @@ -1104,6 +1104,9 @@ convert it back to a primitive. Just use the primitive value instead.</p> <pre> primitive i = new BoxedPrimitive(1).primitiveValue(); + or + primitive i = BoxedPrimitive.valueOf(1).primitiveValue(); + should just use primitive i = 1; </pre> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-26 07:53:26 UTC (rev 868) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java 2007-02-26 08:01:55 UTC (rev 869) @@ -36,9 +36,10 @@ { private static final int SEEN_NOTHING = 0; private static final int SEEN_VALUE = 1; - private static final int SEEN_VALUEOF = 2; + private static final int SEEN_VALUEOFSTRING = 2; private static final int SEEN_PARSE = 3; private static final int SEEN_CTOR = 4; + private static final int SEEN_VALUEOFPRIMITIVE = 5; private static final Map<String, String[]> boxClasses = new HashMap<String, String[]>(); static { @@ -98,9 +99,14 @@ boxClass = getClassConstantOperand(); String[] boxSigs = boxClasses.get(boxClass); if (boxSigs != null) { - if ("valueOf".equals(getNameConstantOperand()) && getSigConstantOperand().startsWith("(Ljava/lang/String;)")) { - if (!"java/lang/Boolean".equals(boxClass) || (getClassContext().getJavaClass().getMajor() >= Constants.MAJOR_1_5)) - state = SEEN_VALUEOF; + if ("valueOf".equals(getNameConstantOperand())) { + String sig = getSigConstantOperand(); + if (sig.startsWith("(Ljava/lang/String;)")) { + if (!"java/lang/Boolean".equals(boxClass) || (getClassContext().getJavaClass().getMajor() >= Constants.MAJOR_1_5)) + state = SEEN_VALUEOFSTRING; + } else { + state = SEEN_VALUEOFPRIMITIVE; + } } else { String parseSig = parseClasses.get(boxClass); if (parseSig != null) { @@ -156,6 +162,7 @@ break; case SEEN_CTOR: + case SEEN_VALUEOFPRIMITIVE: if (seen == INVOKEVIRTUAL) { String[] boxSigs = boxClasses.get(boxClass); if (boxSigs[0].equals(getNameConstantOperand() + getSigConstantOperand())) { @@ -168,7 +175,7 @@ state = SEEN_NOTHING; break; - case SEEN_VALUEOF: + case SEEN_VALUEOFSTRING: if (seen == INVOKEVIRTUAL) { String[] boxSigs = boxClasses.get(boxClass); if (boxSigs[0].equals(getNameConstantOperand() + getSigConstantOperand())) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |