Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make singleton identification more accurate
- Loading branch information
1 parent
eae6f5c
commit d415ee0
Showing
3 changed files
with
94 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
spotbugsTestCases/src/java/singletons/NotSingletonWithFactoryMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package singletons; | ||
|
||
/** | ||
* See https://github.com/spotbugs/spotbugs/issues/2934 | ||
*/ | ||
public class NotSingletonWithFactoryMethod { | ||
|
||
private static final NotSingletonWithFactoryMethod INSTANCE = new NotSingletonWithFactoryMethod("1"); | ||
|
||
private final String text; | ||
|
||
private NotSingletonWithFactoryMethod(String text) { | ||
this.text = text; | ||
} | ||
|
||
public static NotSingletonWithFactoryMethod instance1() { | ||
return INSTANCE; | ||
} | ||
|
||
public static NotSingletonWithFactoryMethod create(String text) { | ||
return new NotSingletonWithFactoryMethod("text"); | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
} |