Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object InfiniteRecursions extends ProjectsAnalysisApplication {
nextCallOperands: domain.Operands = operandsArray(pc).take(parametersCount)
} {
// IntegerRangeValues and ReferenceValues have useable equals semantics
if (!callOperandsList.exists { _ == nextCallOperands })
if (!callOperandsList.contains(nextCallOperands))
callOperandsList = nextCallOperands :: callOperandsList
}
callOperandsList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ object IfNullParameterAnalysis extends ProjectsAnalysisApplication {
domain1,
// We need to keep the original location, otherwise
// the correlation analysis would miserably fail!
ex.asInstanceOf[domain2.DomainSingleOriginReferenceValue].origin
ex.asInstanceOf[domain2.DomainSingleOriginReferenceValue]
.origin
).asInstanceOf[domain1.ExceptionValue]
).toSet[domain1.DomainReferenceValue]
)
val diff =
d1thrownException.diff(adaptedD2ThrownException) ++
adaptedD2ThrownException.diff(d1thrownException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ object MethodReturnValuesAnalysis extends ProjectsAnalysisApplication {

case class RefinedReturnType(method: Method, refinedType: Option[Domain#DomainValue]) {

override def toString(): String = {
override def toString: String = {
import Console.*
"Refined the return type of " + BOLD + BLUE + method.toJava + " => " +
GREEN + refinedType.getOrElse("\"NONE\" (the method does not return normally)") + RESET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class SimpleInstrumentationDemo {
}

def callsToString(): Unit = {
println("the length of the toString representation is: " + this.toString().length())
println("the length of the toString representation is: " + this.toString.length())
}

def returnsValue(i: Int): Int = {
if (i % 2 == 0)
return -1;
-1
else
return 2;
2
}

def playingWithTypes(a: AnyRef): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,5 @@ object HelloWorldClass extends App {
attributes = ArraySeq(SourceFile_attribute(32, 33))
)

println("Created class file: " + Files.write(Paths.get("Test.class"), Assembler(cf)).toAbsolutePath())
println("Created class file: " + Files.write(Paths.get("Test.class"), Assembler(cf)).toAbsolutePath)
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object MoreCheckers {
field <- classFile.fields if field.isProtected
} yield (classFile, field)
} { t => collect("CI_CONFUSED_INHERITANCE", t /*nsToSecs(t)*/ ) }
println(", " /*"\tViolations: "*/ + protectedFields.size)
println(", " /*"\tViolations: "*/ + protectedFields.length)

// FINDBUGS: CN: Class implements Cloneable but does not define or use clone method (CN_IDIOM)
val cloneableNoClone = time {
Expand Down Expand Up @@ -174,7 +174,7 @@ object MoreCheckers {
if classHierarchy.isASubtypeOf(classFile.thisType, ClassType.Cloneable).isYesOrUnknown
} yield (classFile.thisType.fqn, method.name)
}(t => collect("CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE", t /*nsToSecs(t)*/ ))
println(", " /*"\tViolations: "*/ /*+cloneButNotCloneable.mkString(", ")*/ + cloneButNotCloneable.size)
println(", " /*"\tViolations: "*/ /*+cloneButNotCloneable.mkString(", ")*/ + cloneButNotCloneable.length)

// FINDBUGS: Co: Abstract class defines covariant compareTo() method (CO_ABSTRACT_SELF)
// FINDBUGS: Co: Covariant compareTo() method defined (CO_SELF_NO_OBJECT)
Expand All @@ -201,7 +201,7 @@ object MoreCheckers {
for { // we don't care about gc calls in java.lang and also about gc calls that happen inside of methods related to garbage collection (heuristic)
classFile <- classFiles if !classFile.thisType.fqn.startsWith("java/lang");
method <- classFile.methods
if method.body.isDefined && !"(^gc)|(gc$)".r.findFirstIn(method.name).isDefined;
if method.body.isDefined && "(^gc)|(gc$)".r.findFirstIn(method.name).isEmpty;
instruction <- method.body.get.instructions
} {
instruction match {
Expand Down Expand Up @@ -255,7 +255,7 @@ object MoreCheckers {
) <- classFile.methods if method.isAbstract
} yield (classFile, method);
}(t => collect("EQ_ABSTRACT_SELF", t /*nsToSecs(t)*/ ))
println(", " /*"\tViolations: "*/ + abstractCovariantEquals.size)
println(", " /*"\tViolations: "*/ + abstractCovariantEquals.length)

// FINDBUGS: FI: Finalizer should be protected, not public (FI_PUBLIC_SHOULD_BE_PROTECTED)
val classesWithPublicFinalizeMethods = time {
Expand Down Expand Up @@ -292,7 +292,7 @@ object MoreCheckers {
if getClassFile.isDefinedAt(superclass) // the class file of some supertypes (defined in libraries, which we do not analyze) may not be available
superClassFile = getClassFile(superclass)
if !superClassFile.isInterfaceDeclaration
if !superClassFile.constructors.exists(_.descriptor.parameterTypes.length == 0)
if !superClassFile.constructors.exists(_.descriptor.parameterTypes.isEmpty)
} yield superclass // there can be at most one method
}(t => collect("SE_NO_SUITABLE_CONSTRUCTOR", t /*nsToSecs(t)*/ ))
println(", " /*"\tViolations: "*/ + classesWithoutDefaultConstructor.size);
Expand All @@ -313,7 +313,7 @@ object MoreCheckers {
case _ =>
}
}
if (privateFields.size > 0)
if (privateFields.nonEmpty)
unusedFields = (classFile, privateFields) :: unusedFields
}
}(t => collect("UUF_UNUSED_FIELD", t /*nsToSecs(t)*/ ))
Expand Down Expand Up @@ -354,9 +354,9 @@ object MoreCheckers {
classFile <- classFiles if classFile.isClassDeclaration
case method @ MethodWithBody(body) <- classFile.methods
exceptionHandler <- body.exceptionHandlers
if exceptionHandler.catchType == Some(IllegalMonitorStateExceptionType)
if exceptionHandler.catchType.contains(IllegalMonitorStateExceptionType)
} yield (classFile, method)
}(t => collect("IMSE_DONT_CATCH_IMSE", t /*nsToSecs(t)*/ ))
println(", " /*"\tViolations: "*/ + catchesIllegalMonitorStateException.size)
println(", " /*"\tViolations: "*/ + catchesIllegalMonitorStateException.length)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,17 @@ object SimpleProjectStatistics extends ProjectsAnalysisApplication {
(group, es.size)
}

val maxInstanceFieldsInAClass =
project.allClassFiles.map(_.fields.filter(f => !f.isStatic).size).max
val classWithMaxInstanceFields =
project.allClassFiles.find(
_.fields.filter(f => !f.isStatic).size == maxInstanceFieldsInAClass
).map(_.thisType.toJava)

val maxClassFieldsInAClass =
project.allClassFiles.map(_.fields.filter(f => f.isStatic).size).max
val classWithMaxClassFields =
project.allClassFiles.find(
_.fields.filter(f => f.isStatic).size == maxClassFieldsInAClass
).map(_.thisType.toJava)

val maxMethodsInAClass =
project.allClassFiles.map(_.methods.size).max
val classWithMaxMethods =
project.allClassFiles.find(
_.methods.size == maxMethodsInAClass
).map(_.thisType.toJava)
val maxInstanceFieldsInAClass = project.allClassFiles.map(_.fields.count(f => !f.isStatic)).max
val classWithMaxInstanceFields = project.allClassFiles
.find(_.fields.count(f => !f.isStatic) == maxInstanceFieldsInAClass).map(_.thisType.toJava)

val maxClassFieldsInAClass = project.allClassFiles.map(_.fields.count(f => f.isStatic)).max
val classWithMaxClassFields = project.allClassFiles
.find(_.fields.count(f => f.isStatic) == maxClassFieldsInAClass).map(_.thisType.toJava)

val maxMethodsInAClass = project.allClassFiles.map(_.methods.size).max
val classWithMaxMethods = project.allClassFiles
.find(_.methods.size == maxMethodsInAClass).map(_.thisType.toJava)

val (longestMethodInAClass, theLongestMethod) = {
var max = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ object ObserverPatternUsage extends ProjectsAnalysisApplication {
val appClassFiles = project.allProjectClassFiles
val libClassFiles = project.allLibraryClassFiles
println("Application:\n\tClasses:" + appClassFiles.size)
println("\tMethods:" + appClassFiles.foldLeft(0)(_ + _.methods.filter(!_.isSynthetic).size))
println("\tNon-final Fields:" + appClassFiles.foldLeft(0)(_ + _.fields.filter(!_.isFinal).size))
println("\tMethods:" + appClassFiles.foldLeft(0)(_ + _.methods.count(!_.isSynthetic)))
println("\tNon-final Fields:" + appClassFiles.foldLeft(0)(_ + _.fields.count(!_.isFinal)))
println("Library:\n\tClasses:" + libClassFiles.size)
println("Overall " + project.statistics)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ object ClassHierarchyVisualizer extends ProjectsAnalysisApplication {

val (project, _) = analysisConfig.setupProject(cp)

val dotGraph = toDot(Set(project.classHierarchy.toGraph()), "back")
val dotGraph = toDot(Set(project.classHierarchy.toGraph), "back")

val file = writeAndOpen(dotGraph, "ClassHierarchy", ".gv")
println(s"Wrote class hierarchy graph to: $file.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.opalj.ai.Domain
import org.opalj.ai.NoUpdate
import org.opalj.ai.SomeUpdate
import org.opalj.ai.Update
import org.opalj.ai.domain
import org.opalj.ai.domain.TheCode
import org.opalj.ai.domain.l1.ReferenceValues
import org.opalj.br.Code
import org.opalj.br.instructions.Instruction
import org.opalj.collection.mutable.IntArrayStack
Expand Down Expand Up @@ -68,10 +68,10 @@ trait ConsoleTracer extends AITracer { tracer =>
case rv: IsReferenceValue if rv.allValues.size > 1 =>
val values = rv.allValues
val t =
if (rv.isInstanceOf[domain.l1.ReferenceValues#TheReferenceValue])
s";refId=${rv.asInstanceOf[org.opalj.ai.domain.l1.ReferenceValues#TheReferenceValue].refId}"
else
""
rv match {
case value1: ReferenceValues#TheReferenceValue => s";refId=${value1.refId}"
case _ => ""
}
values.map(toStringWithOID(_)).mkString("OneOf[" + values.size + "](", ",", ")") +
rv.upperTypeBound.map(_.toJava).mkString(";lutb=", " with ", ";") +
s"isPrecise=${rv.isPrecise};isNull=${rv.isNull}$t " +
Expand Down Expand Up @@ -115,7 +115,7 @@ trait ConsoleTracer extends AITracer { tracer =>

val ps = {
val ps = domain.properties(pc)
if ((ps eq null) || ps == None)
if ((ps eq null) || ps.isEmpty)
""
else {
s"\tproperties: ${ps.get}\n"
Expand Down Expand Up @@ -173,7 +173,7 @@ trait ConsoleTracer extends AITracer { tracer =>

override def deadLocalVariable(domain: Domain)(pc: Int, lvIndex: Int): Unit = {
println(
pc.toString + line(domain, pc).toString + ":" +
pc.toString + line(domain, pc) + ":" +
Console.BLACK_B + Console.WHITE + s"local variable $lvIndex is dead"
)
}
Expand Down Expand Up @@ -382,7 +382,7 @@ trait ConsoleTracer extends AITracer { tracer =>
): Unit = {
val loc = pc.map(pc => s"$pc:").getOrElse("<NO PC>")
println(
s"$loc[Domain:${source.getSimpleName().split('$')(0)} - $typeID] $message"
s"$loc[Domain:${source.getSimpleName.split('$')(0)} - $typeID] $message"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ trait XHTMLTracer extends AITracer {
"new …" + classType.simpleName;
case CHECKCAST(referenceType) =>
"checkcast " + referenceType.toJava;
case LoadString(s) if s.size < 5 =>
case LoadString(s) if s.length < 5 =>
"Load \"" + s + "\"";
case LoadString(s) =>
"Load \"" + s.substring(0, 4) + "…\""
Expand Down Expand Up @@ -394,7 +394,7 @@ trait XHTMLTracer extends AITracer {
): Unit = { /*EMPTY*/ }

def result(result: AIResult): Unit = {
writeAndOpen(dumpXHTML((new java.util.Date).toString()), "AITrace", ".html")
writeAndOpen(dumpXHTML((new java.util.Date).toString), "AITrace", ".html")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class GeneratedProxyClassFilesTest extends AnyFunSpec with Matchers {

// there is no dead-code
var nextPc = 0
while (nextPc < instructions.size) {
while (nextPc < instructions.length) {
result.operandsArray(nextPc) should not be (null)
nextPc = instructions(nextPc).indexOfNextInstruction(nextPc, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public static void externalWorldField_sink(java.awt.Event e) {
// information regarding their type hierarchy. In this test, we consider two sinks with parameters of external
// types ArrayList and Map.

static class MyList extends ArrayList { }
static class MyList extends ArrayList<Object> { }

@AvailableTypes({
"org/opalj/fpcf/fixtures/callgraph/xta/StaticMethodFlows$A",
Expand All @@ -338,7 +338,7 @@ private static void externalTypeFilter() {
sink(new MyList());
// LinkedList is an external type for which it is unknwon whether it extends Map or ArrayList.
// It should propagate to both sinks.
sink(new LinkedList());
sink(new LinkedList<>());

externalTypeFilter_sink(null);
externalTypeFilter_sink2(null);
Expand All @@ -347,12 +347,12 @@ private static void externalTypeFilter() {
@AvailableTypes({
"org/opalj/fpcf/fixtures/callgraph/xta/StaticMethodFlows$MyList",
"java/util/LinkedList"})
private static void externalTypeFilter_sink(ArrayList list) { }
private static void externalTypeFilter_sink(ArrayList<?> list) { }

@AvailableTypes({
"org/opalj/fpcf/fixtures/callgraph/xta/StaticMethodFlows$MyList",
"java/util/LinkedList"})
private static void externalTypeFilter_sink2(Map map) { }
private static void externalTypeFilter_sink2(Map<?, ?> map) { }

// === Return optimization ===
// Even though the source method here has a non-void return type, the analysis should not consider the call
Expand Down Expand Up @@ -435,7 +435,7 @@ public static void genericContainer_sink2(Container<A> a, Container<B> b) {
"org/opalj/fpcf/fixtures/callgraph/xta/StaticMethodFlows$B",
"org/opalj/fpcf/fixtures/callgraph/xta/StaticMethodFlows$C",
"org/opalj/fpcf/fixtures/callgraph/xta/StaticMethodFlows$Container"})
public static void genericContainer_sink3(Container c) {
public static void genericContainer_sink3(Container<?> c) {
// This method's parameter is a raw type.
Object obj = c.get();
sink(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import org.opalj.fpcf.properties.compile_time_constancy.CompileTimeConstant;
import org.opalj.fpcf.properties.compile_time_constancy.CompileTimeVarying;
import org.opalj.fpcf.properties.static_data_usage.UsesConstantDataOnly;
import org.opalj.fpcf.properties.static_data_usage.UsesNoStaticData;
import org.opalj.fpcf.properties.static_data_usage.UsesVaryingData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package org.opalj.fpcf.fixtures.escape.virtual_calls;

import org.opalj.fpcf.fixtures.escape.Circle;
import org.opalj.fpcf.properties.escape.AtMostNoEscape;

public interface Interface {
Circle copyCircle(Circle aCircle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import org.opalj.fpcf.properties.field_locality.LocalField;
import org.opalj.fpcf.properties.field_locality.LocalFieldWithGetter;
import org.opalj.fpcf.properties.field_locality.NoLocalField;

public final class FinalClassExample {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package org.opalj.fpcf.fixtures.field_locality;

import org.opalj.fpcf.properties.field_locality.LocalField;
import org.opalj.fpcf.properties.field_locality.NoLocalField;

public class LocalFieldExample implements Cloneable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void callNopOfClassWithMutableFields(){

@TransitivelyImmutableField("The field is effectively non assignable and has a primitive type")
@EffectivelyNonAssignableField("The field is not written after initialization")
private Long simpleLong = 5l;
private Long simpleLong = 5L;

@TransitivelyImmutableField("The concrete assigned object is known to be deep immutable")
@EffectivelyNonAssignableField("The field is not written after initialization")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public synchronized Integer getInGetterSynchronizedSimpleLazyInitializedIntegerF
private long inGetterSynchronizedLazyInitializedLongField;

public synchronized long getInGetterSynchronizedLazyInitializedLongField(){
if(inGetterSynchronizedLazyInitializedLongField == 0l)
if(inGetterSynchronizedLazyInitializedLongField == 0L)
inGetterSynchronizedLazyInitializedLongField = 5;
return inGetterSynchronizedLazyInitializedLongField;
}
Expand All @@ -51,8 +51,8 @@ public synchronized long getInGetterSynchronizedLazyInitializedLongField(){
private Long lazyintializedLongObject;

public synchronized Long getLongObject(){
if(lazyintializedLongObject == 0l)
lazyintializedLongObject = 5l;
if(lazyintializedLongObject == 0L)
lazyintializedLongObject = 5L;
return lazyintializedLongObject;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class SimpleStringModel {
@NonTransitivelyImmutableField(value = "The analysis can not recognize transitive immutable arrays",
analyses = { FieldImmutabilityAnalysis.class})
@NonAssignableField("The field is final")
private final char value[];
private final char[] value;

public char[] getValue(){
return value.clone();
Expand All @@ -42,7 +42,7 @@ public SimpleStringModel(char[] value){
public int hashCode() {
int h = 0;
if (hash == 0) {
char val[] = value;
char[] val = value;
for (int i = 0; i < value.length; i++) {
h = 31 * h + val[i];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public enum TypePropagationVariant {
FTA,
CTA;

public static String tag = "TypePropagationVariant";
public static final String tag = "TypePropagationVariant";
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package org.opalj.fpcf.properties.static_data_usage;

import org.opalj.fpcf.properties.PropertyValidator;
import org.opalj.fpcf.properties.compile_time_constancy.CompileTimeConstantMatcher;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
Expand Down
Loading