diff --git a/.checkstyle b/.checkstyle
deleted file mode 100644
index dafbb82..0000000
--- a/.checkstyle
+++ /dev/null
@@ -1,5 +0,0 @@
-
- \n\
- \n\
- Send comments to findbugs@cs.umd.edu \n\
- Send comments to findbugs@cs.umd.edu \n\
+ \n\
+
doc.html.googleanalytics= \n\
+
doc.html.gen.header=\
- \n\
-
+ \n\
+
doc.html.gen.beginBody= \n\
- This document lists the standard bug patterns reported by\n\
- FindBugs version @VERSION@. This document lists the standard bug patterns reported by\n\
+ FindBugs version @VERSION@. This document lists all of the bug patterns reported by the\n\
- latest development version of \n\
- FindBugs. Note that this may include\n\
- bug patterns not available in any released version of FindBugs,\n\
- as well as bug patterns that are not enabled by default.
+ This document lists all of the bug patterns reported by the\n\
+ latest development version of \n\
+ FindBugs. Note that this may include\n\
+ bug patterns not available in any released version of FindBugs,\n\
+ as well as bug patterns that are not enabled by default.
diff --git a/etc/findbugs.xml b/etc/findbugs.xml
index 2b49e10..e718d6b 100644
--- a/etc/findbugs.xml
+++ b/etc/findbugs.xml
@@ -417,7 +417,6 @@
reports="CAA_COVARIANT_ARRAY_FIELD,CAA_COVARIANT_ARRAY_RETURN,CAA_COVARIANT_ARRAY_LOCAL,CAA_COVARIANT_ARRAY_ELEMENT_STORE"/>
This detector looks for synchronization on a shared built-in constant (such as a String). This detector generates a random signal: warnings that are just based on
hash values of the operations performed by methods.
These warnings are bogus random noise, intended to be useful
- as a control in data mining experiments, not in finding actual bugs in software
+ as a control in data mining experiments, not in finding actual bugs in software.
This detector is just a hook for testing new detectors.
Normally, this detector does nothing. This detector looks for problems in how Iterator classes are defined.
\n\
-
+ \n\
-
\n\
- \n\
- \n\
- \n\
- \n\
- \n\
- Docs and Info \n\
- FindBugs 2.0 \n\
- Demo and data \n\
- Users and supporters \n\
- FindBugs blog \n\
- Fact sheet \n\
- Manual \n\
- Manual(ja/日本語) \n\
- FAQ \n\
- Bug descriptions \n\
- Bug descriptions(ja/日本語) \n\
- Bug descriptions(fr) \n\
- Mailing lists \n\
- Documents and Publications \n\
- \n\
- Links \n\
- \n\
- \n\
- \n\
- Downloads \n\
- \n\
- \n\
- \n\
- FindBugs Swag \n\
- \n\
- \n\
- Development \n\
- Open bugs \n\
- Reporting bugs \n\
- Contributing \n\
- Dev team \n\
- API [no frames] \n\
- Change log \n\
- SF project page \n\
- Browse source \n\
- Latest code changes \n\
+
doc.html.footer= \n\
- \n\
+
\n\
+ \n\
+ \n\
+ \n\
+ \n\
+ \n\
+ Docs and Info \n\
+ FindBugs 2.0 \n\
+ Demo and data \n\
+ Users and supporters \n\
+ FindBugs blog \n\
+ Fact sheet \n\
+ Manual \n\
+ Manual(ja/日本語) \n\
+ FAQ \n\
+ Bug descriptions \n\
+ Bug descriptions(ja/日本語) \n\
+ Bug descriptions(fr) \n\
+ Mailing lists \n\
+ Documents and Publications \n\
+ \n\
+ Links \n\
+ \n\
+ \n\
+ \n\
+ Downloads \n\
+ \n\
+ \n\
+ \n\
+ FindBugs Swag \n\
+ \n\
+ \n\
+ Development \n\
+ Open bugs \n\
+ Reporting bugs \n\
+ Contributing \n\
+ Dev team \n\
+ API [no frames] \n\
+ Change log \n\
+ GitHub project page \n\
+ Browse source \n\
+ Latest code changes
doc.html.gen.bugDescriptions.prologue=\
- \n\
- @HTML_SIDEBAR@\n\
-
+
+ @HTML_FOOTER@\n\
+ \n\
+ @HTML_SIDEBAR@\n\
+
doc.html.gen.endBody=\n\
- @HTML_FOOTER@\n\
-
This detector looks for circular dependencies among classes.
]]> @@ -1320,7 +1320,7 @@ This detector looks for public classes that synchronize and use wait(), notify() or notifyAll() on this. This exposes a synchronization implementation as a public artifact of the class. -Clients of the class may use an instance of the class as it's own synchronizing object, and cause +Clients of the class may use an instance of the class as its own synchronizing object, and cause havoc to the base implementation. ]]> @@ -1368,7 +1368,7 @@This detector looks for miscellaneous small errors mentioned by Joshua Bloch and Neal Gafter in their work on Programming Puzzlers.
@@ -1462,7 +1462,7 @@Looks for an attempt to append to an object output stream.
]]>(Javadoc) A ScheduledThreadPoolExecutor with zero core threads will never execute anything; changes to the max pool size are ignored.
@@ -1770,7 +1770,7 @@(Javadoc) While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect.
@@ -2045,9 +2045,9 @@A warning was recorded, but FindBugs can't find the description of this bug pattern and so can't describe it. This should occur only in cases of a bug in FindBugs or its configuration, or perhaps if an analysis was generated using a plugin, but that plugin is not currently loaded. .
@@ -2685,7 +2685,7 @@Random.nextInt(n)
method.
+want to multiply the random value by something else before coercing it to an integer, or use the Random.nextInt(n)
method.
]]>
This is considered bad practice, as it makes it very hard to implement an equals method that -is symmetric and transitive. Without those properties, very unexpected behavoirs are possible. +is symmetric and transitive. Without those properties, very unexpected behaviors are possible.
]]>A web server generally only creates one instance of servlet or JSP class (i.e., treats the class as a Singleton), and will have multiple threads invoke methods on that instance to service multiple @@ -3509,8 +3509,8 @@ when evaluating the right-hand side can generate an error.
-See the Java -Language Specification for details +
See the Java +Language Specification for details.
]]> @@ -3530,8 +3530,8 @@ can result in errors if the left-hand side guards cases when evaluating the right-hand side can generate an error. -See the Java -Language Specification for details +
See the Java +Language Specification for details.
]]> @@ -3599,7 +3599,7 @@This method is invoked in the constructor of the superclass. At this point, the fields of the class have not yet initialized.
To make this more concrete, consider the following classes:
abstract class A { @@ -3622,7 +3622,7 @@ the constructor for theA
class is invoked before the constructor forB
setsvalue
. Thus, when the constructor forA
invokesgetValue
, -an uninitialized value is read forvalue
+an uninitialized value is read forvalue
. ]]>
Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this could +
Constant Strings are interned and shared across all other classes loaded by the JVM. Thus, this code is locking on something that other code might also be locking. This could result in very strange and hard to diagnose blocking and deadlock behavior. See http://www.javalobby.org/java/forums/t96352.html and http://jira.codehaus.org/browse/JETTY-352.
@@ -3711,7 +3711,7 @@The code synchronizes on a boxed primitive constant, such as a Boolean.
private static Boolean inited = Boolean.FALSE; ... @@ -3724,7 +3724,7 @@ ...
Since there normally exist only two Boolean objects, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness -and possible deadlock
+and possible deadlock.See CERT CON08-J. Do not synchronize on objects that may be reused for more information.
]]>Since Integer objects can be cached and shared, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness -and possible deadlock
+and possible deadlock.See CERT CON08-J. Do not synchronize on objects that may be reused for more information.
]]>foo(17)
, which is defined in both a superclass and in an outer method.
By the Java semantics,
-it will be resolved to invoke the inherited method, but this may not be want
+it will be resolved to invoke the inherited method, but this may not be what
you intend.
If you really intend to invoke the inherited method,
@@ -4895,8 +4895,8 @@
This condition always produces the same result as the value of the involved variable that was narrowed before. +Probably something else was meant or the condition can be removed.
]]>new Boolean(b)
constructor. It is best to avoid such objects, but if they do exist,
then checking Boolean objects for equality using == or != will give results
-than are different than you would get using .equals(...)
+than are different than you would get using .equals(...)
.
]]>
This code generates a random signed integer and then computes
the absolute value of that random integer. If the number returned by the random number
generator is Integer.MIN_VALUE
, then the result will be negative as well (since
-Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
). (Same problem arised for long values as well).
+Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
). (Same problem arises for long values as well).
x.hashCode()%n
, use x.hashCode()&(n-1)
.
+using x.hashCode()%n
, use x.hashCode()&(n-1)
).
This is probably faster than computing the remainder as well.
If you don't know that the divisor is a power of 2, take the absolute
value of the result of the remainder operation (i.e., use
-Math.abs(x.hashCode()%n)
+Math.abs(x.hashCode()%n)
).
]]>
Signed bytes can only have a value in the range -128 to 127. Comparing
a signed byte with a value outside that range is vacuous and likely to be incorrect.
To convert a signed byte b
to an unsigned value in the range 0..255,
-use 0xff & b
+use 0xff & b
.
Loads a byte value (e.g., a value loaded from a byte array or returned by a method
with return type byte) and performs a bitwise OR with
that value. Byte values are sign extended to 32 bits
-before any any bitwise operations are performed on the value.
+before any bitwise operations are performed on the value.
Thus, if b[0]
contains the value 0xff
, and
x
is initially 0, then the code
((x << 8) | b[0])
will sign extend 0xff
@@ -6072,7 +6072,7 @@
Adds a byte value and a value which is known to have the 8 lower bits clear.
Values loaded from a byte array are sign extended to 32 bits
-before any any bitwise operations are performed on the value.
+before any bitwise operations are performed on the value.
Thus, if b[0]
contains the value 0xff
, and
x
is initially 0, then the code
((x << 8) + b[0])
will sign extend 0xff
@@ -6114,35 +6114,27 @@
((event.detail & SWT.SELECTED) > 0). -
Using bit arithmetic and then comparing with the greater than operator can +
This method compares an expression such as
+((event.detail & SWT.SELECTED) > 0)
.
+Using bit arithmetic and then comparing with the greater than operator can
lead to unexpected results (of course depending on the value of
SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate
for a bug. Even when SWT.SELECTED is not negative, it seems good practice
to use '!= 0' instead of '> 0'.
-Boris Bokowski -
]]>((event.detail & SWT.SELECTED) > 0). -
Using bit arithmetic and then comparing with the greater than operator can
-lead to unexpected results (of course depending on the value of
-SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate
-for a bug. Even when SWT.SELECTED is not negative, it seems good practice
+ ((val & CONSTANT) > 0)
where CONSTANT is the negative number.
+Using bit arithmetic and then comparing with the greater than operator can
+lead to unexpected results. This comparison is unlikely to work as expected. The good practice is
to use '!= 0' instead of '> 0'.
-
-Boris Bokowski
]]> This method compares an expression of the form (e & 0)
to 0,
which will always compare equal.
This may indicate a logic error or typo.
This method compares an expression of the form (e | C)
to D.
which will always compare unequal
due to the specific values of constants C and D.
This may indicate a logic error or typo.
Typically, this bug occurs because the code wants to perform a membership test in a bit set, but uses the bitwise OR operator ("|") instead of bitwise AND ("&").
+ +Also such bug may appear in expressions like (e & A | B) == C
+which is parsed like ((e & A) | B) == C
while (e & (A | B)) == C
was intended.
This method contains an unsynchronized lazy initialization of a static field. After the field is set, the object stored into that location is further updated or accessed. The setting of the field is visible to other threads as soon as it is set. If the -futher accesses in the method that set the field serve to initialize the object, then +further accesses in the method that set the field serve to initialize the object, then you have a very serious multithreading bug, unless something else prevents any other thread from accessing the stored object until it is fully initialized.
@@ -6509,7 +6504,7 @@Class is a JUnit TestCase but has not implemented any test methods.
]]>Foo.class
would force the static initializer
for Foo
to be executed, if it has not been executed already.
In Java 5 and later, it does not.
-See Sun's article on Java SE compatibility +
See Sun's article on Java SE compatibility for more details and examples, and suggestions on how to force class initialization in Java 5.
]]> @@ -7194,8 +7189,8 @@String.format("%d", "1")
will generate an exception, since
the String "1" is incompatible with the format specifier %d.
@@ -7433,7 +7428,7 @@
The correct way to do get an array of a specific type from a collection is to use
c.toArray(new String[]);
or c.toArray(new String[c.size()]);
(the latter is slightly more efficient).
-
There is one common/known exception exception to this. The toArray()
+
There is one common/known exception to this. The toArray()
method of lists returned by Arrays.asList(...)
will return a covariantly
typed array. For example, Arrays.asArray(new String[] { "a" }).toArray()
will return a String []
. FindBugs attempts to detect and suppress
@@ -7578,7 +7573,7 @@
The code here uses File.separator
where a regular expression is required. This will fail on Windows
platforms, where the File.separator
is a backslash, which is interpreted in a
-regular expression as an escape character. Amoung other options, you can just use
+regular expression as an escape character. Among other options, you can just use
File.separatorChar=='\\' ? "\\\\" : File.separator
instead of
File.separator
@@ -7662,7 +7657,7 @@
The code invokes hashCode on an array. Calling hashCode on
-an array returns the same value as System.identityHashCode, and ingores
+an array returns the same value as System.identityHashCode, and ignores
the contents and length of the array. If you need a hashCode that
depends on the contents of an array a
,
use java.util.Arrays.hashCode(a)
.
@@ -7710,7 +7705,7 @@
use (low+high) >>> 1
This bug exists in many earlier implementations of binary search and merge sort.
-Martin Buchholz found and fixed it
+Martin Buchholz found and fixed it
in the JDK libraries, and Joshua Bloch
widely
publicized the bug pattern.
@@ -8037,14 +8032,14 @@
Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multithreaded use.
Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the
application. Under 1.4 problems seem to surface less often than under Java 5 where you will probably see
random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(). You may also experience serialization problems. Using an instance field is recommended. For more information on this see Sun Bug #6231579
-and Sun Bug #6178997. For more information on this see JDK Bug #6231579
+and JDK Bug #6178997. Even though the JavaDoc does not contain a hint about it, Calendars are inherently unsafe for multithreaded use.
The detector has found a call to an instance of Calendar that has been obtained via a static
-field. This looks suspicous. For more information on this see Sun Bug #6231579
-and Sun Bug #6178997.
For more information on this see JDK Bug #6231579 +and JDK Bug #6178997.
]]>You may also experience serialization problems.
Using an instance field is recommended.
-For more information on this see Sun Bug #6231579 -and Sun Bug #6178997.
+For more information on this see JDK Bug #6231579 +and JDK Bug #6178997.
]]> @@ -8083,9 +8078,9 @@ As the JavaDoc states, DateFormats are inherently unsafe for multithreaded use. The detector has found a call to an instance of DateFormat that has been obtained via a static -field. This looks suspicous. -For more information on this see Sun Bug #6231579 -and Sun Bug #6178997.
+field. This looks suspicious. +For more information on this see JDK Bug #6231579 +and JDK Bug #6178997.
]]> @@ -8427,7 +8422,7 @@new BigDecimal(0.1)
ã¨æ›¸ãã¨ã€0.1ã¨æ£ç¢ºã«ç‰ã—ã„ BigDecimal (スケールãŒ1ã§ã‚¹ã‚±ãƒ¼ãƒ«ãªã—ã®å€¤ãŒ1) ãŒä½œæˆã•ã‚Œã‚‹ã¨æ€ã†ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“ãŒã€
実際ã«ã¯0.1000000000000000055511151231257827021181583404541015625ã¨ç‰ã—ããªã‚Šã¾ã™ã€‚
@@ -2157,7 +2157,7 @@
FindBugs ã¯ã€HRS ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’æ´¾é£ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ HRS を心é…ã™ã‚‹ãªã‚‰ã€å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2201,12 +2201,12 @@FindBugs ã¯ã€HRS ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’見ã¤ã‘ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ HRS を心é…ã™ã‚‹ãªã‚‰ã€å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2223,7 +2223,7 @@FindBugs ã¯ã€ç›¸å¯¾ãƒ‘ストラãƒãƒ¼ã‚µãƒ«ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’見ã¤ã‘ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ 相対パストラãƒãƒ¼ã‚µãƒ«ã‚’心é…ã™ã‚‹ãªã‚‰ã€å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2240,7 +2240,7 @@FindBugs ã¯ã€ç›¸å¯¾ãƒ‘ストラãƒãƒ¼ã‚µãƒ«ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’見ã¤ã‘ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ 相対パストラãƒãƒ¼ã‚µãƒ«ã‚’心é…ã™ã‚‹ãªã‚‰ã€å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2252,12 +2252,12 @@FindBugs ã¯ã€XSS ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’見ã¤ã‘ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ XSS を心é…ã™ã‚‹ãªã‚‰ã€å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2270,13 +2270,13 @@HttpServletResponse.sendError
を使用ã—㦠HTTP パラメータを直接書ã込んã§ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã‚µãƒ¼ãƒ–レットã®ã‚¨ãƒ©ãƒ¼ãƒšãƒ¼ã‚¸ã« HttpServletResponse.sendError
を使用ã—㦠HTTP パラメータを直接書ã込んã§ã„ã¾ã™ã€‚
ä¿¡é ¼ã§ããªã„入力を返ã™ã“ã¨ã¯åå°„åž‹ XSS(クãƒã‚¹ã‚µã‚¤ãƒˆã‚¹ã‚¯ãƒªãƒ—ティング) 脆弱性をå¯èƒ½ã«ã—ã¾ã™ã€‚FindBugs ã¯ã€XSS ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’見ã¤ã‘ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ XSS を心é…ã™ã‚‹ãªã‚‰ã€å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2289,12 +2289,12 @@FindBugs ã¯ã€XSS ã®æœ€ã‚‚露骨ã§è‡ªæ˜Žãªã‚±ãƒ¼ã‚¹ã ã‘を探ã—ã¾ã™ã€‚ -FindBugs ãŒä½•ã‹ã‚’発見ã—ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ +FindBugs ãŒä½•ã‹ã‚’見ã¤ã‘ãŸãªã‚‰ã»ã¼é–“é•ã„ãªã FindBugs ãŒå ±å‘Šã—ãªã„より多ãã®è„†å¼±æ€§ãŒã‚ã‚‹ã§ã—ょã†ã€‚ XSS ã«é–¢ã—ã¦å¿ƒé…ã—ã¦ã„ã‚‹ãªã‚‰å•†ç”¨ã®é™çš„解æžãƒ„ールã‹ãƒšãƒãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ãƒ†ã‚¹ãƒˆãƒ„ールã®ä½¿ç”¨ã‚’真剣ã«æ¤œè¨Žã™ã‚‹ã¹ãã§ã™ã€‚
]]> @@ -2374,7 +2374,7 @@putNextEntry
メソッドを呼ã³å‡ºã—ã¦ã€closeEntry
メソッドをã™ãã«ã‚’呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ putNextEntry
メソッドを呼ã³å‡ºã—ã¦ã€closeEntry
メソッドをã™ãã«ã‚’呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚
ã“ã‚Œã¯ç©ºã® ZIP ファイルエントリã«ãªã‚Šã¾ã™ã€‚
エントリデータ㯠putNextEntry
メソッド㨠closeEntry
メソッドã®å‘¼ã³å‡ºã—ã®é–“㧠ZIP ファイルã«æ›¸ã込むã¹ãã§ã™ã€‚
@@ -2545,7 +2545,7 @@
putNextEntry
メソッドを呼ã³å‡ºã—ã¦ã€ closeEntry
メソッドをã™ãã«å‘¼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ putNextEntry
メソッドを呼ã³å‡ºã—ã¦ã€ closeEntry
メソッドをã™ãã«å‘¼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚
ã“ã‚Œã¯ç©ºã® JAR ファイルエントリã«ãªã‚Šã¾ã™ã€‚
エントリデータ㯠putNextEntry
メソッド㨠closeEntry
メソッドã®å‘¼ã³å‡ºã—ã®é–“㧠JAR ファイルã«æ›¸ã込むã¹ãã§ã™ã€‚
@@ -2750,7 +2750,7 @@
Math.min(0, Math.max(100, value))
ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’使用ã—ã¦å¢ƒç•Œå€¤ã‚’制é™ã—よã†ã¨ã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ Math.min(0, Math.max(100, value))
ã®ã‚ˆã†ãªæ§‹æ–‡ã‚’使用ã—ã¦å¢ƒç•Œå€¤ã‚’制é™ã—よã†ã¨ã—ã¦ã„ã¾ã™ã€‚
ã—ã‹ã—ãªãŒã‚‰ã€å®šæ•°ã®é †åºãŒé–“é•ã£ã¦ã„ã¾ã™ã€‚ Math.min(100, Math.max(0, value))
ã¨ã™ã¹ãã§ã™ã€‚
çµæžœã¨ã—ã¦ã“ã®ã‚³ãƒ¼ãƒ‰ã¯å¸¸ã«åŒã˜çµæžœ (もã—値㌠NaN ãªã‚‰ NaN) を作り出ã—ã¾ã™ã€‚
@@ -3205,7 +3205,7 @@
PreparedStatement
を作æˆã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯å®šæ•°ã§ãªã„æ–‡å—列ã‹ã‚‰ SQL ã® PreparedStatement
を作æˆã—ã¦ã„ã¾ã™ã€‚
ユーザã‹ã‚‰ã®ãƒã‚§ãƒƒã‚¯ã•ã‚Œã¦ã„ãªã„汚染ã•ã‚ŒãŸãƒ‡ãƒ¼ã‚¿ãŒã“ã®æ–‡å—列を作る際ã«ä½¿ã‚れるãªã‚‰ã€PreparedStatement
ã§äºˆæƒ³å¤–ã§æœ›ã¾ã—ããªã„何ã‹ã‚’ã™ã‚‹ãŸã‚ã« SQL インジェクションãŒä½¿ã‚れるå¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚
]]>
@@ -3474,7 +3474,7 @@
compareTo
ã¾ãŸã¯ compare
メソッドã®æˆ»ã‚Šå€¤ã‚’無効ã«ã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ compareTo
ã¾ãŸã¯ compare
メソッドã®æˆ»ã‚Šå€¤ã‚’無効ã«ã—ã¦ã„ã¾ã™ã€‚
ã“ã‚Œã¯ç–‘ã‚ã—ã„ã‹ãƒãƒƒãƒ‰ãƒ—ãƒã‚°ãƒ©ãƒŸãƒ³ã‚°ãƒ—ラクティスã§ã™ã€‚戻り値㌠Integer.MIN_VALUE ãªã®ã§ã€æˆ»ã‚Šå€¤ã‚’無効ã«ã™ã‚‹ã“ã¨ã¯çµæžœã®ç¬¦å·ã‚’無効ã«ã—ã¾ã›ã‚“。
çµæžœã‚’無効ã«ã™ã‚‹ã®ã§ã¯ãªãオペランドã®é †åºã‚’逆ã«ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã€åŒã˜æ„図ã—ãŸçµæžœã‚’å¾—ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
@@ -3820,7 +3820,7 @@
java.lang.String
オブジェクトを比較ã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯å‚ç…§ç‰ä¾¡æ€§ã®ãŸã‚ã« == ã‚„ != を使用ã—㦠java.lang.String
オブジェクトを比較ã—ã¦ã„ã¾ã™ã€‚
両方ã®æ–‡å—列ãŒã‚½ãƒ¼ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«ã®å®šæ•°ã‹ã€String.intern()
を使用ã—ã¦æ£æº–化ã•ã‚Œã¦ã„ãªã„ã‹ãŽã‚Šã€åŒã˜æ–‡å—列ã¯2ã¤ã®ç•°ãªã‚‹ String オブジェクトã«ã‚ˆã£ã¦è¡¨ã•ã‚Œã‚‹ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。
ãã®ä»£ã‚ã‚Šã« equals(Object)
メソッドを使用ã™ã‚‹ã“ã¨ã‚’検討ã—ã¦ãã ã•ã„。
@@ -3834,7 +3834,7 @@
java.lang.String
パラメータを比較ã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯å‚ç…§ç‰ä¾¡æ€§ã®ãŸã‚ã« == ã‚„ != を使用ã—㦠java.lang.String
パラメータを比較ã—ã¦ã„ã¾ã™ã€‚
æ–‡å—列定数ã¾ãŸã¯æ£æº–化ã•ã‚ŒãŸæ–‡å—列ã ã‘をメソッドã«æ¸¡ã™ã“ã¨ã‚’呼ã³å‡ºã—å…ƒã«è¦æ±‚ã™ã‚‹ã“ã¨ã¯å¿…è¦ä»¥ä¸Šã«è„†å¼±ã§æ¸¬å®šå¯èƒ½ãªæ€§èƒ½ã®å‘上をもãŸã‚‰ã—ã¾ã›ã‚“。
ãã®ä»£ã‚ã‚Šã« equals(Object)
メソッドを使用ã™ã‚‹ã“ã¨ã‚’検討ã—ã¦ãã ã•ã„。
@@ -3897,7 +3897,7 @@
ã“ã®ãƒã‚°ãƒ‘ターンã«åˆè‡´ã™ã‚‹å…¸åž‹çš„ãªãƒã‚°ã¯ã€ã‚¹ãƒ¬ãƒƒãƒ‰ã‚»ãƒ¼ãƒ•ã‚’æ„図ã—ãŸã‚¯ãƒ©ã‚¹ã§ãƒ¡ã‚½ãƒƒãƒ‰ã‚’åŒæœŸåŒ–ã•ã›ã‚‹ã“ã¨ã‚’忘れã¦ã„ã‚‹ã“ã¨ã§ã™ã€‚
@@ -3963,7 +3963,7 @@
java.lang.Object.wait()
ã®å‘¼ã³å‡ºã—ãŒã‚ã‚Šã¾ã™ã€‚
-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€wait
メソッドを呼ã³å‡ºã™å‰ã«å¾…æ©Ÿã™ã‚‹ã¤ã‚‚ã‚Šã ã£ãŸæ¡ä»¶ãŒæ—¢ã«æº€ãŸã•ã‚Œã¦ã„ãªã„ã“ã¨ã‚’確ã‹ã‚ã‚‹ã¹ãã§ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ wait
メソッドを呼ã³å‡ºã™å‰ã«å¾…æ©Ÿã™ã‚‹ã¤ã‚‚ã‚Šã ã£ãŸæ¡ä»¶ãŒæ—¢ã«æº€ãŸã•ã‚Œã¦ã„ãªã„ã“ã¨ã‚’確ã‹ã‚ã‚‹ã¹ãã§ã™ã€‚
ã©ã‚“ãªå‰ã®é€šçŸ¥ã‚‚無視ã•ã‚Œã¾ã™ã€‚
]]>
@@ -4214,7 +4214,7 @@
private static String LOCK = "LOCK"; @@ -4265,7 +4265,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ˜Žã‚‰ã‹ã«å…±æœ‰ã•ã‚Œã¦ã„ãªã„@@ -4550,7 +4550,7 @@Integer
ã®ã‚ˆã†ãªãƒœã‚¯ã‚·ãƒ³ã‚°ã•ã‚ŒãŸãƒ—リミティブ型ã§åŒæœŸåŒ–ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ˜Žã‚‰ã‹ã«å…±æœ‰ã•ã‚Œã¦ã„ãªã„Integer
ã®ã‚ˆã†ãªãƒœã‚¯ã‚·ãƒ³ã‚°ã•ã‚ŒãŸãƒ—リミティブ型ã§åŒæœŸåŒ–ã—ã¦ã„ã¾ã™ã€‚private static final Integer fileLock = new Integer(1); @@ -4275,7 +4275,7 @@ }-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ fileLock を以下ã®ã‚ˆã†ã«å®£è¨€ã™ã‚‹ã¨ã‚ˆã‚Šè‰¯ããªã‚Šã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ fileLock を以下ã®ã‚ˆã†ã«å®£è¨€ã™ã‚‹ã¨ã‚ˆã‚Šè‰¯ããªã‚Šã¾ã™ã€‚
private static final Object fileLock = new Object(); @@ -4294,7 +4294,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€Integer ã®ã‚ˆã†ãªãƒœã‚¯ã‚·ãƒ³ã‚°ã•ã‚ŒãŸãƒ—リミティブ型ã®å®šæ•°ã§åŒæœŸåŒ–ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯Integer ã®ã‚ˆã†ãªãƒœã‚¯ã‚·ãƒ³ã‚°ã•ã‚ŒãŸãƒ—リミティブ型ã®å®šæ•°ã§åŒæœŸåŒ–ã—ã¦ã„ã¾ã™ã€‚@@ -4515,7 +4515,7 @@ ã“ã® final static フィールドã¯é…列をå‚ç…§ã—ã¦ã„ã‚‹ã®ã§ã€æ‚ªæ„ã®ã‚るコードやå¶ç„¶åˆ¥ã®ãƒ‘ッケージã«ã‚ˆã£ã¦ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ã€‚ -ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€é…列ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„を自由ã«å¤‰æ›´ã§ãã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯é…列ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„を自由ã«å¤‰æ›´ã§ãã¾ã™ã€‚ ]]>private static Integer count = 0; @@ -4473,7 +4473,7 @@ ã“ã® final static フィールド㯠Hashtable ã‚’å‚ç…§ã—ã¦ã„ã‚‹ã®ã§ã€æ‚ªæ„ã®ã‚るコードやå¶ç„¶åˆ¥ã®ãƒ‘ッケージã«ã‚ˆã£ã¦ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ã€‚ -ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€Hashtable ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„を自由ã«å¤‰æ›´ã§ãã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯Hashtable ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„を自由ã«å¤‰æ›´ã§ãã¾ã™ã€‚ ]]>
String.toLowerCase()
ã®æˆ»ã‚Šå€¤ã‚’無視ã™ã‚‹ã‚ˆã†ãªï¼‰ã€‚
@@ -5717,7 +5717,7 @@
プãƒã‚°ãƒ©ãƒžã¯ã€trim
メソッド㌠dateString
ã«ã‚ˆã£ã¦å‚ç…§ã•ã‚Œã‚‹ String オブジェクトãŒæ›´æ–°ã•ã‚Œã‚‹ã¨æ€ã£ã¦ã„ã¾ã™ã€‚
ã—ã‹ã—ã€String オブジェクトã¯ä¸å¤‰ã§ã€trim
メソッドãŒæ–°ã—ã„ String オブジェクトを返ã™ã®ã«ç„¡è¦–ã—ã¦ã„ã¾ã™ã€‚
-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ä»¥ä¸‹ã®ã‚ˆã†ã«ä¿®æ£ã™ã‚‹ã¹ãã§ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ä¿®æ£ã™ã‚‹ã¹ãã§ã™ã€‚
String dateString = getHeaderField(name); @@ -5748,7 +5748,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€compareTo ã¾ãŸã¯ compare メソッドを呼ã³å‡ºã—ã¦ã€æˆ»ã‚Šå€¤ãŒç‰¹å®šã®å€¤ï¼ˆãŸã¨ãˆã°1ã¾ãŸã¯-1) ãªã®ã‹ç¢ºã‹ã‚ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯compareTo ã¾ãŸã¯ compare メソッドを呼ã³å‡ºã—ã¦ã€æˆ»ã‚Šå€¤ãŒç‰¹å®šã®å€¤ï¼ˆãŸã¨ãˆã°1ã¾ãŸã¯-1) ãªã®ã‹ç¢ºã‹ã‚ã¦ã„ã¾ã™ã€‚ ã“れらã®ãƒ¡ã‚½ãƒƒãƒ‰ã‚’呼ã³å‡ºã™ã¨ãã¯ç‰¹å®šã®ã‚¼ãƒä»¥å¤–ã®å€¤ã§ã¯ãªãã€çµæžœã®ç¬¦å·ã ã‘ã‚’ãƒã‚§ãƒƒã‚¯ã™ã‚‹ã¹ãã§ã™ã€‚ 多数ã¾ãŸã¯å¤§éƒ¨åˆ†ã® compareTo ã¨æ¯”較メソッドã¯-1ã€0ã¾ãŸã¯1ã‚’è¿”ã—ã¾ã™ãŒã€ã„ãã¤ã‹ã¯ä»–ã®å€¤ã‚’è¿”ã—ã¾ã™ã€‚ @@ -5762,7 +5762,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ä¾‹å¤– (ã¾ãŸã¯ã‚¨ãƒ©ãƒ¼) オブジェクトを作æˆã—ã¦ã„ã¾ã™ãŒã€ä½•ã‚‚ã—ã¦ã„ã¾ã›ã‚“。
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ä¾‹å¤– (ã¾ãŸã¯ã‚¨ãƒ©ãƒ¼) オブジェクトを作æˆã—ã¦ã„ã¾ã™ãŒã€ä½•ã‚‚ã—ã¦ã„ã¾ã›ã‚“。
ãŸã¨ãˆã°ä»¥ä¸‹ã®ã‚ˆã†ãªã‚³ãƒ¼ãƒ‰ã§ã™ã€‚@@ -6586,7 +6586,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€java.util.Random
オブジェクトを作æˆã—ã¦1ã¤ã®ä¹±æ•°ã‚’生æˆã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã—ã¦æ¨ã¦ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯java.util.Random
オブジェクトを作æˆã—ã¦1ã¤ã®ä¹±æ•°ã‚’生æˆã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã—ã¦æ¨ã¦ã¦ã„ã¾ã™ã€‚ ã“ã‚Œã¯ã‚ã¾ã‚Šè‰¯ããªã„å“質ã®ä¹±æ•°ã‚’作り出ã—ã€åŠ¹çŽ‡ãŒæ‚ªã„ã§ã™ã€‚ ã§ãã‚Œã°ã€Random
オブジェクトを1ã¤ã ã‘作æˆã—ã¦ä¿å˜ã•ã‚Œã‚‹ã‚ˆã†ã«ã‚³ãƒ¼ãƒ‰ã‚’書ãç›´ã—ã¦ãã ã•ã„。 ãã—ã¦ã€æ¯Žå›žæ–°ã—ã„乱数ã¯æ—¢å˜ã®Random
オブジェクトを呼ã³å‡ºã—ã¦å–å¾—ã™ã‚‹ã“ã¨ãŒå¿…è¦ã§ã™ã€‚ @@ -6605,7 +6605,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ç¬¦å·ä»˜ãæ•´æ•°ã®ä¹±æ•°ã‚’生æˆã—ã¦çµ¶å¯¾å€¤ã‚’計算ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ç¬¦å·ä»˜ãæ•´æ•°ã®ä¹±æ•°ã‚’生æˆã—ã¦çµ¶å¯¾å€¤ã‚’計算ã—ã¦ã„ã¾ã™ã€‚ 乱数ジェãƒãƒ¬ãƒ¼ã‚¿ã§è¿”ã•ã‚Œã‚‹æ•°ãŒInteger.MIN_VALUE
ãªã‚‰çµæžœã¯åŒæ§˜ã«è² ã§ã™ (Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
ãªã®ã§)。 (åŒã˜å•é¡Œã¯ long 値ã§ã‚‚åŒæ§˜ã«èµ·ãã¾ã™)。 @@ -6619,7 +6619,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ã‚’生æˆã—ã¦çµ¶å¯¾å€¤ã‚’計算ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ã‚’生æˆã—ã¦çµ¶å¯¾å€¤ã‚’計算ã—ã¦ã„ã¾ã™ã€‚ ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ãŒ@@ -6693,7 +6693,7 @@Integer.MIN_VALUE
ãªã‚‰çµæžœã¯åŒæ§˜ã«è² ã§ã™ (Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
ãªã®ã§)。@@ -6649,7 +6649,7 @@
-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ã‚’計算ã—ã¦åˆ¥ã®å€¤ã‚’法ã¨ã™ã‚‹å‰°ä½™ã‚’計算ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ã‚’計算ã—ã¦åˆ¥ã®å€¤ã‚’法ã¨ã™ã‚‹å‰°ä½™ã‚’計算ã—ã¦ã„ã¾ã™ã€‚ ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ã¯è² ã«ãªã‚Šã€å‰°ä½™æ¼”ç®—ã®çµæžœã‚‚è² ãªã‚Šã¾ã™ã€‚@@ -6668,7 +6668,7 @@
]]>-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€è² ã§ãªã„ã“ã¨ãŒä¿è¨¼ã•ã‚Œã¦ã„る値ã¨è² ã®å®šæ•°ã¾ãŸã¯ã‚¼ãƒã¨ã‚’比較ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯è² ã§ãªã„ã“ã¨ãŒä¿è¨¼ã•ã‚Œã¦ã„る値ã¨è² ã®å®šæ•°ã¾ãŸã¯ã‚¼ãƒã¨ã‚’比較ã—ã¦ã„ã¾ã™ã€‚-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€int 値㨠int 値ã¨ã—ã¦è¡¨ã•ã‚Œã‚‹å€¤ã®ç¯„囲外㮠long 定数を比較ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯int 値㨠int 値ã¨ã—ã¦è¡¨ã•ã‚Œã‚‹å€¤ã®ç¯„囲外㮠long 定数を比較ã—ã¦ã„ã¾ã™ã€‚ ã“ã®æ¯”較ã¯ç„¡æ„味ã§ã€ãŠãらãé–“é•ã£ã¦ã„ã¾ã™ã€‚ ]]> @@ -6820,31 +6820,24 @@-ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ã€((event.detail & SWT.SELECTED) > 0)
ã®ã‚ˆã†ãªå¼ã‚’比較ã—ã¦ã„ã¾ã™ã€‚ -ビット演算をより大ãã„演算åã§æ¯”較ã™ã‚‹ã“ã¨ã¯ã€äºˆæƒ³å¤–ã®çµæžœ (ã‚‚ã¡ã‚ã‚“ã€SWT.SELECTED
ã®å€¤ã«ã‚ˆã‚‹) ã®åŽŸå› ã«ãªã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚ -SWT.SELECTED
ãŒè² æ•°ã§ã‚ã‚‹ãªã‚‰ã€ã“ã‚Œã¯ãƒã‚°ã®å€™è£œã§ã™ã€‚ -SWT.SELECTED
ãŒè² ã§ã¯ãªã„ã¨ã—ã¦ã‚‚ã€'> 0' ã®ä»£ã‚ã‚Šã« '!= 0' を使用ã™ã‚‹ã“ã¨ã¯è‰¯ã„プラクティスã¨æ€ã‚ã‚Œã¾ã™ã€‚ - --Boris Bokowski +ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ã€
]]>((event.detail & SWT.SELECTED) > 0)
ã®ã‚ˆã†ãªå¼ã§æ¯”較ã—ã¦ã„ã¾ã™ã€‚ +ビット演算をより大ãã„演算åã§æ¯”較ã™ã‚‹ã“ã¨ã¯ã€äºˆæƒ³å¤–ã®çµæžœ (ã‚‚ã¡ã‚ã‚“ã€SWT.SELECTED ã®å€¤ã«ã‚ˆã‚‹) ã®åŽŸå› ã«ãªã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚ +SWT.SELECTED ãŒè² æ•°ã§ã‚ã‚‹ãªã‚‰ã€ã“ã‚Œã¯ãƒã‚°ã®å€™è£œã§ã™ã€‚ +SWT.SELECTED ãŒè² ã§ã¯ãªã„ã¨ã—ã¦ã‚‚ã€'> 0' ã®ä»£ã‚ã‚Šã« '!= 0' を使用ã™ã‚‹ã“ã¨ãŒè‰¯ã„プラクティスã§ã‚ã‚‹ã¨æ€ã‚ã‚Œã¾ã™ã€‚
((event.detail & SWT.SELECTED) > 0)
ã®ã‚ˆã†ãªå¼ã‚’比較ã—ã¦ã„ã¾ã™ã€‚
-ビット演算をより大ãã„演算åã§æ¯”較ã™ã‚‹ã“ã¨ã¯ã€äºˆæƒ³å¤–ã®çµæžœ (ã‚‚ã¡ã‚ã‚“ã€SWT.SELECTED
ã®å€¤ã«ã‚ˆã‚‹) ã®åŽŸå› ã«ãªã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚
-SWT.SELECTED
ãŒè² æ•°ã§ã‚ã‚‹ãªã‚‰ã€ã“ã‚Œã¯ãƒã‚°ã®å€™è£œã§ã™ã€‚
-SWT.SELECTED
ãŒè² ã§ã¯ãªã„ã¨ã—ã¦ã‚‚ã€'> 0' ã®ä»£ã‚ã‚Šã« '!= 0' を使用ã™ã‚‹ã“ã¨ã¯è‰¯ã„プラクティスã¨æ€ã‚ã‚Œã¾ã™ã€‚
-
-
-Boris Bokowski
+ ((val & CONSTANT) > 0)
ã®ã‚ˆã†ãªãƒ“ット演算å¼ã§æ¯”較ã—ã¦ã„ã¾ã™ã€‚
+ビット演算をより大ãã„演算åã§æ¯”較ã™ã‚‹ã“ã¨ã¯ã€äºˆæƒ³å¤–ã®çµæžœã®åŽŸå› ã«ãªã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ã€‚比較ã¯æœŸå¾…ã—ãŸã‚ˆã†ã«ãªã‚Šã¾ã›ã‚“。
+'> 0' ã®ä»£ã‚ã‚Šã« '!= 0' を使用ã™ã‚‹ã“ã¨ãŒè‰¯ã„プラクティスã§ã™ã€‚
(e & 0)
å½¢å¼ã®å¼ã‚’0ã¨æ¯”較ã—ã¦ã„ã¾ã™ã€‚ãã‚Œã¯ã€å¸¸ã«ç‰ä¾¡ã§ã‚ã‚‹ã“ã¨ã‚’比較ã—ã¾ã™ã€‚è«–ç†ã‚¨ãƒ©ãƒ¼ã‹ã‚¿ã‚¤ãƒ—ミスã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。
]]>
(e | C)
å½¢å¼ã®å¼ã‚’ D
ã¨æ¯”較ã—ã¦ã„ã¾ã™ã€‚
-定数 C ã®ç‰¹å®šã®å€¤ã¨ D ã®ãŸã‚ã«å¸¸ã«ç‰ã—ããªã„ã“ã¨ã‚’比較ã—ã¾ã™ã€‚è«–ç†ã‚¨ãƒ©ãƒ¼ã‹ã‚¿ã‚¤ãƒ—ミスã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。
+ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ã€(e | C)
å½¢å¼ã®å¼ã‚’ D ã¨æ¯”較ã—ã¦ã„ã¾ã™ã€‚
+定数 C ã¨ã€€D ã®ç‰¹å®šã®å€¤ã®ãŸã‚ã«å¸¸ã«ç‰ã—ããªã„ã“ã¨ã‚’比較ã—ã¾ã™ã€‚è«–ç†ã‚¨ãƒ©ãƒ¼ã‹ã‚¿ã‚¤ãƒ—ミスã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。
典型的ã«ã€ã“ã®ãƒã‚°ã¯ã€ãƒ“ットセットã§å¸°å±žé–¢ä¿‚ã®ãƒ†ã‚¹ãƒˆã‚’実行ã—ãŸã„コードã§ç™ºç”Ÿã—ã¾ã™ã€‚ ã—ã‹ã—ã€ãƒ“ット論ç†ç©æ¼”ç®—å ("&") ã®ä»£ã‚ã‚Šã«ãƒ“ット論ç†å’Œæ¼”ç®—å ("|") を使用ã—ã¦ã„ã¾ã™ã€‚ +
+
+ã“ã†ã—ãŸãƒã‚°ã¯ (e & (A | B)) == C
ãŒæ„図ã•ã‚Œã¦ã„ã‚‹é–“ã« ((e & A) | B) == C
ã®ã‚ˆã†ã«è§£æžã•ã‚Œã‚‹ (e & A | B) == C
ã®ã‚ˆã†ãªå¼ã§ç¾ã‚Œã‚‹ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。
myString.indexOf(".")
 ã®ä»£ã‚ã‚Šã« myString.indexOf('.')
を呼ã³å‡ºã—ã¾ã™ã€‚
]]>
@@ -7141,7 +7137,7 @@
myString.lastIndexOf(".")
 ã®ä»£ã‚ã‚Šã« myString.lastIndexOf('.')
を呼ã³å‡ºã—ã¾ã™ã€‚
]]>
@@ -7581,7 +7577,7 @@
if (x == Double.NaN)
)。
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æµ®å‹•å°æ•°ç‚¹ãŒç‰¹åˆ¥ãªéžæ•°å€¤ã¨ç‰ä¾¡ã§ã‚ã‚‹ã‹ç¢ºã‹ã‚ã¦ã„ã¾ã™ (ãŸã¨ãˆã° if (x == Double.NaN)
)。
ã—ã‹ã—ãªãŒã‚‰ã€NaN
ã®ç‰¹åˆ¥ãªæ„味ã®ãŸã‚ã€å€¤ã¯ NaN
ã¨ç‰ä¾¡ã§ã¯ã‚ã‚Šã¾ã›ã‚“。
ã—ãŸãŒã£ã¦ã€x == Double.NaN
ã¯å¸¸ã« false ã¨è©•ä¾¡ã—ã¾ã™ã€‚
x
ã¨ã„ã†å€¤ãŒç‰¹åˆ¥ãªéžæ•°å€¤ã§ã‚ã‚‹ã‹ã©ã†ã‹ç¢ºã‹ã‚ã‚‹ãŸã‚ã«ã¯ Double.isNaN(x)
を使用ã—ã¾ã™ (ã¾ãŸã¯ x
ãŒæµ®å‹•å°æ•°ç‚¹ç²¾åº¦ã§ã‚ã‚‹ãªã‚‰ Float.isNaN(x)
)。
@@ -7774,7 +7770,7 @@
long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; } @@ -7803,7 +7799,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€32ビット int 値を64ビット long 値ã«å¤‰æ›ã—ã¦ã€çµ¶å¯¾æ™‚間値を必è¦ã¨ã™ã‚‹ãƒ¡ã‚½ãƒƒãƒ‰ãƒ‘ラメータã«æ¸¡ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯32ビット int 値を64ビット long 値ã«å¤‰æ›ã—ã¦ã€çµ¶å¯¾æ™‚間値を必è¦ã¨ã™ã‚‹ãƒ¡ã‚½ãƒƒãƒ‰ãƒ‘ラメータã«æ¸¡ã—ã¦ã„ã¾ã™ã€‚ 絶対時間値ã¯ã€ã€Œã‚¨ãƒãƒƒã‚¯ã€ï¼ˆã™ãªã‚ã¡ã€1970å¹´1月1æ—¥ã€00:00:00 GMT)ã¨ã—ã¦ã‚ã‹ã£ã¦ã„る標準的ãªåŸºæº–時間ã‹ã‚‰ã®ãƒŸãƒªç§’æ•°ã§ã™ã€‚
ãŸã¨ãˆã°ã€æ¬¡ã®ãƒ¡ã‚½ãƒƒãƒ‰ (エãƒãƒƒã‚¯ã‹ã‚‰ã®ç§’ã‚’ Date ã¸å¤‰æ›ã™ã‚‹ã“ã¨ã‚’æ„図ã—ãŸï¼‰ ã¯ã²ã©ã壊れã¦ã„ã¾ã™ã€‚ @@ -7834,7 +7830,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ•´æ•°å€¤ã‚’ float 精度浮動å°æ•°ç‚¹ã«å¤‰æ›ã—ã¦ã‹ã‚‰ã€ãã®çµæžœã‚’Math.round()
ã«æ¸¡ã—ã¦å¼•æ•°ã«æœ€ã‚‚è¿‘ã„ int/long ã‚’è¿”ã—ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ•´æ•°å€¤ã‚’ float 精度浮動å°æ•°ç‚¹ã«å¤‰æ›ã—ã¦ã‹ã‚‰ã€ãã®çµæžœã‚’Math.round()
ã«æ¸¡ã—ã¦å¼•æ•°ã«æœ€ã‚‚è¿‘ã„ int/long ã‚’è¿”ã—ã¾ã™ã€‚ æ•´æ•°ã‚’ float ã«å¤‰æ›ã™ã‚‹ã¨å°æ•°éƒ¨ãŒãªã„数値ãŒå¾—られるã®ã§ã€ã“ã®æ¼”ç®—ã¯å¸¸ã«ãƒŽãƒ¼ã‚ªãƒšãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã«ãªã‚Šã¾ã™ã€‚Math.round()
ã«æ¸¡ã•ã‚Œã‚‹å€¤ã‚’生æˆã—ãŸæ¼”ç®—ãŒæµ®å‹•å°æ•°ç‚¹æ¼”算を使用ã—ã¦å®Ÿè¡Œã™ã‚‹ã“ã¨ã‚’æ„図ã—ãŸå¯èƒ½æ€§ãŒé«˜ã„ã§ã™ã€‚ @@ -7848,7 +7844,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ•´æ•°å€¤ (ãŸã¨ãˆã°ã€int ã‚„ long) ã‚’å€ç²¾åº¦æµ®å‹•å°æ•°ç‚¹ã«å¤‰æ›ã—ã¦ã‹ã‚‰ã€ãã®çµæžœã‚’Math.ceil()
ã«æ¸¡ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ•´æ•°å€¤ (ãŸã¨ãˆã°ã€int ã‚„ long) ã‚’å€ç²¾åº¦æµ®å‹•å°æ•°ç‚¹ã«å¤‰æ›ã—ã¦ã‹ã‚‰ã€ãã®çµæžœã‚’Math.ceil()
ã«æ¸¡ã—ã¦ã„ã¾ã™ã€‚ æ•´æ•°ã‚’ double ã«å¤‰æ›ã™ã‚‹ã¨å°æ•°éƒ¨ãŒãªã„数値ãŒå¾—られるã®ã§ã€ã“ã®æ¼”ç®—ã¯å¸¸ã«ãƒŽãƒ¼ã‚ªãƒšãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã«ãªã‚Šã¾ã™ã€‚Math.ceil()
ã«æ¸¡ã•ã‚Œã‚‹å€¤ã‚’生æˆã—ãŸæ¼”ç®—ãŒå€ç²¾åº¦æµ®å‹•å°æ•°ç‚¹æ¼”算を使用ã—ã¦å®Ÿè¡Œã™ã‚‹ã“ã¨ã‚’æ„図ã—ãŸå¯èƒ½æ€§ãŒé«˜ã„ã§ã™ã€‚ @@ -7862,7 +7858,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ æ•´æ•°ã®é™¤ç®—ã®çµæžœã‚’ double ã¾ãŸã¯ float ã«ã‚ャストã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ•´æ•°ã®é™¤ç®—ã®çµæžœã‚’ double ã¾ãŸã¯ float ã«ã‚ャストã—ã¦ã„ã¾ã™ã€‚ æ•´æ•°ã§é™¤ç®—ã‚’ã™ã‚‹ã“ã¨ã¯ã€ã‚¼ãƒã«æœ€ã‚‚è¿‘ã„整数値ã¾ã§çµæžœã‚’切りæ¨ã¦ã¾ã™ã€‚ çµæžœãŒ double ã«ã‚ャストã•ã‚ŒãŸã¨ã„ã†äº‹å®Ÿã¯ã€ã“ã®ç²¾åº¦ãŒç¶æŒã•ã‚Œã‚‹ã¹ãã ã£ãŸã“ã¨ã‚’示唆ã—ã¦ã„ã¾ã™ã€‚ ãŠãらãæ„味ã•ã‚ŒãŸã“ã¨ã¯ã€é™¤ç®—を実行ã™ã‚‹å‰ã«ã‚ªãƒšãƒ©ãƒ³ãƒ‰ã®1ã¤ã¾ãŸã¯ä¸¡æ–¹ã‚’ double ã«ã‚ャストã™ã‚‹ã“ã¨ã§ã—ãŸã€‚
@@ -7887,7 +7883,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€HttpSession ã«éžç›´åˆ—化å¯èƒ½ã‚ªãƒ–ã‚¸ã‚§ã‚¯ãƒˆã‚’æ ¼ç´ã—ã¦ã„ã‚‹ã¨æ€ã‚ã‚Œã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ HttpSession ã«éžç›´åˆ—化å¯èƒ½ã‚ªãƒ–ã‚¸ã‚§ã‚¯ãƒˆã‚’æ ¼ç´ã—ã¦ã„ã‚‹ã¨æ€ã‚ã‚Œã¾ã™ã€‚ ã“ã®ã‚»ãƒƒã‚·ãƒ§ãƒ³ãŒä¸æ´»æ€§åŒ–ã•ã‚Œã‚‹ã‹ç§»è¡Œã—ãŸãªã‚‰ã€ã‚¨ãƒ©ãƒ¼ã‚’æ‹›ãã¾ã™ã€‚ ]]> @@ -7900,7 +7896,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ObjectOutput.writeObject
ã«éžç›´åˆ—化å¯èƒ½ã‚ªãƒ–ジェクトを渡ã—ã¦ã„ã‚‹ã¨æ€ã‚ã‚Œã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ObjectOutput.writeObject
ã«éžç›´åˆ—化å¯èƒ½ã‚ªãƒ–ジェクトを渡ã—ã¦ã„ã‚‹ã¨æ€ã‚ã‚Œã¾ã™ã€‚ ã“ã®ã‚ªãƒ–ジェクトãŒæœ¬å½“ã«éžç›´åˆ—化å¯èƒ½ãªã‚‰ã€ã‚¨ãƒ©ãƒ¼ã‚’æ‹›ãã¾ã™ã€‚ ]]> @@ -7913,7 +7909,7 @@-ã“ã®æ›¸å¼æ–‡å—列ã¯ã€å‰ã®æ›¸å¼æŒ‡ç¤ºåã®å¼•æ•°ãŒå†åˆ©ç”¨ã•ã‚Œã‚‹ã‚ˆã†ã«ã™ã‚‹ãŸã‚ã«ã€Œç›¸å¯¾ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ("<")ã€ã‚’指定ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®æ›¸å¼æ–‡å—列ã¯å‰ã®æ›¸å¼æŒ‡ç¤ºåã®å¼•æ•°ãŒå†åˆ©ç”¨ã•ã‚Œã‚‹ã‚ˆã†ã«ã™ã‚‹ãŸã‚ã«ã€Œç›¸å¯¾ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ ("<")ã€ã‚’指定ã—ã¦ã„ã¾ã™ã€‚ ã—ã‹ã—ãªãŒã‚‰ã€å‰ã®å¼•æ•°ãŒã‚ã‚Šã¾ã›ã‚“。 ãŸã¨ãˆã°ã€formatter.format("%<s %s", "a", "b")
ãŒå®Ÿè¡Œã•ã‚Œã‚‹ã¨ MissingFormatArgumentException をスãƒãƒ¼ã—ã¾ã™ã€‚ @@ -7927,7 +7923,7 @@-ã“ã®æ›¸å¼æ–‡å—列ã«ã¯æ”¹è¡Œæ–‡å— (\n) ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ +ã“ã®æ›¸å¼æ–‡å—列ã¯æ”¹è¡Œæ–‡å— (\n) ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ã€‚ 一般的ã«æ›¸å¼æ–‡å—列ã«ã¯ %n を使用ã™ã‚‹ã“ã¨ãŒã‚ˆã‚Šæœ›ã¾ã—ã„ã§ã™ã€‚%n ã¯ã€ãƒ—ラットホーム特有ã®è¡Œã‚»ãƒ‘レータを作り出ã—ã¾ã™ã€‚ ]]> @@ -7935,12 +7931,12 @@
String.format("%d", "1")
ã¯ã€æ–‡å—列 "1" ãŒæ›¸å¼æŒ‡ç¤ºå "%d" ã¨äº’æ›æ€§ãŒãªã„ã®ã§ä¾‹å¤–を生æˆã—ã¾ã™ã€‚
]]>
@@ -8085,7 +8081,7 @@
List
ã€Set
ã€Map
)。
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯Collection を抽象コレクションã«ã‚ャストã—ã¦ã„ã¾ã™ (ãŸã¨ãˆã° List
ã€Set
ã€Map
)。
オブジェクトãŒã‚ャストã™ã‚‹åž‹ã§ã‚ã‚‹ã¨ã„ã†ã“ã¨ãŒä¿è¨¼ã•ã‚Œã¦ã„ã‚‹ã“ã¨ã‚’確èªã—ã¦ãã ã•ã„。
å¿…è¦ã¨ã™ã‚‹ã‚³ãƒ¬ã‚¯ã‚·ãƒ§ãƒ³ã®å復処ç†ãŒã§ãã‚‹ãªã‚‰ Set ã¾ãŸã¯ List ã«ã‚ャストã™ã‚‹å¿…è¦ã¯ã‚ã‚Šã¾ã›ã‚“。
@@ -8140,7 +8136,7 @@
Object[]
より特定ã®åž‹ã®ã‚³ãƒ¬ã‚¯ã‚·ãƒ§ãƒ³ã§ toArray
メソッドを呼ã³å‡ºã™çµæžœã‚’ã‚ャストã—ã¦ã„ã¾ã™ã€‚
+ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ä»¥ä¸‹ã®ã‚ˆã†ã«ã€Object[]
より特定ã®åž‹ã®ã‚³ãƒ¬ã‚¯ã‚·ãƒ§ãƒ³ã§ toArray
メソッドを呼ã³å‡ºã™çµæžœã‚’ã‚ャストã—ã¦ã„ã¾ã™ã€‚
String[] getAsArray(Collection<String> c) { @@ -8233,7 +8229,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ãƒ¡ã‚½ãƒƒãƒ‰ã®æˆ»ã‚Šå€¤ã®æœªç¢ºèªã®ã‚ャストを実行ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ãƒ¡ã‚½ãƒƒãƒ‰ã®æˆ»ã‚Šå€¤ã®æœªç¢ºèªã®ã‚ャストを実行ã—ã¦ã„ã¾ã™ã€‚ コードã¯ã€ã‚ャストãŒå®‰å…¨ã§ã‚ã‚‹ã“ã¨ãŒä¿è¨¼ã•ã‚Œã‚‹ã‚ˆã†ã«ãƒ¡ã‚½ãƒƒãƒ‰ã‚’呼ã³å‡ºã—ã¦ã„ã‚‹ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“ãŒã€FindBugs ã¯ã‚ャストãŒå®‰å…¨ã§ã‚ã‚‹ã“ã¨ã‚’検証ã§ãã¾ã›ã‚“。 プãƒã‚°ãƒ©ãƒ ã®ãƒã‚¸ãƒƒã‚¯ãŒã“ã®ã‚ャストãŒå¤±æ•—ã—ãªã„ã“ã¨ã‚’確実ã«ç¢ºèªã—ã¦ãã ã•ã„。 @@ -8281,7 +8277,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ£è¦è¡¨ç¾ã®æ§‹æ–‡ã«ã‚ˆã‚‹ã¨ç„¡åŠ¹ã§ã‚ã‚‹æ£è¦è¡¨ç¾ã‚’使用ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ£è¦è¡¨ç¾ã®æ§‹æ–‡ã«ã‚ˆã‚‹ã¨ç„¡åŠ¹ã§ã‚ã‚‹æ£è¦è¡¨ç¾ã‚’使用ã—ã¦ã„ã¾ã™ã€‚ ã“ã®æ–‡ãŒå®Ÿè¡Œã•ã‚Œã‚‹ã¨ã PatternSyntaxException をスãƒãƒ¼ã—ã¾ã™ã€‚ ]]> @@ -8294,7 +8290,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ£è¦è¡¨ç¾ãŒå¿…è¦ãªå ´æ‰€ã§ã€File.separator
を使用ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ£è¦è¡¨ç¾ãŒå¿…è¦ãªå ´æ‰€ã§ã€File.separator
を使用ã—ã¦ã„ã¾ã™ã€‚ ã“ã‚Œã¯File.separator
ãŒãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã‚ã‚‹ Windows プラットホームã§ã¯å¤±æ•—ã—ã¾ã™ã€‚ ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã¯æ£è¦è¡¨ç¾ã§ã¯ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—æ–‡å—ã¨ã—ã¦è§£é‡ˆã•ã‚Œã¾ã™ã€‚ ãã®ä»–ã®é¸æŠžè‚¢ã¨ã—ã¦ã¯ã€File.separator
ã®ä»£ã‚ã‚Šã«File.separatorChar=='\\' ? "\\\\" : File.separator
を使用ã§ãã¾ã™ã€‚ @@ -8309,7 +8305,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ã‚¤ãƒ³ã‚¯ãƒªãƒ¡ãƒ³ãƒˆæ¼”ç®— (ãŸã¨ãˆã°ã€i++
) を実行ã—ã¦ã™ãã«ä¸Šæ›¸ãã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã‚¤ãƒ³ã‚¯ãƒªãƒ¡ãƒ³ãƒˆæ¼”ç®— (ãŸã¨ãˆã°ã€i++
) を実行ã—ã¦ã™ãã«ä¸Šæ›¸ãã—ã¦ã„ã¾ã™ã€‚ ãŸã¨ãˆã°ã€i = i++
ã¯å…ƒã®å€¤ã‚’インクリメントã—ãŸå€¤ã§ä¸Šæ›¸ãã—ã¾ã™ã€‚ ]]> @@ -8322,7 +8318,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ç¬¦å·ãªã—ã‚ャストã®å®Ÿè¡Œçµæžœã‚’ short ã¾ãŸã¯ byte ã«ã‚ャストã—ã¦ã„ã¾ã™ã€‚çµæžœã®ä¸Šä½ãƒ“ットã¯æ¨ã¦ã‚‰ã‚Œã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ç¬¦å·ãªã—ã‚ャストã®å®Ÿè¡Œçµæžœã‚’ short ã¾ãŸã¯ byte ã«ã‚ャストã—ã¦ã„ã¾ã™ã€‚çµæžœã®ä¸Šä½ãƒ“ットã¯æ¨ã¦ã‚‰ã‚Œã¾ã™ã€‚ 上ä½ãƒ“ットãŒæ¨ã¦ã‚‰ã‚Œã‚‹ã®ã§ã€ç¬¦å·ä»˜ãã¨ç¬¦å·ãªã—å³ã‚·ãƒ•ãƒˆ (シフトã®ã‚µã‚¤ã‚ºã«ã‚ˆã£ã¦) ã¨ã®é•ã„ãŒãªã„ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“。 ]]> @@ -8349,7 +8345,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€32ビット int ã®-31ã‹ã‚‰31ã®ç¯„囲を超ãˆãŸé‡ã§ã‚·ãƒ•ãƒˆã‚’実行ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯32ビット int ã®-31ã‹ã‚‰31ã®ç¯„囲を超ãˆãŸé‡ã§ã‚·ãƒ•ãƒˆã‚’実行ã—ã¦ã„ã¾ã™ã€‚ ã“ã‚Œã®åŠ¹æžœã¯ã€ã©ã®ãらã„シフトã™ã‚‹ã®ã‹ã‚’決ã‚ã‚‹ãŸã‚ã«æ•´æ•°å€¤ã®ä¸‹ä½5ビット (32ã§å‰²ã£ãŸä½™ã‚Š) を使用ã™ã‚‹ã“ã¨ã§ã™ (ãŸã¨ãˆã°ã€40ビットã§ã‚·ãƒ•ãƒˆã™ã‚‹ã“ã¨ã¯8ビットã§ã‚·ãƒ•ãƒˆã™ã‚‹ã“ã¨ã¨åŒã˜ã§ã€32ビットã§ã‚·ãƒ•ãƒˆã™ã‚‹ã“ã¨ã¯0ビットã§ã‚·ãƒ•ãƒˆã™ã‚‹ã“ã¨ã¨åŒã˜ã§ã™)。 ã“ã‚Œã¯ãŠãらã期待ã•ã‚ŒãŸã“ã¨ã§ã¯ãªãã€å°‘ãªãã¨ã‚‚紛らã‚ã—ã„ã§ã™ã€‚ @@ -8363,7 +8359,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ•´æ•°å‰°ä½™ã®çµæžœã«æ•´æ•°å®šæ•°ã‚’ä¹—ç®—ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ•´æ•°å‰°ä½™ã®çµæžœã«æ•´æ•°å®šæ•°ã‚’ä¹—ç®—ã—ã¦ã„ã¾ã™ã€‚ 紛らã‚ã—ã„演算åã®å„ªå…ˆé †ä½ãŒãªã„ã“ã¨ã‚’確実ã«ã—ã¦ãã ã•ã„。 ãŸã¨ãˆã°ã€i % 60 * 1000 ã¯ã€i % (60 * 1000) ã§ã¯ãªã (i % 60) * 1000 ã¨ãªã‚Šã¾ã™ã€‚ @@ -8377,7 +8373,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€é…列ã§hashCode
メソッドを呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯é…列ã§hashCode
メソッドを呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚ é…列ã§hashCode
メソッドを呼ã³å‡ºã™ã“ã¨ã¯ã€System.identityHashCode ã¨åŒã˜å€¤ã‚’è¿”ã™ã®ã§ã€ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã¨é…列ã®é•·ã•ã‚’無視ã—ã¾ã™ã€‚ é…列a
ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„ã«ã‚ˆã‚‹ãƒãƒƒã‚·ãƒ¥ã‚³ãƒ¼ãƒ‰ã‚’å¿…è¦ã¨ã™ã‚‹ãªã‚‰ã€java.util.Arrays.hashCode(a)
を使用ã—ã¦ãã ã•ã„。 @@ -8391,7 +8387,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€é…列ã§toString
メソッドを呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚「[C@16f0472ã€ã®ã‚ˆã†ãªã‹ãªã‚Šå½¹ã«ç«‹ãŸãªã„çµæžœã‚’生æˆã—ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯é…列ã§toString
メソッドを呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚「[C@16f0472ã€ã®ã‚ˆã†ãªã‹ãªã‚Šå½¹ã«ç«‹ãŸãªã„çµæžœã‚’生æˆã—ã¾ã™ã€‚ é…列ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„を与ãˆã€èªã‚ã‚‹æ–‡å—列ã«å¤‰æ›ã™ã‚‹ãŸã‚ã«Arrays.toString()
を使用ã™ã‚‹ã“ã¨ã‚’検討ã—ã¦ãã ã•ã„。
『Programming Puzzlersã€ã®ç¬¬3ç« ã€ãƒ‘ズル12ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 @@ -8405,7 +8401,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ç„¡åã®é…列ã§toString
メソッドを呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚「[C@16f0472ã€ã®ã‚ˆã†ãªã‹ãªã‚Šå½¹ã«ç«‹ãŸãªã„çµæžœã‚’生æˆã—ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ç„¡åã®é…列ã§toString
メソッドを呼ã³å‡ºã—ã¦ã„ã¾ã™ã€‚「[C@16f0472ã€ã®ã‚ˆã†ãªã‹ãªã‚Šå½¹ã«ç«‹ãŸãªã„çµæžœã‚’生æˆã—ã¾ã™ã€‚ é…列ã®ã‚³ãƒ³ãƒ†ãƒ³ãƒ„を与ãˆã€èªã‚ã‚‹æ–‡å—列ã«å¤‰æ›ã™ã‚‹ãŸã‚ã«Arrays.toString()
を使用ã™ã‚‹ã“ã¨ã‚’検討ã—ã¦ãã ã•ã„。
『Programming Puzzlersã€ã®ç¬¬3ç« ã€ãƒ‘ズル12ã‚’å‚ç…§ã—ã¦ãã ã•ã„。 @@ -8419,7 +8415,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€é™¤ç®—ã‹ç¬¦å·ä»˜ãå³ã‚·ãƒ•ãƒˆã‚’使用ã—ã¦2ã¤ã®æ•´æ•°ã®å¹³å‡ã‚’計算ã—ã¦ã€çµæžœã‚’é…列ã®æ·»å—ã¨ã—ã¦ä½¿ç”¨ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯é™¤ç®—ã‹ç¬¦å·ä»˜ãå³ã‚·ãƒ•ãƒˆã‚’使用ã—ã¦2ã¤ã®æ•´æ•°ã®å¹³å‡ã‚’計算ã—ã¦ã€çµæžœã‚’é…列ã®æ·»å—ã¨ã—ã¦ä½¿ç”¨ã—ã¦ã„ã¾ã™ã€‚ å¹³å‡å€¤ãŒéžå¸¸ã«å¤§ãã„ãªã‚‰ã‚ªãƒ¼ãƒãƒ¼ãƒ•ãƒãƒ¼ã™ã‚‹å¯èƒ½æ€§ãŒã‚ã‚Šã¾ã™ (çµæžœã¨ã—ã¦è² ã®å¹³å‡ã®è¨ˆç®—ã«ãªã‚‹)。 çµæžœãŒè² ã§ãªã„ã“ã¨ã‚’æ„図ã—ã¦ã„ãŸãªã‚‰ã€ãã®ä»£ã‚ã‚Šã«ç¬¦å·ãªã—å³ã‚·ãƒ•ãƒˆã‚’使用ã§ãã¾ã™ã€‚ ã¤ã¾ã‚Šã€(low+high)/2
ã§ã¯ãªã(low+high) >>> 1
を使用ã—ã¦ãã ã•ã„。 @@ -8439,7 +8435,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€x % 2 == 1
を使用ã—ã¦å€¤ãŒè² æ•°ãªã®ã‹ç¢ºã‹ã‚ã¦ã„ã¾ã™ãŒã€è² æ•° (ãŸã¨ãˆã°ã€(-5) % 2 == -1
) ãªã®ã§æ©Ÿèƒ½ã—ã¾ã›ã‚“。 +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯x % 2 == 1
を使用ã—ã¦å€¤ãŒè² æ•°ãªã®ã‹ç¢ºã‹ã‚ã¦ã„ã¾ã™ãŒã€è² æ•° (ãŸã¨ãˆã°ã€(-5) % 2 == -1
) ãªã®ã§æ©Ÿèƒ½ã—ã¾ã›ã‚“。 奇数ãƒã‚§ãƒƒã‚¯ã‚’æ„図ã—ã¦ã„ã‚‹ãªã‚‰ã€x & 1 == 1
ã¾ãŸã¯x % 2 != 0
を使用ã™ã‚‹ã“ã¨ã‚’検討ã—ã¦ãã ã•ã„。 ]]> @@ -8452,7 +8448,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ãƒãƒ¼ãƒ‰ã‚³ãƒ¼ãƒ‰ã•ã‚ŒãŸçµ¶å¯¾ãƒ‘スåを使用ã—㦠File オブジェクトを構築ã—ã¦ã„ã¾ã™ (ãŸã¨ãˆã°@@ -8464,7 +8460,7 @@new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");
)。 +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ãƒãƒ¼ãƒ‰ã‚³ãƒ¼ãƒ‰ã•ã‚ŒãŸçµ¶å¯¾ãƒ‘スåを使用ã—㦠File オブジェクトを構築ã—ã¦ã„ã¾ã™ (ãŸã¨ãˆã°new File("/home/dannyc/workspace/j2ee/src/share/com/sun/enterprise/deployment");
)。 ]]>-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€ãƒ¡ã‚½ãƒƒãƒ‰ã«0ã‹ã‚‰11ã®ç¯„囲外ã®æœˆå®šæ•°å€¤ã‚’渡ã—ã¦ã„ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ãƒ¡ã‚½ãƒƒãƒ‰ã«0ã‹ã‚‰11ã®ç¯„囲外ã®æœˆå®šæ•°å€¤ã‚’渡ã—ã¦ã„ã¾ã™ã€‚ ]]>@@ -8476,7 +8472,7 @@-ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€æ–‡å—列ã§@@ -8773,7 +8769,7 @@substring(0)
を呼ã³å‡ºã—ã¦ã„ã¾ã™ãŒã€å…ƒã®å€¤ã‚’è¿”ã—ã¾ã™ã€‚ +ã“ã®ã‚³ãƒ¼ãƒ‰ã¯æ–‡å—列ã§substring(0)
を呼ã³å‡ºã—ã¦ã„ã¾ã™ãŒã€å…ƒã®å€¤ã‚’è¿”ã—ã¾ã™ã€‚ ]]>
Label
ã®ã‚µãƒ–クラスã¯åŒã˜ã‚µãƒ–クラスã§åŒæœŸåŒ–ã—ã¾ã›ã‚“。データレースを生ã˜ã•ã›ã¾ã™ã€‚
-代ã‚ã‚Šã«ã€ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ã€Label.class
ã§åŒæœŸåŒ–ã™ã‚‹ã¹ãã§ã™ã€‚
+代ã‚ã‚Šã«ã€ã“ã®ã‚³ãƒ¼ãƒ‰ã¯ Label.class
ã§åŒæœŸåŒ–ã™ã‚‹ã¹ãã§ã™ã€‚
private static final String base = "label"; diff --git a/lib/LICENSE_AppleJavaExtensions.txt b/lib/LICENSE_AppleJavaExtensions.txt new file mode 100644 index 0000000..ee60804 --- /dev/null +++ b/lib/LICENSE_AppleJavaExtensions.txt @@ -0,0 +1,67 @@ + +AppleJavaExtensions +v 1.2 + + http://developer.apple.com/samplecode/AppleJavaExtensions/AppleJavaExtensions.html + +This is a pluggable jar of stub classes representing the new Apple +eAWT and eIO APIs for Java 1.4 on Mac OS X. The purpose of these +stubs is to allow for compilation of eAWT- or eIO-referencing code on +platforms other than Mac OS X. These stubs are not intended for the +runtime classpath on non-Mac platforms. Please see the OSXAdapter +sample for how to write cross-platform code that uses eAWT. + +There is no license file provided for AppleJavaExtensions.jar. Below +is a response from Apple to a question about the license. + +On 13 Aug 2004, at 12:33 AM, mdrance@apple.com wrote: + +> Thank you for bringing this up. AppleJavaExtensions is subject to all +> the same terms as the other sample code projects from Apple. We will +> update the readme to contain the boilerplate legal info. Of course you +> can use them on other platforms -- the readme explicitly says this is +> their purpose. But I appreciate your caution and attention to detail. + +Below is a copy of the standard Apple sample code disclaimer from another +piece of sample code on the same site: + +------------------------------------------------------------------------- +Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple +Computer, Inc. ("Apple") in consideration of your agreement to the +following terms, and your use, installation, modification or +redistribution of this Apple software constitutes acceptance of these +terms. If you do not agree with these terms, please do not use, +install, modify or redistribute this Apple software. + +In consideration of your agreement to abide by the following terms, and +subject to these terms, Apple grants you a personal, non-exclusive +license, under Apple's copyrights in this original Apple software (the +"Apple Software"), to use, reproduce, modify and redistribute the Apple +Software, with or without modifications, in source and/or binary forms; +provided that if you redistribute the Apple Software in its entirety and +without modifications, you must retain this notice and the following +text and disclaimers in all such redistributions of the Apple Software. +Neither the name, trademarks, service marks or logos of Apple Computer, +Inc. may be used to endorse or promote products derived from the Apple +Software without specific prior written permission from Apple. Except +as expressly stated in this notice, no other rights or licenses, express +or implied, are granted by Apple herein, including but not limited to +any patent rights that may be infringed by your derivative works or by +other works in which the Apple Software may be incorporated. + +The Apple Software is provided by Apple on an "AS IS" basis. APPLE +MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND +OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + +IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, +MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED +AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), +STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Copyright © 2004 Apple Computer, Inc., All Rights Reserved diff --git a/pom.xml b/pom.xml index f791d07..3a2008c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,15 @@ -+ 4.0.0 org.sonatype.oss oss-parent 7 -+ com.google.code.findbugs findbugs -3.0.1-SNAPSHOT +3.1.0-SNAPSHOT jar http://findbugs.sourceforge.net/ @@ -60,7 +60,7 @@bp Keith Lea -+ http://keithlea.com/ web cloud @@ -89,26 +89,26 @@Nay Ayewah -- - - + + + + -5 Ben Langmead -- - - + + + + -5 Tomas Pollak -- + + @@ -116,17 +116,17 @@ Eclipse plugin tests Phil Crosby -- - - + + + + -5 Peter Friese -- + + @@ -134,37 +134,37 @@ Eclipse plugin Dave Brosius -- - - + + + + -5 Brian Goetz -- - - + + + + -5 Rohan Lloyd -- - - + + + + -5 @@ -246,7 +246,7 @@ Tagir Valeev -- - - + lany@ngs.ru ++ + +6 - ${basedir}/src +${basedir}/src/java ${basedir}/src/junit @@ -275,7 +275,7 @@ - ${basedir}/src/antTask +${basedir}/src/gui **/*.xsl **/*.properties @@ -285,7 +285,7 @@- -${basedir}/src/gui +${basedir}/src/java **/*.xsl **/*.properties @@ -294,25 +294,30 @@**/*.html - ${basedir}/src/java -- -**/*.xsl -**/*.properties -**/*.db -**/*.png -**/*.html -+ + org.codehaus.mojo +build-helper-maven-plugin +1.9.1 ++ ++ +generate-sources ++ add-source + ++ + + + +org.apache.maven.plugins maven-javadoc-plugin 2.9.1 -- src/java -org.apache.maven.plugins @@ -329,7 +334,6 @@diff --git a/runMaven b/runMaven index d002795..4c4bc85 100755 --- a/runMaven +++ b/runMaven @@ -1,5 +1,5 @@ #! /bin/sh mvn install:install-file -Dfile=lib/bcel-6.0-SNAPSHOT.jar -DgroupId=com.google.code.findbugs -DartifactId=bcel -Dversion=6.0-SNAPSHOT -Dpackaging=jar -mvn install:install-file -Dfile=lib/asm-debug-all-5.0.2.jar -DgroupId=org.ow2.asm -DartifactId=asm-debug-all -Dversion=5.0.2 -Dpackaging=jar +mvn install:install-file -Dfile=lib/asm-debug-all-6.0-SNAPSHOT.jar -DgroupId=org.ow2.asm -DartifactId=asm-debug-all -Dversion=6.0-SNAPSHOT -Dpackaging=jar mvn clean mvn package diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java index 055ce59..d9711a9 100755 --- a/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/ConvertXmlToTextTask.java @@ -160,7 +160,7 @@ getProject().setProperty(errorProperty, "true"); } if ((rc & ExitCodes.ERROR_FLAG) != 0) { - String message = "At least one error occured!"; + String message = "At least one error occurred!"; if (failIfBugFound) { throw new BuildException(message); } else { diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java index 406db86..4e7c62d 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsTask.java @@ -51,13 +51,15 @@ * **/architecture/** **/cloud/** -**/DetectorsTest.java debug (boolean default false) * effort (enum min|default|max) *excludeFilter (filter filename) + * excludePath (classpath or classpathRef to filters) * failOnError (boolean - default false) * home (findbugs install dir) * includeFilter (filter filename) + * includePath (classpath or classpathRef to filters) * maxRank (maximum rank issue to be reported) * jvm (Set the command used to start the VM) * jvmargs (any additional jvm arguments) - * omitVisitors (collection - comma seperated) + * omitVisitors (collection - comma separated) * onlyAnalyze (restrict analysis to find bugs to given comma-separated list * of classes and packages - See the textui argument description for details) * output (enum text|xml|xml:withMessages|html - default xml) @@ -76,7 +78,7 @@ * "default.xsl") * systemProperty (a system property to set) * timestampNow (boolean - default false) - * visitors (collection - comma seperated) + * visitors (collection - comma separated) * chooseVisitors (selectively enable/disable visitors) * workHard (boolean default false) * setSetExitCode (boolean default true) @@ -136,7 +138,11 @@ private File excludeFile; + private Path excludePath; + private File includeFile; + + private Path includePath; private Path auxClasspath; @@ -532,6 +538,62 @@ */ public void setSourcePathRef(Reference r) { createSourcePath().setRefid(r); + } + + /** + * the sourcepath to use. + */ + public void setExcludePath(Path src) { + if (excludePath == null) { + excludePath = src; + } else { + excludePath.append(src); + } + } + + /** + * Path to use for sourcepath. + */ + public Path createExcludePath() { + if (excludePath == null) { + excludePath = new Path(getProject()); + } + return excludePath.createPath(); + } + + /** + * Adds a reference to a source path defined elsewhere. + */ + public void setExcludePathRef(Reference r) { + createExcludePath().setRefid(r); + } + + /** + * the sourcepath to use. + */ + public void setIncludePath(Path src) { + if (includePath == null) { + includePath = src; + } else { + includePath.append(src); + } + } + + /** + * Path to use for sourcepath. + */ + public Path createIncludePath() { + if (includePath == null) { + includePath = new Path(getProject()); + } + return includePath.createPath(); + } + + /** + * Adds a reference to a source path defined elsewhere. + */ + public void setIncludePathRef(Reference r) { + createIncludePath().setRefid(r); } /** @@ -728,9 +790,23 @@ addArg("-exclude"); addArg(excludeFile.getPath()); } + if (excludePath != null) { + String[] result = excludePath.toString().split(java.io.File.pathSeparator); + for (int x = 0; x < result.length; x++) { + addArg("-exclude"); + addArg(result[x]); + } + } if (includeFile != null) { addArg("-include"); addArg(includeFile.getPath()); + } + if (includePath != null) { + String[] result = includePath.toString().split(java.io.File.pathSeparator); + for (int x = 0; x < result.length; x++) { + addArg("-include"); + addArg(result[x]); + } } if (visitors != null) { addArg("-visitors"); diff --git a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java index 9ba5aa4..baf6021 100644 --- a/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java +++ b/src/antTask/edu/umd/cs/findbugs/anttask/FindBugsViewerTask.java @@ -32,7 +32,7 @@ /** * FindBugsViewerTask.java -- Ant Task to launch the FindBugsFrame * - * To use, create a new task that refrences the ant task (such as + * To use, create a new task that references the ant task (such as * "findbugs-viewer"). Then call this task while passing in parameters to modify * it's behaviour. It supports several options that are the same as the findbugs * task: diff --git a/src/doc/Changes.html b/src/doc/Changes.html index 232aa38..988fbc0 100644 --- a/src/doc/Changes.html +++ b/src/doc/Changes.html @@ -706,7 +706,7 @@ Changes since version 1.3.5
@@ -2130,10 +2130,10 @@
- Added fairly exhaustive static analysis of uses of format - strings, checking for missing or extra arguements, invalid format + strings, checking for missing or extra arguments, invalid format specifiers, or mismatched format specifiers and arguments (e.g, passing a String value for a %d format specifier). The logic for doing so is derived from Sun's java.util.Formatter class, and @@ -1304,7 +1304,7 @@ extends
beta.Foo
). This can be exceptionally confusing, create lots of situations in which you have to look at import statements to resolve references and creates many - opportunities to accidently define methods that do not + opportunities to accidentally define methods that do not override methods in their superclasses.- NM_SAME_SIMPLE_NAME_AS_INTERFACE: This class/interface @@ -1313,7 +1313,7 @@ in a different package (e.g.,
alpha.Foo
extendsbeta.Foo
). This can be exceptionally confusing, create lots of situations in which you have to look at import statements to resolve - references and creates many opportunities to accidently define + references and creates many opportunities to accidentally define methods that do not override methods in their superclasses.Updated detectors -
- SwitchFallthrough.java: surpress some false positives
-- DuplicateBranches.java: surpress some false positives
-- IteratorIdioms.java: surpress some false positives
-- FindHEmismatch.java: surpress some false positives
+- SwitchFallthrough.java: suppress some false positives
+- DuplicateBranches.java: suppress some false positives
+- IteratorIdioms.java: suppress some false positives
+- FindHEmismatch.java: suppress some false positives
- QuestionableBooleanAssignment.java: finds more cases of if (b=true) ilk
@@ -2444,7 +2444,7 @@- New detector to find calls to equals() methods that use Object's version. (Dave Brosius)
- New detector to find Applets that call methods in the - constructor refering to the AppletStub (Dave Brosius)
+ constructor referring to the AppletStub (Dave Brosius)New detector to find some cases of infinite recursion (Bill Pugh) New detector to find dead stores to local variables (David @@ -2498,7 +2498,7 @@ Allow Swing GUI to show source code in jar files on Windows systems (Dave Brosius) -Fix the Switch Fall Thru detector (Dave Brosius, David + Fix the Switch Fall Through detector (Dave Brosius, David Hovemeyer, Bill Pugh) MacOS GUI fixes (Rohan Lloyd) Fix false positive in BOA in case where method is diff --git a/src/doc/contributing.html b/src/doc/contributing.html index 0531869..503567d 100644 --- a/src/doc/contributing.html +++ b/src/doc/contributing.html @@ -21,18 +21,17 @@ The preferred way to get the FindBugs source code and create the patch is to use Eclipse + Git. You can easily import FindBugs code into Eclipse by following the steps described -here: Import Eclipse projects +here: Import Eclipse projects .
Preparing a patch
-The best way to create a patch is to clone FindBugs Git repository here: - http://code.google.com/p/findbugs/source/clones, +
The best way to create a patch is to fork FindBugs Git repository here: + https://github.com/findbugsproject/findbugs, commit changes with descriptive commit messages (small commits are better) and - create a new bug - or feature request - with the "[patch]" prefix in the title and link to your repository in the description. + create a new pull request + with the appropriate title and description.
Please follow these guidelines when preparing your patch:
@@ -48,7 +47,7 @@If you are submitting a new bug detector, please submit a small standalone source file that contains an instance of the kind of bug the detector looks for. The file should be placed at - findbugsTestCases/src/java/sfBugsNew + findbugsTestCases/src/java/ghBugsNew package and named after the bug or feature you are addressing. @@ -58,9 +57,8 @@ Where to submit a patch
Patches may be submitted through the -bug - or feature request trackers on the -sourceforge project page. +pull requests on the +GitHub project page. @HTML_FOOTER@ diff --git a/src/doc/findbugs2.html b/src/doc/findbugs2.html index b169227..cd86014 100644 --- a/src/doc/findbugs2.html +++ b/src/doc/findbugs2.html @@ -35,7 +35,7 @@
- Also check out http://code.google.com/p/findbugs/w/list + Also check out https://github.com/findbugsproject/findbugs/commits/master for more information about some recent features/changes in FindBugs.
diff --git a/src/doc/index.html b/src/doc/index.html index fe6d9d5..ce05763 100644 --- a/src/doc/index.html +++ b/src/doc/index.html @@ -55,9 +55,9 @@ href="#sponsors">Sponsors | Support -FindBugs 3.0.1 Release
--
- A number of changes described in the changes document, including new bug patterns: +
FindBugs 3.0.1 Release
++
- A number of changes described in the changes document, including new bug patterns:
- Also check out http://code.google.com/p/findbugs/w/list + Also check out https://github.com/findbugsproject/findbugs/commits/master for more information about some recent features/changes in FindBugs.
diff --git a/src/doc/manual.xml b/src/doc/manual.xml index 647d85a..992eb7d 100644 --- a/src/doc/manual.xml +++ b/src/doc/manual.xml @@ -1335,7 +1335,7 @@An optional attribute. It specifies the confidence/priority threshold for reporting issues. If set to "low", confidence is not used to filter bugs. - If set to "medium" (the default), low confidence issues are supressed. + If set to "medium" (the default), low confidence issues are suppressed. If set to "high", only high confidence bugs are reported. @@ -1474,12 +1474,70 @@+ + ++ excludePath + ++ Since Findbugs 3.0.2. + ++ An optional nested element which specifies a path + containing filters specifying bugs + to exclude from being reported. See +. + + Example: + + ++ <findbugs home="${findbugs.home}"> + <excludePath> + <path> + <fileset dir="${findbugs-exclusion-filters.dir}" includes="findbugs-*-exclude-filter.xml" /> + </path> + </excludePath> + </findbugs> + + + SeeApache Ant's Path-like Structures documentation for details. ++ + includeFilter + Optional attribute. It specifies the filename of a filter specifying which bugs are reported. See +. + @@ -1601,6 +1659,18 @@ ++ includePath + + Since Findbugs 3.0.2. + ++ An optional nested element which specifies a path + containing filters specifying which bugs + are reported. See +. + + Example: + + + <findbugs home="${findbugs.home}"> + <includePath> + <path> + <fileset dir="${findbugs-inclusion-filters.dir}" includes="findbugs-*-include-filter.xml" /> + </path> + </includePath> + </findbugs> + + + SeeApache Ant's Path-like Structures documentation for details. ++ + @@ -1756,7 +1826,7 @@+ pluginList + ++ A optional String attribute or optional nested element specifying which BugDetector Jar files to add.. The +pluginList + element must specify alocation attribute which names the + archive file (jar, zip, etc.), directory, or class file to be analyzed. MultiplepluginList + elements may be specified as children of a singlefindbugs element. +Extending the Eclipse Plugin (since 2.0.0) Eclipse plugin supports contribution of custom &FindBugs; detectors (see also - AddingDetectors.txt +AddingDetectors.txt for more information). There are two ways to contribute custom plugins to the Eclipse:@@ -1789,7 +1859,7 @@ Please check the documentation of the - @@ -2000,7 +2070,7 @@ If the+ findBugsEclipsePlugin/schema/detectorPlugins.exsd extension point how to update the plugin.xml. Existing &FindBugs; detector plugins can be easily "extended" to be full featured &FindBugs; AND Eclipse detector plugins. @@ -1805,7 +1875,7 @@ Eclipse plugin. You can do this even for third-party detector packages. Another major differentiator is the ability to extend the default FindBugs classpath at runtime with required third party libraries (see -AddingDetectors.txt +AddingDetectors.txt for more information).Match element contains neither aClass element, nor aclass /classregex attribute, the predicate will apply to all classes. Such predicate is likely to match more bug instances than you want, unless it is - refined further down with apropriate method or field predicates. + refined further down with appropriate method or field predicates. @@ -2038,7 +2108,7 @@@@ -2133,7 +2203,7 @@ By explicitly matching both classes, you ensure that the IC bug instance will be matched regardless of which class involved in the circularity happens to be listed first in the bug instance. (Of course, this approach might accidentally -supress circularities involving "com.foobar.A" or "com.foobar.B" and a third +suppress circularities involving "com.foobar.A" or "com.foobar.B" and a third class.) @@ -2574,7 +2644,7 @@ This element specifies a field. The name attribute is is used to specify the exact or regex match pattern for the field name. You can also filter fields according to their signature - - usetype attribute to specify fully qualified type of the field. You can specify eiter or both + usetype attribute to specify fully qualified type of the field. You can specify either or both of these attributes in order to perform name / signature based matches. Therole attribute is the field role.@@ -2741,7 +2811,7 @@ - explanation: A textual explaination of why the return value should be checked. Default value:"". +explanation: A textual explanation of why the return value should be checked. Default value:"".The annotated element could be null under some circumstances. In general, this means developers will have to read the documentation to determine when a null value is -acceptable and whether it is neccessary to check for a null value. FindBugs will +acceptable and whether it is necessary to check for a null value. FindBugs will treat the annotated items as though they had no annotation. @@ -3149,7 +3219,7 @@ |
-output <file> output="<file>" save output in the named file (may also be an input file) -
-overrideRevisionNames[:truth] overrideRevisionNames="[true|false]" override revision names for each version with names computed from the filenames +
-noPackageMoves[:truth] noPackageMoves="[true|false]" if a class has moved to another package, treat warnings in that class as seperate |
-noPackageMoves[:truth] noPackageMoves="[true|false]" if a class has moved to another package, treat warnings in that class as separate |
-preciseMatch[:truth] preciseMatch="[true|false]" require bug patterns to match precisely |
-precisePriorityMatch[:truth] precisePriorityMatch="[true|false]" consider two warnings as the same only if priorities match exactly @@ -3325,7 +3395,7 @@
-quiet[:truth] quiet="[true|false]" don't generate any output to standard out unless there is an error |
fixed Count of warnings removed from a class that remains in the current version |
removed Count of warnings in the previous version for a class that is not present in the current version -
retained Count of warnings that were in both the previous and current version +
dead Warnings that were present in earlier versions but in neither the current version or the immediately preceeding version |
dead Warnings that were present in earlier versions but in neither the current version or the immediately preceding version @@ -3962,6 +4032,8 @@
active Total warnings present in the current version Kevin Lubick contributed fixes and tests for multi-quick-fixes and customizable annotation colors for Eclipse plugin. +Boris Bokowski contributed several new bug patterns: BIT_SIGNED_CHECK and BIT_SIGNED_CHECK_HIGH_BIT. +Tagir Valeev contributed several new bug detectors and improved existing ones. If you have contributed to &FindBugs;, but aren't mentioned above, diff --git a/src/doc/manual_ja.xml b/src/doc/manual_ja.xml index 9c17484..0e4b388 100644 --- a/src/doc/manual_ja.xml +++ b/src/doc/manual_ja.xml @@ -656,7 +656,7 @@ -userPrefs edu.umd.cs.findbugs.core.prefs - ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®ãƒ‘スをè¨å®šã—ã¾ã™ã€‚ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã§ã€ä»–ã®ã‚ªãƒ—ションã®ä¸€éƒ¨ã‚’上書ãã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®ãƒ‘スをè¨å®šã—ã¾ã™ã€‚ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã§ã€ä»–ã®ã‚ªãƒ—ションã®ä¸€éƒ¨ã‚’上書ãã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ @@ -1041,7 +1041,7 @@userPrefs を一番目ã®å¼•æ•°ã«æŒ‡å®šã—ãŸå ´åˆã¯ã€å¾Œç¶šã®ã‚ªãƒ—ションã®æ–¹ãŒãƒ¦ãƒ¼ã‚¶ãƒ¼è¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã«å„ªå…ˆã—ã¾ã™ã€‚userPrefs を最後ã®å¼•æ•°ã«æŒ‡å®šã—ãŸå ´åˆã¯ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼è¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã®æ–¹ãŒå‰ã«æŒ‡å®šã—ãŸã‚ªãƒ—ションã«å„ªå…ˆã—ã¾ã™ã€‚ ã“ã®ã‚ªãƒ—ションをè¨ã‘ãŸèƒŒæ™¯ãƒ»ç†ç”±ã¯ã€ Eclipse プãƒã‚¸ã‚§ã‚¯ãƒˆã® FindBugs ã®è¨å®šã‚’コマンドライン実行ã§å†åˆ©ç”¨ã™ã‚‹ãŸã‚ã§ã™ã€‚diff --git a/src/doc/reportingBugs.html b/src/doc/reportingBugs.html index 9975fa4..5c2c591 100644 --- a/src/doc/reportingBugs.html +++ b/src/doc/reportingBugs.html @@ -23,13 +23,13 @@ ä»»æ„指定ã®å±žæ€§ã§ã™ã€‚ - ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®ãƒ‘スをè¨å®šã—ã¾ã™ã€‚ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã§ã€ä»–ã®ã‚ªãƒ—ションã®ä¸€éƒ¨ã‚’上書ãã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ + ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®ãƒ‘スをè¨å®šã—ã¾ã™ã€‚ユーザーè¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã§ã€ä»–ã®ã‚ªãƒ—ションã®ä¸€éƒ¨ã‚’上書ãã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ userPreferencesFile を一番目ã®å¼•æ•°ã«æŒ‡å®šã—ãŸå ´åˆã¯ã€å¾Œç¶šã®ã‚ªãƒ—ションã®æ–¹ãŒãƒ¦ãƒ¼ã‚¶ãƒ¼è¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã«å„ªå…ˆã—ã¾ã™ã€‚userPreferencesFile を最後ã®å¼•æ•°ã«æŒ‡å®šã—ãŸå ´åˆã¯ã€ãƒ¦ãƒ¼ã‚¶ãƒ¼è¨å®šãƒ•ã‚¡ã‚¤ãƒ«ã®å†…容ã®æ–¹ãŒå‰ã«æŒ‡å®šã—ãŸã‚ªãƒ—ションã«å„ªå…ˆã—ã¾ã™ã€‚ ã“ã®ã‚ªãƒ—ションをè¨ã‘ãŸèƒŒæ™¯ãƒ»ç†ç”±ã¯ã€ Eclipse プãƒã‚¸ã‚§ã‚¯ãƒˆã® FindBugs ã®è¨å®šã‚’コマンドライン実行ã§å†åˆ©ç”¨ã™ã‚‹ãŸã‚ã§ã™ã€‚ @@ -1155,14 +1155,14 @@Eclipse プラグインã§ã¯ã€ 独自㮠&FindBugs; ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ã‚’è¿½åŠ ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ (詳ã—ã知りãŸã„æ–¹ã¯ã€ - AddingDetectors.txt -ã‚‚ã”覧ãã ã•ã„)。 +AddingDetectors.txt +ã‚‚ã”覧ãã ã•ã„)。 独自ã®ãƒ—ラグインを Eclipse ã«è¿½åŠ ã™ã‚‹ã«ã¯ä»¥ä¸‹ã®2通りã®æ–¹æ³•ãŒã‚ã‚Šã¾ã™ã€‚@@ -1368,7 +1368,7 @@ - æ—¢å˜ã®æ¨™æº– &FindBugs; ディテクタパッケージã¯ä»¥ä¸‹ã§è¨å®šã§ãã¾ã™ã€‚ + æ—¢å˜ã®æ¨™æº– &FindBugs; ディテクタパッケージã¯ä»¥ä¸‹ã§è¨å®šã§ãã¾ã™ã€‚ Window Preferences @@ -1186,7 +1186,7 @@- + findBugsEclipsePlugin/schema/detectorPlugins.exsd ã® documentation 㧠plugin.xml ã®æ›´æ–°æ–¹æ³•ã‚’確èªã—ã¦ãã ã•ã„。 æ—¢å˜ã® &FindBugs; ディテクタプラグイン ã‚’ç°¡å˜ã«ã€Œæ‹¡å¼µã€ã—ã¦å¼·åŠ›ãª &FindBugs; Eclipse ディテクタプラグイン ã«ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ 通常必è¦ãªã®ã¯ã€ META-INF/MANIFEST.MF ãŠã‚ˆã³ plugin.xml ã‚’ jar ã«è¿½åŠ ã—ã¦ã‹ã¤ã€ MANIFEST.MF ãŒãƒ“ルド時ã«ä¸Šæ›¸ãã•ã‚Œãªã„よã†ã«ãƒ“ルドスクリプトを更新ã™ã‚‹ã ã‘ã§ã™ã€‚ @@ -1197,7 +1197,7 @@ å‰ææ¡ä»¶ã¯ç¾åœ¨ä½¿ç”¨ã—ã¦ã„るディテクタパッケージを Eclipse プラグインã«å¤‰æ›ã—ã¦ãŠãã“ã¨ã§ã™ã€‚ ã“ã‚Œã¯ã‚µãƒ¼ãƒ‰ãƒ‘ーティã®ãƒ‡ã‚£ãƒ†ã‚¯ã‚¿ãƒ‘ッケージもåŒæ§˜ã§ã™ã€‚ ã‚‚ã†ã²ã¨ã¤ã®ä¸»ãªå·®åˆ¥åŒ–è¦å› ã¯ã€ FindBugs ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆå®Ÿè¡Œæ™‚クラスパス ã«å½“è©²ã‚µãƒ¼ãƒ‰ãƒ‘ãƒ¼ãƒ†ã‚£ãƒ©ã‚¤ãƒ–ãƒ©ãƒªãƒ¼ã‚’è¿½åŠ ã™ã‚‹ã“ã¨ãŒå¿…è¦ãªã“ã¨ã§ã™(ãã‚ã—ã㯠-AddingDetectors.txt +AddingDetectors.txt ã‚’ã”覧ãã ã•ã„)。<And> @@ -1808,7 +1808,7 @@ - ã“ã®è¦ç´ ã¯ã€è«–ç†ç©ã¨ã—㦠Match æ¡é …ã‚’çµåˆã—ã¾ã™ã€‚ + ã“ã®è¦ç´ ã¯ã€è«–ç†ç©ã¨ã—ã¦Match æ¡é …ã‚’çµåˆã—ã¾ã™ã€‚ ã™ãªã‚ã¡ã€Bug ãŠã‚ˆã³Confidence è¦ç´ ã‚’And æ¡é …内ã«æŒ‡å®šã™ã‚‹ã“ã¨ã§ 特定ã®ä¿¡é ¼åº¦ã®ç‰¹å®šã®ãƒã‚°ã®ã¿ç…§åˆã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚クラスã¾ãŸã¯ãƒ‘ッケージã®ã™ã¹ã¦ã®ãƒ¡ãƒ³ãƒãƒ¼ãŒæŒ‡å®šã•ã‚ŒãŸã‚¢ãƒŽãƒ†ãƒ¼ã‚·ãƒ§ãƒ³ã‚¯ãƒ©ã‚¹ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆå€¤ã§ã‚¢ãƒŽãƒ†ãƒ¼ãƒˆã•ã‚Œã‚‹ã“ã¨ã‚’指定ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ ã“ã®æŒ‡å®šã¯ @NonNull 〠@CheckForNull ã€ã¾ãŸã¯ @CheckReturnValueãªã©ã«ä½¿ç”¨ã™ã‚‹æƒ³å®šã§ã™ã€‚ -具体的ã«ã¯ã€ クラスã¾ãŸã¯ãƒ‘ッケージ㫠@DefaultAnnotation(NonNull.class) を指定ã—ãŸä¸Šã§ã€ +具体的ã«ã¯ã€ クラスã¾ãŸã¯ãƒ‘ッケージ㫠@DefaultAnnotation(NonNull.class) を指定ã—ãŸä¸Šã§ã€ null を許容ã—ãŸã„パラメーターã€ãƒ¡ã‚½ãƒƒãƒ‰ã¾ãŸã¯ãƒ•ã‚£ãƒ¼ãƒ«ãƒ‰ã«ã®ã¿ @Nullable を指定ã™ã‚‹ã¨ã„ã†ä½¿ç”¨æ–¹æ³•ãŒã‚ã‚Šã¾ã™ã€‚ Please report bugs using the -Sourceforge -bugs tracker. Note that you need to be logged in to sourceforge to +GitHub +bugs tracker. Note that you need to be logged in to GitHub to use the bug tracker.
-If you cannot use the Sourceforge tracker, you can try sending +If you cannot use the GitHub tracker, you can try sending email to the findbugs-discuss mailing list. You must be subscribed to the list to post a message. diff --git a/src/doc/sysprops.html b/src/doc/sysprops.html index f68c330..2c71747 100644 --- a/src/doc/sysprops.html +++ b/src/doc/sysprops.html @@ -68,7 +68,7 @@
findbugs.sf.comment -Ignore switch fall thru bugs if a comment is found with 'fall' or 'nobreak' + Ignore switch fall through bugs if a comment is found with 'fall' or 'nobreak' ba.checkAssertions diff --git a/src/doc/updateChecking.html b/src/doc/updateChecking.html index c591381..0f59202 100644 --- a/src/doc/updateChecking.html +++ b/src/doc/updateChecking.html @@ -60,13 +60,13 @@- You can also redirect all update checks to a local server. This allows you to collect information about who is using what versions of FindBugs in your organization, and keep all of that information private.
- All of the plugins from the FindBugs project use
http://update.findbugs.org/update-checkas the -host we use for update checks. If you wish to ensure that no one from your organization accidently reports any usage +host we use for update checks. If you wish to ensure that no one from your organization accidentally reports any usage information to the FindBugs project, you can blacklist that URL in your firewalldiff --git a/src/doc/users.html b/src/doc/users.html index 14e51aa..4e6c2ad 100644 --- a/src/doc/users.html +++ b/src/doc/users.html @@ -54,7 +54,7 @@
- You can also block
http://findbugs-cloud.appspot.com, the host we use for our publicly hosted repository of bug evaluations (e.g., evaluations in open source projects such as the JDK, Eclipse and GlassFish). While people have to explicitly request that their evaluations be stored into the FindBugs cloud, you -can block it to ensure that no one accidently shares evaluations of your own code to the FindBugs cloud. You can also +can block it to ensure that no one accidentally shares evaluations of your own code to the FindBugs cloud. You can also remove the WebCloudClientThe following companies, projects and organizations have given us permission to identify them as FindBugs users and/or have - publically stated that they use FindBugs. Send email to + publicly stated that they use FindBugs. Send email to findbugs@cs.umd.edu if you'd like to be listed here.
diff --git a/src/gui/edu/umd/cs/findbugs/gui2/BugSaver.java b/src/gui/edu/umd/cs/findbugs/gui2/BugSaver.java index fe9763c..5b22849 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/BugSaver.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/BugSaver.java @@ -54,7 +54,7 @@ saveBugs(UTF8.fileWriter(out), data, p); lastPlaceSaved = out.getAbsolutePath(); } catch (IOException e) { - JOptionPane.showMessageDialog(null, "An error has occured in saving your file"); + JOptionPane.showMessageDialog(null, "An error has occurred in saving your file"); } } diff --git a/src/gui/edu/umd/cs/findbugs/gui2/BugTreeModel.java b/src/gui/edu/umd/cs/findbugs/gui2/BugTreeModel.java index cbe5b6c..d5677bb 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/BugTreeModel.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/BugTreeModel.java @@ -45,7 +45,7 @@ * Our TreeModel. Once upon a time it was a simple model, that queried data, its BugSet, for what to show under each branch * Then it got more and more complicated, no one knows why it still seems to work... or why it doesn't if it in fact doesn't. * - * Here's a tip, Dont even attempt to deal with suppressions or filtering and their related tree model events without the API + * Here's a tip, Don't even attempt to deal with suppressions or filtering and their related tree model events without the API * for TreeModelEvents open. And read it three times first. Ignore the fact that its inconsistent for sending events about the root, just pick one of the things it says and go with it * * Heres the order things MUST be done when dealing with suppressions, filtering, unsuppressions... unfiltering... all that fun stuff @@ -354,8 +354,8 @@ // If this thread is not interrupting a previous thread, set the paths // to be opened when the new tree is complete - // If the thread is interrupting another thread, dont do this, because - // you dont have the tree with the correct paths selected + // If the thread is interrupting another thread, don't do this, because + // you don't have the tree with the correct paths selected // As of now, it should be impossible to interrupt a rebuilding thread, // in another version this may change, so this if statement check is @@ -754,7 +754,7 @@ void sendEvent(TreeModelEvent event, TreeModification whatToDo) { Debug.println("Sending An Event!"); if (event == null) { - throw new IllegalStateException("Dont throw null events."); + throw new IllegalStateException("Don't throw null events."); } resetData(); for (TreeModelListener l : listeners) { diff --git a/src/gui/edu/umd/cs/findbugs/gui2/GUISaveState.java b/src/gui/edu/umd/cs/findbugs/gui2/GUISaveState.java index 90d5662..6f93d75 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/GUISaveState.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/GUISaveState.java @@ -53,7 +53,7 @@ * */ /* - * GUISaveState uses the Preferences API, dont look for a file anywhere, there + * GUISaveState uses the Preferences API, don't look for a file anywhere, there * isn't one, well... there might be, but its all system dependent where it is * and how its stored */ @@ -67,7 +67,7 @@ private static final String FRAME_BOUNDS = "Frame Bounds"; private static final String EXTENDED_WINDOW_STATE = "ExtendedWindowState"; - private static final int MAXNUMRECENTPROJECTS = 5; + static final int MAXNUMRECENTPROJECTS = 10; private static final Sortables[] DEFAULT_COLUMN_HEADERS = new Sortables[] { Sortables.CATEGORY, Sortables.BUGCODE, Sortables.TYPE, Sortables.DIVIDER, Sortables.BUG_RANK, Sortables.FIRST_SEEN, Sortables.DESIGNATION }; diff --git a/src/gui/edu/umd/cs/findbugs/gui2/MainFrame.java b/src/gui/edu/umd/cs/findbugs/gui2/MainFrame.java index da3d3f6..896215e 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/MainFrame.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/MainFrame.java @@ -544,7 +544,7 @@ if (bugCollection != null) { displayer.clearCache(); BugSet bs = new BugSet(bugCollection); - // Dont clear data, the data's correct, just get the tree off the + // Don't clear data, the data's correct, just get the tree off the // listener lists. BugTreeModel model = (BugTreeModel) mainFrameTree.getTree().getModel(); model.getOffListenerList(); diff --git a/src/gui/edu/umd/cs/findbugs/gui2/MainFrameLoadSaveHelper.java b/src/gui/edu/umd/cs/findbugs/gui2/MainFrameLoadSaveHelper.java index 863a103..0066feb 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/MainFrameLoadSaveHelper.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/MainFrameLoadSaveHelper.java @@ -118,7 +118,7 @@ final File f = saveOpenFileChooser.getSelectedFile(); if (!fileType.isValid(f)) { - JOptionPane.showMessageDialog(saveOpenFileChooser, "That file is not compatible with the choosen file type", + JOptionPane.showMessageDialog(saveOpenFileChooser, "That file is not compatible with the chosen file type", "Invalid File", JOptionPane.WARNING_MESSAGE); loading = true; continue; diff --git a/src/gui/edu/umd/cs/findbugs/gui2/MainFrameTree.java b/src/gui/edu/umd/cs/findbugs/gui2/MainFrameTree.java index d4d6902..97fbe25 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/MainFrameTree.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/MainFrameTree.java @@ -633,7 +633,7 @@ if (!(path.getParentPath() == null)) { // path is null, the // root was selected, - // dont allow them to + // don't allow them to // filter out the root. branchPopupMenu.show(tree, e.getX(), e.getY()); } diff --git a/src/gui/edu/umd/cs/findbugs/gui2/NewProjectWizard.java b/src/gui/edu/umd/cs/findbugs/gui2/NewProjectWizard.java index c6d06cb..6baa13f 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/NewProjectWizard.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/NewProjectWizard.java @@ -187,7 +187,7 @@ wizardComponents[1] = createFilePanel( edu.umd.cs.findbugs.L10N.getLocalString("dlg.aux_class_lbl", "Auxiliary class locations:"), auxList, auxModel, - JFileChooser.FILES_AND_DIRECTORIES, directoryOrArchive, "Choose Auxilliary Class Archives and Directories", false, + JFileChooser.FILES_AND_DIRECTORIES, directoryOrArchive, "Choose Auxiliary Class Archives and Directories", false, "http://findbugs.sourceforge.net/FAQ.html#q4"); wizardComponents[2] = createFilePanel( diff --git a/src/gui/edu/umd/cs/findbugs/gui2/RecentMenu.java b/src/gui/edu/umd/cs/findbugs/gui2/RecentMenu.java index d6be279..cf92dfa 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/RecentMenu.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/RecentMenu.java @@ -30,7 +30,7 @@ public class RecentMenu { private static class LimitedArrayListextends ArrayList { - public static final int MAX_ENTRIES = 5; + public static final int MAX_ENTRIES = GUISaveState.MAXNUMRECENTPROJECTS; public LimitedArrayList() { super(MAX_ENTRIES); diff --git a/src/gui/edu/umd/cs/findbugs/gui2/SorterTableColumnModel.java b/src/gui/edu/umd/cs/findbugs/gui2/SorterTableColumnModel.java index be023cf..67ae383 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/SorterTableColumnModel.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/SorterTableColumnModel.java @@ -287,7 +287,7 @@ public int getColumnIndex(Object columnIdentifier) { if (columnIdentifier == null) { - throw new IllegalArgumentException("Dont send null to getColumnIndex, null shouldn't be in the sorting table."); + throw new IllegalArgumentException("Don't send null to getColumnIndex, null shouldn't be in the sorting table."); } for (int x = 0; x < columnList.size(); x++) { diff --git a/src/gui/edu/umd/cs/findbugs/gui2/StackedFilterMatcher.java b/src/gui/edu/umd/cs/findbugs/gui2/StackedFilterMatcher.java index c7dbe78..75fd2c6 100644 --- a/src/gui/edu/umd/cs/findbugs/gui2/StackedFilterMatcher.java +++ b/src/gui/edu/umd/cs/findbugs/gui2/StackedFilterMatcher.java @@ -134,7 +134,7 @@ (MainFrame.getInstance().getBugTreeModel()).sendEvent(event, whatToDo); } catch (BranchOperationException e) { // Another filter already filters out the branch this filter - // would filter out, set active, but dont send any tree model + // would filter out, set active, but don't send any tree model // events. this.active = active; } diff --git a/src/java/edu/umd/cs/findbugs/BugInstance.java b/src/java/edu/umd/cs/findbugs/BugInstance.java index d32ae07..5a0a0bc 100644 --- a/src/java/edu/umd/cs/findbugs/BugInstance.java +++ b/src/java/edu/umd/cs/findbugs/BugInstance.java @@ -462,7 +462,7 @@ } /** - * Get the primary method annotation, which indicates where the bug occurs. + * Get the primary field annotation, which indicates where the bug occurs. */ @CheckForNull public FieldAnnotation getPrimaryField() { diff --git a/src/java/edu/umd/cs/findbugs/BugRanker.java b/src/java/edu/umd/cs/findbugs/BugRanker.java index c319871..efdd2c7 100644 --- a/src/java/edu/umd/cs/findbugs/BugRanker.java +++ b/src/java/edu/umd/cs/findbugs/BugRanker.java @@ -51,7 +51,7 @@ * * A bug ranker is comprised of a list of bug patterns, bug kinds and bug * categories. For each, either an absolute or relative bug rank is provided. A - * relative rank is one preceeded by a + or -. + * relative rank is one preceded by a + or -. * * For core bug detectors, the bug ranker search order is: * diff --git a/src/java/edu/umd/cs/findbugs/CheckBcel.java b/src/java/edu/umd/cs/findbugs/CheckBcel.java index 5b60878..2ebc7f0 100644 --- a/src/java/edu/umd/cs/findbugs/CheckBcel.java +++ b/src/java/edu/umd/cs/findbugs/CheckBcel.java @@ -78,7 +78,7 @@ * name of the BCEL class */ private static void error(String cname) { - System.err.println("BCEL class compatability error."); + System.err.println("BCEL class compatibility error."); System.err.println("The version of class " + cname + " found was not compatible with\n" + "FindBugs. Please remove any BCEL libraries that may be interfering. This may happen\n" + "if you have an old version of BCEL or a library that includes an old version of BCEL\n" diff --git a/src/java/edu/umd/cs/findbugs/ClassAnnotation.java b/src/java/edu/umd/cs/findbugs/ClassAnnotation.java index a0af44c..420fb6e 100644 --- a/src/java/edu/umd/cs/findbugs/ClassAnnotation.java +++ b/src/java/edu/umd/cs/findbugs/ClassAnnotation.java @@ -44,6 +44,8 @@ public static final String SUBCLASS_ROLE = "CLASS_SUBCLASS"; public static final String SUPERCLASS_ROLE = "CLASS_SUPERCLASS"; + + public static final String ANONYMOUS_ROLE = "CLASS_ANONYMOUS"; public static final String RECOMMENDED_SUPERCLASS_ROLE = "CLASS_RECOMMENDED_SUPERCLASS"; diff --git a/src/java/edu/umd/cs/findbugs/FieldWarningSuppressor.java b/src/java/edu/umd/cs/findbugs/FieldWarningSuppressor.java index 3742561..f393b11 100644 --- a/src/java/edu/umd/cs/findbugs/FieldWarningSuppressor.java +++ b/src/java/edu/umd/cs/findbugs/FieldWarningSuppressor.java @@ -12,7 +12,7 @@ @Override public String toString() { - return String.format("Supress %s in %s.%s", bugPattern, clazz, field); + return String.format("Suppress %s in %s.%s", bugPattern, clazz, field); } @Override public boolean match(BugInstance bugInstance) { diff --git a/src/java/edu/umd/cs/findbugs/FindBugsAnnotationDescriptions.properties b/src/java/edu/umd/cs/findbugs/FindBugsAnnotationDescriptions.properties index e4ca0a4..8689858 100644 --- a/src/java/edu/umd/cs/findbugs/FindBugsAnnotationDescriptions.properties +++ b/src/java/edu/umd/cs/findbugs/FindBugsAnnotationDescriptions.properties @@ -3,6 +3,7 @@ CLASS_REFTYPE =Reference type {0} CLASS_SUBCLASS =has subclass {0} CLASS_SUPERCLASS =superclass is {0} +CLASS_ANONYMOUS =Anonymous class {0} CLASS_RECOMMENDED_SUPERCLASS =Perhaps class should be refactored to extend {0} CLASS_IMPLEMENTED_INTERFACE =implements interface {0} CLASS_ANNOTATION =annotated with {0.simpleName} diff --git a/src/java/edu/umd/cs/findbugs/FuzzyBugComparator.java b/src/java/edu/umd/cs/findbugs/FuzzyBugComparator.java index aed1395..d854297 100644 --- a/src/java/edu/umd/cs/findbugs/FuzzyBugComparator.java +++ b/src/java/edu/umd/cs/findbugs/FuzzyBugComparator.java @@ -277,7 +277,7 @@ } /** - * For now, just look at the 2 preceeding and succeeding opcodes for fuzzy + * For now, just look at the 2 preceding and succeeding opcodes for fuzzy * source line matching. */ // private static final int NUM_CONTEXT_OPCODES = 2; diff --git a/src/java/edu/umd/cs/findbugs/JavaVersion.java b/src/java/edu/umd/cs/findbugs/JavaVersion.java index f293cf3..536e38f 100644 --- a/src/java/edu/umd/cs/findbugs/JavaVersion.java +++ b/src/java/edu/umd/cs/findbugs/JavaVersion.java @@ -19,14 +19,10 @@ package edu.umd.cs.findbugs; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * Support for finding out what version of Java we're running on. */ public class JavaVersion { - private static final Pattern PATTERN = Pattern.compile("^(\\d+)\\.(\\d+)(\\..*)?$"); private final int major; @@ -43,9 +39,8 @@ try { runtimeVersion = new JavaVersion(SystemProperties.getProperty("java.version")); } catch (JavaVersionException e) { - System.err.println("Warning: Unknown version of Java"); - // Assume Java 1.0. - runtimeVersion = new JavaVersion(1, 0); + // Assume Java 1.8. + runtimeVersion = new JavaVersion(1, 8); e.printStackTrace(); } } @@ -63,17 +58,31 @@ *
java.version
system property: e.g., "1.4.2_04" */ public JavaVersion(String versionString) throws JavaVersionException { - Matcher matcher = PATTERN.matcher(versionString); - if (!matcher.matches()) { - throw new JavaVersionException("Could not parse Java version string: " + versionString); - } + // See https://bugs.openjdk.java.net/browse/JDK-8061493 for http://openjdk.java.net/jeps/223 + // The only common between pre-9 and 9+ are the dots as separators... + String[] strings = versionString.split("\\.", 3); try { - major = Integer.parseInt(matcher.group(1)); - minor = Integer.parseInt(matcher.group(2)); - if (matcher.group(3) != null) { - rest = matcher.group(3); + // We need only care about 9+ early access in first segment + int earlyAccess = strings[0].indexOf('-'); + if(earlyAccess > 0){ + // 9+ early access versions do not follow common scheme above (it would be too easy) + // they look like 9-ea+73 and have only one meaningful (major) part for us. + major = Integer.parseInt(strings[0].substring(0, earlyAccess)); + minor = 0; + rest = strings[0].substring(earlyAccess); } else { - rest = ""; + major = Integer.parseInt(strings[0]); + if(strings.length > 1){ + minor = Integer.parseInt(strings[1]); + if (strings.length > 2) { + rest = strings[2]; + } else { + rest = ""; + } + } else { + minor = 0; + rest = ""; + } } } catch (NumberFormatException e) { throw new JavaVersionException("Could not parse Java Version string: " + versionString, e); diff --git a/src/java/edu/umd/cs/findbugs/OpcodeStack.java b/src/java/edu/umd/cs/findbugs/OpcodeStack.java index 6564b6c..ef986a5 100644 --- a/src/java/edu/umd/cs/findbugs/OpcodeStack.java +++ b/src/java/edu/umd/cs/findbugs/OpcodeStack.java @@ -2634,7 +2634,8 @@ i.setSpecialKind(Item.NON_NEGATIVE); } push(i); - } else if("java/lang/String".equals(clsName) && numberArguments == 0 && topItem.getConstant() instanceof String) { + } else if("java/lang/String".equals(clsName) && numberArguments == 0 && topItem != null && + topItem.getConstant() instanceof String) { String input = (String) topItem.getConstant(); Object result; switch(methodName) { diff --git a/src/java/edu/umd/cs/findbugs/PluginLoader.java b/src/java/edu/umd/cs/findbugs/PluginLoader.java index efc3fdb..adaca64 100644 --- a/src/java/edu/umd/cs/findbugs/PluginLoader.java +++ b/src/java/edu/umd/cs/findbugs/PluginLoader.java @@ -213,7 +213,7 @@ classLoader = new URLClassLoader(loaderURLs, parent); } else { if (parent != PluginLoader.class.getClassLoader()) { - throw new IllegalArgumentException("Can't specify parentid " + parentId + " and provide a seperate class loader"); + throw new IllegalArgumentException("Can't specify parentid " + parentId + " and provide a separate class loader"); } Plugin parentPlugin = Plugin.getByPluginId(parentId); if (parentPlugin != null) { diff --git a/src/java/edu/umd/cs/findbugs/StackMapAnalyzer.java b/src/java/edu/umd/cs/findbugs/StackMapAnalyzer.java index 91b54b7..99ec25c 100644 --- a/src/java/edu/umd/cs/findbugs/StackMapAnalyzer.java +++ b/src/java/edu/umd/cs/findbugs/StackMapAnalyzer.java @@ -30,14 +30,14 @@ import javax.annotation.CheckForNull; -import org.apache.bcel.Constants; +import org.apache.bcel.Const; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.ClassFormatException; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.Method; -import org.apache.bcel.classfile.StackMapTable; -import org.apache.bcel.classfile.StackMapTableEntry; +import org.apache.bcel.classfile.StackMap; +import org.apache.bcel.classfile.StackMapEntry; import org.apache.bcel.classfile.StackMapType; import org.apache.bcel.generic.Type; @@ -84,20 +84,20 @@ SAME_FRAME, SAME_LOCALS_1_STACK_ITEM_FRAME, CHOP_FRAME, APPEND_FRAME, FULL_FRAME; static StackFrameType get(int frame_type) { - if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) { + if (frame_type >= Const.SAME_FRAME && frame_type <= Const.SAME_FRAME_MAX) { return SAME_FRAME; - } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME - && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + } else if (frame_type >= Const.SAME_LOCALS_1_STACK_ITEM_FRAME + && frame_type <= Const.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { return SAME_LOCALS_1_STACK_ITEM_FRAME; - } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { + } else if (frame_type == Const.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { return SAME_LOCALS_1_STACK_ITEM_FRAME; - } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) { + } else if (frame_type >= Const.CHOP_FRAME && frame_type <= Const.CHOP_FRAME_MAX) { return CHOP_FRAME; - } else if (frame_type == Constants.SAME_FRAME_EXTENDED) { + } else if (frame_type == Const.SAME_FRAME_EXTENDED) { return SAME_FRAME; - } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) { + } else if (frame_type >= Const.APPEND_FRAME && frame_type <= Const.APPEND_FRAME_MAX) { return APPEND_FRAME; - } else if (frame_type == Constants.FULL_FRAME) { + } else if (frame_type == Const.FULL_FRAME) { return FULL_FRAME; } else { /* Can't happen */ @@ -106,10 +106,10 @@ } } - static @CheckForNull StackMapTable getStackMapTable(Code code) { + static @CheckForNull StackMap getStackMapTable(Code code) { for(Attribute a : code.getAttributes()) { - if (a instanceof StackMapTable) { - return (StackMapTable) a; + if (a instanceof StackMap) { + return (StackMap) a; } } return null; @@ -143,7 +143,7 @@ @Override public Field run() { - Classc = StackMapTableEntry.class; + Class c = StackMapEntry.class; Field result; try { result = c.getDeclaredField("frame_type"); @@ -168,7 +168,7 @@ frame_type_field = f; } - static int getFrameType(StackMapTableEntry e) { + static int getFrameType(StackMapEntry e) { if (frame_type_field == null) { return -1; } @@ -197,7 +197,7 @@ if (code == null) { return null; } - StackMapTable stackMapTable = getStackMapTable(code); + StackMap stackMapTable = getStackMapTable(code); if (stackMapTable == null) { return null; } @@ -213,8 +213,8 @@ System.out.println(locals); } int pc = 0; - for(StackMapTableEntry e : stackMapTable.getStackMapTable()) { - pc += e.getByteCodeOffsetDelta(); + for(StackMapEntry e : stackMapTable.getStackMap()) { + pc += e.getByteCodeOffset(); int rawFrameType = getFrameType(e); StackFrameType stackFrameType = StackFrameType.get(rawFrameType); switch (stackFrameType) { @@ -227,7 +227,7 @@ break; case CHOP_FRAME : stack.clear(); - int n = Constants.CHOP_FRAME_MAX+1-rawFrameType; + int n = Const.CHOP_FRAME_MAX+1-rawFrameType; for(int i = 0; i < n; i++) { Item it = locals.remove(locals.size()-1); if (it == null) { @@ -277,24 +277,24 @@ switch (t.getType()) { - case Constants.ITEM_Double: + case Const.ITEM_Double: return Item.typeOnly("D"); - case Constants.ITEM_Float: + case Const.ITEM_Float: return Item.typeOnly("F"); - case Constants.ITEM_Integer: + case Const.ITEM_Integer: return Item.typeOnly("I"); - case Constants.ITEM_Long: + case Const.ITEM_Long: return Item.typeOnly("J"); - case Constants.ITEM_Bogus: - case Constants.ITEM_NewObject: + case Const.ITEM_Bogus: + case Const.ITEM_NewObject: return Item.typeOnly("Ljava/lang/Object;"); - case Constants.ITEM_Null: + case Const.ITEM_Null: Item it = new Item(); it.setSpecialKind(Item.TYPE_ONLY); return it; - case Constants.ITEM_InitObject: + case Const.ITEM_InitObject: return Item.typeOnly("Ljava/lang/Object;"); - case Constants.ITEM_Object: + case Const.ITEM_Object: int index = t.getIndex(); ConstantClass c = (ConstantClass) t.getConstantPool().getConstant(index); String name = c.getBytes(t.getConstantPool()); diff --git a/src/java/edu/umd/cs/findbugs/SwitchHandler.java b/src/java/edu/umd/cs/findbugs/SwitchHandler.java index 976f1e9..856b0a8 100644 --- a/src/java/edu/umd/cs/findbugs/SwitchHandler.java +++ b/src/java/edu/umd/cs/findbugs/SwitchHandler.java @@ -28,7 +28,6 @@ import edu.umd.cs.findbugs.ba.XClass; import edu.umd.cs.findbugs.ba.XField; -import edu.umd.cs.findbugs.util.ClassName; import edu.umd.cs.findbugs.visitclass.DismantleBytecode; public class SwitchHandler { @@ -46,10 +45,8 @@ return -1; } int total = 0; - String enumSignature = ClassName.toSignature(c.getClassDescriptor().getClassName()); for(XField f : c.getXFields()) { - if (f.getSignature().equals(enumSignature) - && f.isPublic() && f.isFinal()) { + if (f.isEnum()) { total++; } } diff --git a/src/java/edu/umd/cs/findbugs/Version.java b/src/java/edu/umd/cs/findbugs/Version.java index 40c7905..d515bb9 100644 --- a/src/java/edu/umd/cs/findbugs/Version.java +++ b/src/java/edu/umd/cs/findbugs/Version.java @@ -49,12 +49,12 @@ /** * Minor version number. */ - public static final int MINOR = 0; + public static final int MINOR = 1; /** * Patch level. */ - public static final int PATCHLEVEL = 1; + public static final int PATCHLEVEL = 0; /** * Development version or release candidate? diff --git a/src/java/edu/umd/cs/findbugs/annotations/Confidence.java b/src/java/edu/umd/cs/findbugs/annotations/Confidence.java index efeb725..b6ce7a4 100644 --- a/src/java/edu/umd/cs/findbugs/annotations/Confidence.java +++ b/src/java/edu/umd/cs/findbugs/annotations/Confidence.java @@ -21,14 +21,14 @@ import javax.annotation.Nonnull; -import edu.umd.cs.findbugs.Priorities; - /** * Describes the confidence with which FindBugs reports a bug instance. */ public enum Confidence { - HIGH(Priorities.HIGH_PRIORITY), MEDIUM(Priorities.NORMAL_PRIORITY), LOW(Priorities.LOW_PRIORITY), IGNORE( - Priorities.IGNORE_PRIORITY); + HIGH(1 /* Priorities.HIGH_PRIORITY */), + MEDIUM(2 /* Priorities.NORMAL_PRIORITY */ ), + LOW(3 /* Priorities.LOW_PRIORITY */), + IGNORE(5 /*Priorities.IGNORE_PRIORITY */); private final int confidenceValue; diff --git a/src/java/edu/umd/cs/findbugs/annotations/DesireWarning.java b/src/java/edu/umd/cs/findbugs/annotations/DesireWarning.java index e003b7f..3484b2b 100644 --- a/src/java/edu/umd/cs/findbugs/annotations/DesireWarning.java +++ b/src/java/edu/umd/cs/findbugs/annotations/DesireWarning.java @@ -7,8 +7,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; - -import edu.umd.cs.findbugs.BugRanker; /** * Annotation indicating that a FindBugs warning is desired. @@ -29,7 +27,7 @@ public Confidence confidence() default Confidence.LOW; /** Desire a warning at least this scary */ - public int rank() default BugRanker.VISIBLE_RANK_MAX; + public int rank() default 20; // BugRanker.VISIBLE_RANK_MAX /** Desire at least this many warnings */ public int num() default 1; diff --git a/src/java/edu/umd/cs/findbugs/annotations/ExpectWarning.java b/src/java/edu/umd/cs/findbugs/annotations/ExpectWarning.java index 5c2abe2..ae6394d 100644 --- a/src/java/edu/umd/cs/findbugs/annotations/ExpectWarning.java +++ b/src/java/edu/umd/cs/findbugs/annotations/ExpectWarning.java @@ -7,8 +7,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; - -import edu.umd.cs.findbugs.BugRanker; /** * Annotation indicating that a FindBugs warning is expected. @@ -29,7 +27,7 @@ public Confidence confidence() default Confidence.LOW; /** Expect a warning at least this scary */ - public int rank() default BugRanker.VISIBLE_RANK_MAX; + public int rank() default 20; // BugRanker.VISIBLE_RANK_MAX /** Expect at least this many warnings */ public int num() default 1; diff --git a/src/java/edu/umd/cs/findbugs/annotations/NoWarning.java b/src/java/edu/umd/cs/findbugs/annotations/NoWarning.java index 0f95420..d842339 100644 --- a/src/java/edu/umd/cs/findbugs/annotations/NoWarning.java +++ b/src/java/edu/umd/cs/findbugs/annotations/NoWarning.java @@ -7,8 +7,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; - -import edu.umd.cs.findbugs.BugRanker; /** * Annotation indicating that no FindBugs warning is expected. @@ -29,7 +27,7 @@ public Confidence confidence() default Confidence.LOW; /** Want no warning at this rank or scarier */ - public int rank() default BugRanker.VISIBLE_RANK_MAX; + public int rank() default 20; // BugRanker.VISIBLE_RANK_MAX /** Tolerate up to this many warnings */ public int num() default 0; diff --git a/src/java/edu/umd/cs/findbugs/annotations/Priority.java b/src/java/edu/umd/cs/findbugs/annotations/Priority.java index cdfa2e0..bc5a17b 100644 --- a/src/java/edu/umd/cs/findbugs/annotations/Priority.java +++ b/src/java/edu/umd/cs/findbugs/annotations/Priority.java @@ -19,7 +19,6 @@ package edu.umd.cs.findbugs.annotations; -import edu.umd.cs.findbugs.Priorities; /** * @author pugh @@ -27,8 +26,10 @@ */ @Deprecated public enum Priority { - HIGH(Priorities.HIGH_PRIORITY), MEDIUM(Priorities.NORMAL_PRIORITY), LOW(Priorities.LOW_PRIORITY), IGNORE( - Priorities.IGNORE_PRIORITY); + HIGH(1 /* Priorities.HIGH_PRIORITY */), + MEDIUM(2 /* Priorities.NORMAL_PRIORITY */ ), + LOW(3 /* Priorities.LOW_PRIORITY */), + IGNORE(5 /*Priorities.IGNORE_PRIORITY */); private final int priorityValue; diff --git a/src/java/edu/umd/cs/findbugs/ba/AbstractField.java b/src/java/edu/umd/cs/findbugs/ba/AbstractField.java index 203b242..6481875 100644 --- a/src/java/edu/umd/cs/findbugs/ba/AbstractField.java +++ b/src/java/edu/umd/cs/findbugs/ba/AbstractField.java @@ -41,6 +41,11 @@ return (getAccessFlags() & Constants.ACC_SYNTHETIC) != 0; } + @Override + public boolean isEnum() { + return (getAccessFlags() & Constants.ACC_ENUM) != 0; + } + /* * (non-Javadoc) * diff --git a/src/java/edu/umd/cs/findbugs/ba/AbstractFrameModelingVisitor.java b/src/java/edu/umd/cs/findbugs/ba/AbstractFrameModelingVisitor.java index 52468c9..68f3acd 100644 --- a/src/java/edu/umd/cs/findbugs/ba/AbstractFrameModelingVisitor.java +++ b/src/java/edu/umd/cs/findbugs/ba/AbstractFrameModelingVisitor.java @@ -50,7 +50,7 @@ * @see Frame * @see DataflowAnalysis */ -public abstract class AbstractFrameModelingVisitor > implements VisitorSupportsInvokeDynamic { +public abstract class AbstractFrameModelingVisitor > implements Visitor { private FrameType frame; private Location location; diff --git a/src/java/edu/umd/cs/findbugs/ba/AnalysisContext.java b/src/java/edu/umd/cs/findbugs/ba/AnalysisContext.java index 8b53002..5d45ff3 100644 --- a/src/java/edu/umd/cs/findbugs/ba/AnalysisContext.java +++ b/src/java/edu/umd/cs/findbugs/ba/AnalysisContext.java @@ -33,8 +33,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; - -import net.jcip.annotations.NotThreadSafe; import org.apache.bcel.Repository; import org.apache.bcel.classfile.JavaClass; @@ -70,6 +68,7 @@ import edu.umd.cs.findbugs.detect.UnreadFieldsData; import edu.umd.cs.findbugs.internalAnnotations.DottedClassName; import edu.umd.cs.findbugs.util.ClassName; +import net.jcip.annotations.NotThreadSafe; /** * A context for analysis of a complete project. This serves as the repository @@ -542,7 +541,12 @@ } JavaClass clazz = originalRepository.findClass(className); - return (clazz == null ? originalRepository.loadClass(className) : clazz); + if(clazz != null){ + return clazz; + } + // XXX workaround for system classes missing on Java 9 + // Not sure if we BCEL update, but this seem to work in simple cases + return AnalysisContext.currentAnalysisContext().lookupClass(className); } /** diff --git a/src/java/edu/umd/cs/findbugs/ba/ClassContext.java b/src/java/edu/umd/cs/findbugs/ba/ClassContext.java index e0d609b..f844c70 100644 --- a/src/java/edu/umd/cs/findbugs/ba/ClassContext.java +++ b/src/java/edu/umd/cs/findbugs/ba/ClassContext.java @@ -807,23 +807,26 @@ if (newLine == lineNum || newLine == -1) { continue; } + if (prevStartPc >= 0) { int nextPcInFinallyBlock = pcInFinallyBlock.nextSetBit(prevStartPc); - if (nextPcInFinallyBlock < line.getStartPC()) { + if ( prevStartPc < nextPcInFinallyBlock && nextPcInFinallyBlock < line.getStartPC()) { lineMentionedMultipleTimes.set(lineNum); } } + if (line.getStartPC() >= firstHandler) { afterHandler.set(lineNum); + afterHandler.set(newLine); } - lineNum = newLine; - prevStartPc = line.getStartPC(); + if (foundOnce.get(lineNum)) { lineMentionedMultipleTimes.set(lineNum); } else { foundOnce.set(lineNum); } + prevStartPc = line.getStartPC(); } } lineMentionedMultipleTimes.and(afterHandler); diff --git a/src/java/edu/umd/cs/findbugs/ba/DefaultNullnessAnnotations.java b/src/java/edu/umd/cs/findbugs/ba/DefaultNullnessAnnotations.java index ac22356..ef2aaaa 100644 --- a/src/java/edu/umd/cs/findbugs/ba/DefaultNullnessAnnotations.java +++ b/src/java/edu/umd/cs/findbugs/ba/DefaultNullnessAnnotations.java @@ -190,7 +190,9 @@ database.addMethodParameterAnnotation("java.util.concurrent.ConcurrentHashMap", "setEntryAt", "([Ljava/util/concurrent/ConcurrentHashMap$HashEntry;ILjava/util/concurrent/ConcurrentHashMap$HashEntry;)V", false, 1, NullnessAnnotation.NULLABLE); database.addMethodParameterAnnotation("java.util.concurrent.ForkJoinPool", " ", - "(ILjava/util/concurrent/ForkJoinPool$ForkJoinWorkerThreadFactory;Ljava/lang/Thread$UncaughtExceptionHandler;Z)V", false, 1, NullnessAnnotation.NULLABLE); + "(ILjava/util/concurrent/ForkJoinPool$ForkJoinWorkerThreadFactory;Ljava/lang/Thread$UncaughtExceptionHandler;Z)V", false, 1, NullnessAnnotation.NONNULL); + database.addMethodParameterAnnotation("java.util.concurrent.ForkJoinPool", " ", + "(ILjava/util/concurrent/ForkJoinPool$ForkJoinWorkerThreadFactory;Ljava/lang/Thread$UncaughtExceptionHandler;Z)V", false, 2, NullnessAnnotation.NULLABLE); database.addMethodParameterAnnotation("java.util.concurrent.PriorityBlockingQueue", " ", "(ILjava/util/Comparator;)V", false, 1, NullnessAnnotation.NULLABLE); diff --git a/src/java/edu/umd/cs/findbugs/ba/Hierarchy2.java b/src/java/edu/umd/cs/findbugs/ba/Hierarchy2.java index 0ae4fce..804da44 100644 --- a/src/java/edu/umd/cs/findbugs/ba/Hierarchy2.java +++ b/src/java/edu/umd/cs/findbugs/ba/Hierarchy2.java @@ -312,6 +312,11 @@ return Collections. emptySet(); } + // XXX handle INVOKEDYNAMIC + if (opcode == Constants.INVOKEDYNAMIC) { + return Collections. emptySet(); + } + Type receiverType; boolean receiverTypeIsExact; diff --git a/src/java/edu/umd/cs/findbugs/ba/NullnessAnnotation.java b/src/java/edu/umd/cs/findbugs/ba/NullnessAnnotation.java index 3babf9f..65c45d7 100644 --- a/src/java/edu/umd/cs/findbugs/ba/NullnessAnnotation.java +++ b/src/java/edu/umd/cs/findbugs/ba/NullnessAnnotation.java @@ -48,7 +48,7 @@ return CHECK_FOR_NULL; } // Unfortunately there are mixed case Nonnull and NonNull annotations (JSR305, FB and JDT) - if (className.endsWith("Nonnull")) { + if (className.endsWith("Nonnull") || className.equals("org.jetbrains.annotations.NotNull")) { return NONNULL; } for (NullnessAnnotation v : myValues) { diff --git a/src/java/edu/umd/cs/findbugs/ba/PruneInfeasibleExceptionEdges.java b/src/java/edu/umd/cs/findbugs/ba/PruneInfeasibleExceptionEdges.java index 6c0a06a..400bac8 100644 --- a/src/java/edu/umd/cs/findbugs/ba/PruneInfeasibleExceptionEdges.java +++ b/src/java/edu/umd/cs/findbugs/ba/PruneInfeasibleExceptionEdges.java @@ -61,7 +61,7 @@ } /** - * A momento to remind us of how we classified a particular exception edge. + * A memento to remind us of how we classified a particular exception edge. * If pruning and classifying succeeds, then these momentos can be applied * to actually change the state of the edges. The issue is that the entire * pruning/classifying operation must either fail or succeed as a whole. diff --git a/src/java/edu/umd/cs/findbugs/ba/RepositoryClassParser.java b/src/java/edu/umd/cs/findbugs/ba/RepositoryClassParser.java index fc54152..63efd51 100644 --- a/src/java/edu/umd/cs/findbugs/ba/RepositoryClassParser.java +++ b/src/java/edu/umd/cs/findbugs/ba/RepositoryClassParser.java @@ -69,7 +69,7 @@ } /** - * Parse the class file into a JavaClass object. If succesful, the new + * Parse the class file into a JavaClass object. If successful, the new * JavaClass is entered into the Repository. * * @return the parsed JavaClass diff --git a/src/java/edu/umd/cs/findbugs/ba/XField.java b/src/java/edu/umd/cs/findbugs/ba/XField.java index a0c47bb..7d95a8c 100644 --- a/src/java/edu/umd/cs/findbugs/ba/XField.java +++ b/src/java/edu/umd/cs/findbugs/ba/XField.java @@ -52,6 +52,11 @@ public boolean isVolatile(); /** + * @return true if this is a enum constant + */ + public boolean isEnum(); + + /** * @return FieldDescriptor referring to this field */ public FieldDescriptor getFieldDescriptor(); diff --git a/src/java/edu/umd/cs/findbugs/ba/bcp/BindingSet.java b/src/java/edu/umd/cs/findbugs/ba/bcp/BindingSet.java index 1f2fb3f..10d95e4 100644 --- a/src/java/edu/umd/cs/findbugs/ba/bcp/BindingSet.java +++ b/src/java/edu/umd/cs/findbugs/ba/bcp/BindingSet.java @@ -20,7 +20,7 @@ package edu.umd.cs.findbugs.ba.bcp; /** - * A set of Bindings, which are definitions of variables occuring in a + * A set of Bindings, which are definitions of variables occurring in a * ByteCodePattern. BindingSets are immutable; to add a binding, a new cell is * allocated. (Are we CONSING yet?) * diff --git a/src/java/edu/umd/cs/findbugs/ba/bcp/FieldAccess.java b/src/java/edu/umd/cs/findbugs/ba/bcp/FieldAccess.java index 7145ad9..4dd73fc 100644 --- a/src/java/edu/umd/cs/findbugs/ba/bcp/FieldAccess.java +++ b/src/java/edu/umd/cs/findbugs/ba/bcp/FieldAccess.java @@ -65,7 +65,7 @@ * @param bindingSet * previous definitions * @return a MatchResult containing an updated BindingSet if successful, or - * null if unsucessful + * null if unsuccessful */ protected MatchResult checkConsistent(Variable field, Variable value, BindingSet bindingSet) { // Ensure that the field and value variables are consistent with diff --git a/src/java/edu/umd/cs/findbugs/ba/jsr305/Analysis.java b/src/java/edu/umd/cs/findbugs/ba/jsr305/Analysis.java index d1c2d4d..d88926c 100644 --- a/src/java/edu/umd/cs/findbugs/ba/jsr305/Analysis.java +++ b/src/java/edu/umd/cs/findbugs/ba/jsr305/Analysis.java @@ -27,6 +27,7 @@ import javax.annotation.meta.When; import org.apache.bcel.generic.ConstantPoolGen; +import org.apache.bcel.generic.INVOKEDYNAMIC; import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.InvokeInstruction; @@ -105,8 +106,12 @@ Location location = i.next(); Instruction ins = location.getHandle().getInstruction(); if (ins instanceof InvokeInstruction) { - XMethod called = XFactory.createXMethod((InvokeInstruction) ins, cpg); - addEffectiveRelevantQualifiers(result, called); + if (ins instanceof INVOKEDYNAMIC) { + // TODO handle INVOKEDYNAMIC + } else { + XMethod called = XFactory.createXMethod((InvokeInstruction) ins, cpg); + addEffectiveRelevantQualifiers(result, called); + } } if (DEBUG_FIND_EFFECTIVE_RELEVANT_QUALIFIERS) { diff --git a/src/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierResolver.java b/src/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierResolver.java index 9098e9c..4e5d913 100644 --- a/src/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierResolver.java +++ b/src/java/edu/umd/cs/findbugs/ba/jsr305/TypeQualifierResolver.java @@ -55,6 +55,8 @@ static final ClassDescriptor intellijNullable = DescriptorFactory.createClassDescriptor("org/jetbrains/annotations/Nullable"); + static final ClassDescriptor intellijNotNull = DescriptorFactory.createClassDescriptor("org/jetbrains/annotations/NotNull"); + static final ClassDescriptor eclipseNullable = DescriptorFactory.createClassDescriptor("org/eclipse/jdt/annotation/Nullable"); static final ClassDescriptor eclipseNonNull = DescriptorFactory.createClassDescriptor("org/eclipse/jdt/annotation/NonNull"); @@ -128,7 +130,8 @@ resolveTypeQualifierNicknames(new AnnotationValue(JSR305NullnessAnnotations.CHECK_FOR_NULL), result, onStack); return; } - if (annotationClass.equals(eclipseNonNull) || annotationClass.equals(eclipseNonNullByDefault)) { + if (annotationClass.equals(eclipseNonNull) || annotationClass.equals(eclipseNonNullByDefault) + || annotationClass.equals(intellijNotNull)) { resolveTypeQualifierNicknames(new AnnotationValue(JSR305NullnessAnnotations.NONNULL), result, onStack); return; } diff --git a/src/java/edu/umd/cs/findbugs/ba/npe/NullDerefAndRedundantComparisonFinder.java b/src/java/edu/umd/cs/findbugs/ba/npe/NullDerefAndRedundantComparisonFinder.java index 9cf9f5c..932754a 100644 --- a/src/java/edu/umd/cs/findbugs/ba/npe/NullDerefAndRedundantComparisonFinder.java +++ b/src/java/edu/umd/cs/findbugs/ba/npe/NullDerefAndRedundantComparisonFinder.java @@ -69,7 +69,7 @@ /** * A user-friendly front end for finding null pointer dereferences and redundant - * null comparisions. + * null comparisons. * * @see IsNullValueAnalysis * @author David Hovemeyer diff --git a/src/java/edu/umd/cs/findbugs/ba/npe/jdkBaseNonnullReturn.db b/src/java/edu/umd/cs/findbugs/ba/npe/jdkBaseNonnullReturn.db index 92adda9..4089ae9 100644 --- a/src/java/edu/umd/cs/findbugs/ba/npe/jdkBaseNonnullReturn.db +++ b/src/java/edu/umd/cs/findbugs/ba/npe/jdkBaseNonnullReturn.db @@ -4382,7 +4382,6 @@ javax.xml.soap.SOAPMessage,createAttachmentPart,(Ljavax/activation/DataHandler;)Ljavax/xml/soap/AttachmentPart;,1|true javax.xml.soap.SOAPMessage,getProperty,(Ljava/lang/String;)Ljava/lang/Object;,1|true javax.xml.soap.SOAPMessage,getSOAPBody,()Ljavax/xml/soap/SOAPBody;,1|true -javax.xml.soap.SOAPMessage,getSOAPHeader,()Ljavax/xml/soap/SOAPHeader;,1|true javax.xml.stream.XMLEventFactory,newFactory,()Ljavax/xml/stream/XMLEventFactory;,9|true javax.xml.stream.XMLEventFactory,newFactory,(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljavax/xml/stream/XMLEventFactory;,9|true javax.xml.stream.XMLEventFactory,newInstance,()Ljavax/xml/stream/XMLEventFactory;,9|true diff --git a/src/java/edu/umd/cs/findbugs/ba/obl/ObligationAnalysis.java b/src/java/edu/umd/cs/findbugs/ba/obl/ObligationAnalysis.java index b52e818..b0bc8cc 100644 --- a/src/java/edu/umd/cs/findbugs/ba/obl/ObligationAnalysis.java +++ b/src/java/edu/umd/cs/findbugs/ba/obl/ObligationAnalysis.java @@ -211,7 +211,7 @@ * possiblyLeakedObligation) */) { if (DEBUG_NULL_CHECK) { - System.out.println("Deleting " + comparedObligation.toString() + " on edge from comparision " + System.out.println("Deleting " + comparedObligation.toString() + " on edge from comparison " + edge.getSource().getLastInstruction()); } fact.deleteObligation(comparedObligation, edge.getTarget().getLabel()); diff --git a/src/java/edu/umd/cs/findbugs/ba/type/TypeDataflow.java b/src/java/edu/umd/cs/findbugs/ba/type/TypeDataflow.java index 060a743..6507be8 100644 --- a/src/java/edu/umd/cs/findbugs/ba/type/TypeDataflow.java +++ b/src/java/edu/umd/cs/findbugs/ba/type/TypeDataflow.java @@ -20,6 +20,8 @@ package edu.umd.cs.findbugs.ba.type; import java.util.Collection; + +import javax.annotation.CheckForNull; import edu.umd.cs.findbugs.ba.CFG; import edu.umd.cs.findbugs.ba.Dataflow; @@ -47,6 +49,7 @@ return getAnalysis().getEdgeExceptionSet(edge); } + @CheckForNull public LocationAndFactPair getLocationAndFactForInstruction(int pc) { Collection locations = getCFG().getLocationsContainingInstructionWithOffset(pc); diff --git a/src/java/edu/umd/cs/findbugs/ba/vna/ValueNumberAnalysis.java b/src/java/edu/umd/cs/findbugs/ba/vna/ValueNumberAnalysis.java index a0ecd9d..4146684 100644 --- a/src/java/edu/umd/cs/findbugs/ba/vna/ValueNumberAnalysis.java +++ b/src/java/edu/umd/cs/findbugs/ba/vna/ValueNumberAnalysis.java @@ -169,7 +169,7 @@ if (p == param) { return getEntryValue(slotOffset); } - param++; + p++; slotOffset += SignatureParser.getNumSlotsForType(paramSig); } diff --git a/src/java/edu/umd/cs/findbugs/bcel/OpcodeStackDetector.java b/src/java/edu/umd/cs/findbugs/bcel/OpcodeStackDetector.java index 6cc05e9..a4df989 100644 --- a/src/java/edu/umd/cs/findbugs/bcel/OpcodeStackDetector.java +++ b/src/java/edu/umd/cs/findbugs/bcel/OpcodeStackDetector.java @@ -18,6 +18,8 @@ */ package edu.umd.cs.findbugs.bcel; + +import javax.annotation.OverridingMethodsMustInvokeSuper; import org.apache.bcel.classfile.Code; @@ -65,6 +67,7 @@ } @Override + @OverridingMethodsMustInvokeSuper public boolean beforeOpcode(int seen) { stack.precomputation(this); return !stack.isTop(); @@ -75,6 +78,7 @@ * @see #sawOpcode(int) */ @Override + @OverridingMethodsMustInvokeSuper public void afterOpcode(int seen) { stack.sawOpcode(this, seen); } diff --git a/src/java/edu/umd/cs/findbugs/classfile/analysis/FieldInfo.java b/src/java/edu/umd/cs/findbugs/classfile/analysis/FieldInfo.java index b975f57..8ea2e86 100644 --- a/src/java/edu/umd/cs/findbugs/classfile/analysis/FieldInfo.java +++ b/src/java/edu/umd/cs/findbugs/classfile/analysis/FieldInfo.java @@ -189,6 +189,11 @@ return checkFlag(Constants.ACC_PRIVATE); } + @Override + public boolean isEnum() { + return checkFlag(Constants.ACC_ENUM); + } + /* * (non-Javadoc) * diff --git a/src/java/edu/umd/cs/findbugs/classfile/engine/ClassParserUsingASM.java b/src/java/edu/umd/cs/findbugs/classfile/engine/ClassParserUsingASM.java index 68e3148..b469d49 100644 --- a/src/java/edu/umd/cs/findbugs/classfile/engine/ClassParserUsingASM.java +++ b/src/java/edu/umd/cs/findbugs/classfile/engine/ClassParserUsingASM.java @@ -25,7 +25,7 @@ import javax.annotation.CheckForNull; -import org.apache.bcel.Constants; +import org.apache.bcel.Const; import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; @@ -60,12 +60,12 @@ private static final BitSet RETURN_OPCODE_SET = new BitSet(); static { - RETURN_OPCODE_SET.set(Constants.ARETURN); - RETURN_OPCODE_SET.set(Constants.IRETURN); - RETURN_OPCODE_SET.set(Constants.LRETURN); - RETURN_OPCODE_SET.set(Constants.DRETURN); - RETURN_OPCODE_SET.set(Constants.FRETURN); - RETURN_OPCODE_SET.set(Constants.RETURN); + RETURN_OPCODE_SET.set(Const.ARETURN); + RETURN_OPCODE_SET.set(Const.IRETURN); + RETURN_OPCODE_SET.set(Const.LRETURN); + RETURN_OPCODE_SET.set(Const.DRETURN); + RETURN_OPCODE_SET.set(Const.FRETURN); + RETURN_OPCODE_SET.set(Const.RETURN); } private final ClassReader classReader; @@ -207,23 +207,23 @@ @Override public void visitInsn(int opcode) { switch (opcode) { - case Constants.MONITORENTER: + case Const.MONITORENTER: mBuilder.setUsesConcurrency(); break; - case Constants.ARETURN: - case Constants.IRETURN: - case Constants.LRETURN: - case Constants.DRETURN: - case Constants.FRETURN: + case Const.ARETURN: + case Const.IRETURN: + case Const.LRETURN: + case Const.DRETURN: + case Const.FRETURN: if (identityState == IdentityMethodState.LOADED_PARAMETER) { mBuilder.setIsIdentity(); } sawReturn = true; break; - case Constants.RETURN: + case Const.RETURN: sawReturn = true; break; - case Constants.ATHROW: + case Const.ATHROW: if (stubState == StubState.INITIALIZE_RUNTIME) { sawStubThrow = true; } else if (justSawInitializationOfUnsupportedOperationException) { @@ -457,7 +457,7 @@ mBuilder.setUnsupported(); } if (sawStubThrow) { - mBuilder.addAccessFlags(Constants.ACC_SYNTHETIC); + mBuilder.addAccessFlags(Const.ACC_SYNTHETIC); mBuilder.setIsStub(); } @@ -647,24 +647,24 @@ int size; switch (tag) { - case Constants.CONSTANT_Methodref: - case Constants.CONSTANT_InterfaceMethodref: - case Constants.CONSTANT_Fieldref: - case Constants.CONSTANT_Integer: - case Constants.CONSTANT_Float: - case Constants.CONSTANT_NameAndType: - case Constants.CONSTANT_InvokeDynamic: + case Const.CONSTANT_Methodref: + case Const.CONSTANT_InterfaceMethodref: + case Const.CONSTANT_Fieldref: + case Const.CONSTANT_Integer: + case Const.CONSTANT_Float: + case Const.CONSTANT_NameAndType: + case Const.CONSTANT_InvokeDynamic: size = 5; break; - case Constants.CONSTANT_Long: - case Constants.CONSTANT_Double: + case Const.CONSTANT_Long: + case Const.CONSTANT_Double: size = 9; count++; break; - case Constants.CONSTANT_Utf8: + case Const.CONSTANT_Utf8: size = 3 + classReader.readUnsignedShort(offset + 1); break; - case Constants.CONSTANT_Class: + case Const.CONSTANT_Class: @SlashedClassName String className = classReader.readUTF8(offset + 1, buf); if (className.indexOf('[') >= 0) { @@ -675,11 +675,11 @@ } size = 3; break; - case Constants.CONSTANT_String: - case Constants.CONSTANT_MethodType: + case Const.CONSTANT_String: + case Const.CONSTANT_MethodType: size = 3; break; - case Constants.CONSTANT_MethodHandle: + case Const.CONSTANT_MethodHandle: size = 4; break; default: diff --git a/src/java/edu/umd/cs/findbugs/classfile/engine/asm/FindBugsASM.java b/src/java/edu/umd/cs/findbugs/classfile/engine/asm/FindBugsASM.java index 7f46704..a9a9808 100644 --- a/src/java/edu/umd/cs/findbugs/classfile/engine/asm/FindBugsASM.java +++ b/src/java/edu/umd/cs/findbugs/classfile/engine/asm/FindBugsASM.java @@ -26,6 +26,6 @@ */ public class FindBugsASM { - public static final int ASM_VERSION = Opcodes.ASM5; + public static final int ASM_VERSION = Opcodes.ASM6; } diff --git a/src/java/edu/umd/cs/findbugs/classfile/engine/bcel/ValueRangeAnalysisFactory.java b/src/java/edu/umd/cs/findbugs/classfile/engine/bcel/ValueRangeAnalysisFactory.java index 898f4d2..42fc5e9 100644 --- a/src/java/edu/umd/cs/findbugs/classfile/engine/bcel/ValueRangeAnalysisFactory.java +++ b/src/java/edu/umd/cs/findbugs/classfile/engine/bcel/ValueRangeAnalysisFactory.java @@ -21,10 +21,12 @@ import static org.apache.bcel.Constants.*; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.BitSet; import java.util.Collections; import java.util.Comparator; +import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; @@ -727,7 +729,7 @@ for (VariableData data : analyzedArguments.values()) { for (LongRangeSet subRange : data.splitSet) { BitSet reachedBlocks = new BitSet(); - walkCFG(cfg, cfg.getEntry(), subRange, data.edges, reachedBlocks, new HashSet ()); + walkCFG(cfg, subRange, data.edges, reachedBlocks); data.reachableBlocks.or(reachedBlocks); } } @@ -893,28 +895,45 @@ return result; } - private static void walkCFG(CFG cfg, BasicBlock basicBlock, LongRangeSet subRange, Map edges, BitSet reachedBlocks, Set numbers) { - reachedBlocks.set(basicBlock.getLabel()); - for (Iterator iterator = cfg.outgoingEdgeIterator(basicBlock); iterator.hasNext();) { - Edge edge = iterator.next(); - Branch branch = edges.get(edge); - if (branch != null) { - branch.numbers.addAll(numbers); - numbers = new HashSet<>(numbers); - numbers.add(branch.number.longValue()); - if (branch.trueSet.intersects(subRange)) { - branch.trueReachedSet.add(subRange); - } else { - branch.falseReachedSet.add(subRange); - continue; - } - } - BasicBlock target = edge.getTarget(); - if (!reachedBlocks.get(target.getLabel())) { - walkCFG(cfg, target, subRange, edges, reachedBlocks, numbers); - } - if (branch != null) { - break; + private static void walkCFG(final CFG cfg, LongRangeSet subRange, Map edges, final BitSet reachedBlocks) { + class WalkState { + Set numbers; + BasicBlock target; + + WalkState(Set numbers, BasicBlock target) { + reachedBlocks.set(target.getLabel()); + this.target = target; + this.numbers = numbers; + } + } + + Deque walkStates = new ArrayDeque<>(); + walkStates.push(new WalkState(new HashSet (), cfg.getEntry())); + + while(!walkStates.isEmpty()) { + WalkState walkState = walkStates.removeLast(); + Set numbers = walkState.numbers; + for(Iterator iterator = cfg.outgoingEdgeIterator(walkState.target); iterator.hasNext(); ) { + Edge edge = iterator.next(); + Branch branch = edges.get(edge); + if (branch != null) { + branch.numbers.addAll(numbers); + numbers = new HashSet<>(numbers); + numbers.add(branch.number.longValue()); + if (branch.trueSet.intersects(subRange)) { + branch.trueReachedSet.add(subRange); + } else { + branch.falseReachedSet.add(subRange); + continue; + } + } + BasicBlock target = edge.getTarget(); + if (!reachedBlocks.get(target.getLabel())) { + walkStates.push(new WalkState(numbers, target)); + } + if (branch != null) { + break; + } } } } diff --git a/src/java/edu/umd/cs/findbugs/classfile/impl/ClassFactory.java b/src/java/edu/umd/cs/findbugs/classfile/impl/ClassFactory.java index 4e38c82..2fa8dbe 100644 --- a/src/java/edu/umd/cs/findbugs/classfile/impl/ClassFactory.java +++ b/src/java/edu/umd/cs/findbugs/classfile/impl/ClassFactory.java @@ -117,6 +117,8 @@ throw new IOException("File " + file.getAbsolutePath() + " is not a normal file"); } else if (fileName.endsWith(".class")) { return new SingleFileCodeBase(codeBaseLocator, fileName); + } else if (fileName.endsWith(File.separator + "jrt-fs.jar")) { + return new JrtfsCodeBase(codeBaseLocator, fileName); } else { return ZipCodeBaseFactory.makeZipCodeBase(codeBaseLocator, file); } diff --git a/src/java/edu/umd/cs/findbugs/classfile/impl/ClassPathBuilder.java b/src/java/edu/umd/cs/findbugs/classfile/impl/ClassPathBuilder.java index edabb67..d585743 100644 --- a/src/java/edu/umd/cs/findbugs/classfile/impl/ClassPathBuilder.java +++ b/src/java/edu/umd/cs/findbugs/classfile/impl/ClassPathBuilder.java @@ -25,6 +25,9 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -38,6 +41,7 @@ import java.util.jar.Manifest; import edu.umd.cs.findbugs.FindBugs; +import edu.umd.cs.findbugs.JavaVersion; import edu.umd.cs.findbugs.SystemProperties; import edu.umd.cs.findbugs.classfile.CheckedAnalysisException; import edu.umd.cs.findbugs.classfile.ClassDescriptor; @@ -273,6 +277,12 @@ dumpCodeBaseList(classPath.appCodeBaseIterator(), "Application codebases"); dumpCodeBaseList(classPath.auxCodeBaseIterator(), "Auxiliary codebases"); } + + // Make sure we always know if we can't find system classes + ICodeBaseEntry resource = classPath.lookupResource("java/lang/Object.class"); + if(resource == null){ + throw new ResourceNotFoundException("java/lang/Object.class"); + } } /** @@ -390,7 +400,18 @@ } } + if(isJava9orLater()){ + Path jrtFsJar = Paths.get(System.getProperty("java.home", ""), "jrt-fs.jar"); + if(Files.isRegularFile(jrtFsJar)){ + addWorkListItemsForClasspath(workList, jrtFsJar.toString()); + } + } return workList; + } + + private static boolean isJava9orLater() { + JavaVersion javaVersion = JavaVersion.getRuntimeVersion(); + return javaVersion.getMajor() >= 9; } /** @@ -628,7 +649,11 @@ } catch (IOException e) { if (item.isAppCodeBase() || item.getHowDiscovered() == ICodeBase.Discovered.SPECIFIED) { if (e instanceof FileNotFoundException) { - errorLogger.logError("File not found: " + item.getCodeBaseLocator()); + if(item.isAppCodeBase()){ + errorLogger.logError("File from project not found: " + item.getCodeBaseLocator(), e); + } else { + errorLogger.logError("File from auxiliary classpath not found: " + item.getCodeBaseLocator(), e); + } } else { errorLogger.logError("Cannot open codebase " + item.getCodeBaseLocator(), e); } diff --git a/src/java/edu/umd/cs/findbugs/classfile/impl/JrtfsCodeBase.java b/src/java/edu/umd/cs/findbugs/classfile/impl/JrtfsCodeBase.java new file mode 100644 index 0000000..530dc2e --- /dev/null +++ b/src/java/edu/umd/cs/findbugs/classfile/impl/JrtfsCodeBase.java @@ -0,0 +1,332 @@ +/* + * FindBugs - Find Bugs in Java programs + * Copyright (C) 2003-2008 University of Maryland + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package edu.umd.cs.findbugs.classfile.impl; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +import edu.umd.cs.findbugs.classfile.ClassDescriptor; +import edu.umd.cs.findbugs.classfile.DescriptorFactory; +import edu.umd.cs.findbugs.classfile.ICodeBaseEntry; +import edu.umd.cs.findbugs.classfile.ICodeBaseIterator; +import edu.umd.cs.findbugs.classfile.ICodeBaseLocator; +import edu.umd.cs.findbugs.classfile.InvalidClassFileFormatException; +import edu.umd.cs.findbugs.classfile.ResourceNotFoundException; + +/** + * + * Code base supporting Java 9 new jimage packed modules + * + * @author andrey + */ +public class JrtfsCodeBase extends AbstractScannableCodeBase { + + private FileSystem fs; + private final String fileName; + private Path root; + + /** + * Key is package name in bytecode notation (e.g. 'java/lang'). + * + * Values are either plain Strings for single-module packages, or sets of + * Strings for packages spread over multiple modules + */ + private Map
packageToModuleMap; + + public JrtfsCodeBase(ICodeBaseLocator codeBaseLocator, @Nonnull String fileName) { + super(codeBaseLocator); + this.fileName = fileName; + URL url; + try { + url = Paths.get(fileName).toUri().toURL(); + URLClassLoader loader = new URLClassLoader(new URL[] { url }); + fs = FileSystems.newFileSystem(URI.create("jrt:/"), Collections.emptyMap(), loader); + root = fs.getPath("modules"); + packageToModuleMap = createPackageToModuleMap(fs); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public Map createPackageToModuleMap(FileSystem fs) throws IOException{ + HashMap packageToModule = new LinkedHashMap<>(); + Path path = fs.getPath("packages"); + Files.list(path).forEach(p -> { + try { + Iterator modIter = Files.list(p).iterator(); + while (modIter.hasNext()) { + Path module = modIter.next(); + String packageKey = fileName(p).replace('.', '/'); + String modulePath = fileName(module); + if(!modIter.hasNext() && !packageToModule.containsKey(packageKey)){ + packageToModule.put(packageKey, modulePath); + } else { + @SuppressWarnings("unchecked") + Set