[Fb-contrib-commit] SF.net SVN: fb-contrib:[1474] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2010-01-11 04:12:58
|
Revision: 1474 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1474&view=rev Author: dbrosius Date: 2010-01-11 04:12:47 +0000 (Mon, 11 Jan 2010) Log Message: ----------- using 1.5 now --> use enums Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java 2010-01-11 04:10:58 UTC (rev 1473) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java 2010-01-11 04:12:47 UTC (rev 1474) @@ -58,11 +58,9 @@ mapToSetMethods.add("values"); } - private static final int SEEN_NOTHING = 0; - private static final int SEEN_SYNC = 1; - private static final int SEEN_LOAD = 2; + enum State {SEEN_NOTHING, SEEN_SYNC, SEEN_LOAD} - private int state; + private State state; private Set<String> memberCollections; private Set<Integer> localCollections; private List<Object> monitorObjects; @@ -96,7 +94,7 @@ @Override public void visitCode(final Code obj) { if (obj.getCode() != null) { - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; localCollections.clear(); monitorObjects.clear(); stack.resetForMethodEntry(this); @@ -113,19 +111,19 @@ case SEEN_NOTHING: if ((seen == INVOKESTATIC) && "java/util/Collections".equals(getClassConstantOperand())) { if (synchCollectionNames.contains(getNameConstantOperand())) { - state = SEEN_SYNC; + state = State.SEEN_SYNC; } } else if (seen == ALOAD) { int reg = getRegisterOperand(); if (localCollections.contains(Integer.valueOf(reg))) { collectionInfo = Integer.valueOf(reg); - state = SEEN_LOAD; + state = State.SEEN_LOAD; } } else if ((seen >= ALOAD_0) && (seen <= ALOAD_3)) { int reg = seen - ALOAD_0; if (localCollections.contains(Integer.valueOf(reg))) { collectionInfo = Integer.valueOf(reg); - state = SEEN_LOAD; + state = State.SEEN_LOAD; } } else if (seen == GETFIELD) { ConstantFieldref ref = (ConstantFieldref)getConstantRefOperand(); @@ -134,7 +132,7 @@ String fieldName = nandt.getName(getConstantPool()); if (memberCollections.contains(fieldName)) { collectionInfo = fieldName; - state = SEEN_LOAD; + state = State.SEEN_LOAD; } } break; @@ -152,7 +150,7 @@ ConstantNameAndType nandt = (ConstantNameAndType)getConstantPool().getConstant(ref.getNameAndTypeIndex()); memberCollections.add(nandt.getName(getConstantPool())); } - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; break; case SEEN_LOAD: @@ -160,9 +158,9 @@ String calledClass = getClassConstantOperand(); if ("java/lang/Map".equals(calledClass)) { if (mapToSetMethods.contains(getNameConstantOperand())) { - state = SEEN_LOAD; + state = State.SEEN_LOAD; } else { - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; } } else if (calledClass.startsWith("java/util/")) { if ("iterator".equals(getNameConstantOperand())) { @@ -171,7 +169,7 @@ .addClass(this) .addMethod(this) .addSourceLine(this)); - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; } else { Object syncObj = monitorObjects.get(monitorObjects.size() - 1); @@ -181,14 +179,14 @@ .addMethod(this) .addSourceLine(this)); } - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; } } } else { - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; } } else { - state = SEEN_NOTHING; + state = State.SEEN_NOTHING; } break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |