From 2221e695b0dfdf796dabe3d29b01ebe3dd2da8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20D=C3=BCsing?= Date: Tue, 7 Jul 2026 14:04:15 +0200 Subject: [PATCH] Do not run reflection allocations analysis on TypeBasedPointsToKey --- OPAL/tac/src/main/resources/reference.conf | 7 +++++- ...ocationSiteBasedPointsToCallGraphKey.scala | 22 ++++++++++++++++++- .../opalj/tac/cg/CFA_1_0_CallGraphKey.scala | 2 +- .../opalj/tac/cg/CFA_1_1_CallGraphKey.scala | 2 +- .../opalj/tac/cg/PointsToCallGraphKey.scala | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/OPAL/tac/src/main/resources/reference.conf b/OPAL/tac/src/main/resources/reference.conf index d02069a03d..dc12aca07e 100644 --- a/OPAL/tac/src/main/resources/reference.conf +++ b/OPAL/tac/src/main/resources/reference.conf @@ -1702,10 +1702,15 @@ org.opalj { "UnsafePointsTo", "SerializationAllocations", "NewInstance", - "ReflectionAllocationsAnalysisScheduler", "org.opalj.tac.fpcf.analyses.fieldaccess.TriggeredFieldAccessInformationAnalysis", "org.opalj.tac.fpcf.analyses.fieldaccess.reflection.ReflectionRelatedFieldAccessesAnalysisScheduler", ] + }, + AllocationSites { + # Modules (analyses for different functionalities) to be used when tracking allocation sites in call graph construction + modules = [ + "org.opalj.tac.fpcf.analyses.pointsto.ReflectionAllocationsAnalysisScheduler" + ] } } } diff --git a/OPAL/tac/src/main/scala/org/opalj/tac/cg/AllocationSiteBasedPointsToCallGraphKey.scala b/OPAL/tac/src/main/scala/org/opalj/tac/cg/AllocationSiteBasedPointsToCallGraphKey.scala index fc87e30403..417dbe61ad 100644 --- a/OPAL/tac/src/main/scala/org/opalj/tac/cg/AllocationSiteBasedPointsToCallGraphKey.scala +++ b/OPAL/tac/src/main/scala/org/opalj/tac/cg/AllocationSiteBasedPointsToCallGraphKey.scala @@ -3,12 +3,32 @@ package org.opalj package tac package cg +import scala.jdk.CollectionConverters.* + import org.opalj.br.analyses.ProjectInformationKey import org.opalj.br.analyses.SomeProject +import org.opalj.br.fpcf.FPCFAnalysisScheduler import org.opalj.br.fpcf.properties.SimpleContexts import org.opalj.br.fpcf.properties.SimpleContextsKey +import org.opalj.log.LogContext import org.opalj.tac.fpcf.analyses.cg.AllocationSitesPointsToTypeIterator +trait AllocationSiteBasedPointsToCallGraphKey extends PointsToCallGraphKey { + + override protected def registeredAnalyses(project: SomeProject): scala.collection.Seq[FPCFAnalysisScheduler] = { + implicit val logContext: LogContext = project.logContext + val config = project.config + + // TODO use FPCFAnalysesRegistry here + super.registeredAnalyses(project) ++ config.getStringList( + "org.opalj.tac.cg.AllocationSites.modules" + ).asScala.flatMap { moduleName => + resolveAnalysisRunner(if (moduleName.contains('.')) moduleName else getModuleFQN(moduleName)) + } + } + +} + /** * A [[org.opalj.br.analyses.ProjectInformationKey]] to compute a [[CallGraph]] based on * the points-to analysis. @@ -17,7 +37,7 @@ import org.opalj.tac.fpcf.analyses.cg.AllocationSitesPointsToTypeIterator * * @author Florian Kuebler */ -object AllocationSiteBasedPointsToCallGraphKey extends PointsToCallGraphKey { +object AllocationSiteBasedPointsToCallGraphKey extends AllocationSiteBasedPointsToCallGraphKey { override val pointsToType: String = "AllocationSiteBased" override val contextKey: ProjectInformationKey[SimpleContexts, Nothing] = SimpleContextsKey diff --git a/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_0_CallGraphKey.scala b/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_0_CallGraphKey.scala index 565ff91b61..f327f87c5b 100644 --- a/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_0_CallGraphKey.scala +++ b/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_0_CallGraphKey.scala @@ -20,7 +20,7 @@ import org.opalj.tac.fpcf.analyses.cg.TypesBasedPointsToTypeIterator * * @author Dominik Helm */ -object CFA_1_0_CallGraphKey extends PointsToCallGraphKey { +object CFA_1_0_CallGraphKey extends AllocationSiteBasedPointsToCallGraphKey { override val pointsToType: String = "TypeBased" override val contextKey: ProjectInformationKey[CallStringContexts, Nothing] = CallStringContextsKey diff --git a/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_1_CallGraphKey.scala b/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_1_CallGraphKey.scala index 295df97411..d6d497e72b 100644 --- a/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_1_CallGraphKey.scala +++ b/OPAL/tac/src/main/scala/org/opalj/tac/cg/CFA_1_1_CallGraphKey.scala @@ -18,7 +18,7 @@ import org.opalj.tac.fpcf.analyses.cg.CFA_k_l_TypeIterator * * @author Dominik Helm */ -object CFA_1_1_CallGraphKey extends PointsToCallGraphKey { +object CFA_1_1_CallGraphKey extends AllocationSiteBasedPointsToCallGraphKey { override val pointsToType: String = "AllocationSiteBased" override val contextKey: ProjectInformationKey[CallStringContexts, Nothing] = CallStringContextsKey diff --git a/OPAL/tac/src/main/scala/org/opalj/tac/cg/PointsToCallGraphKey.scala b/OPAL/tac/src/main/scala/org/opalj/tac/cg/PointsToCallGraphKey.scala index 02870441c2..96f69825f8 100644 --- a/OPAL/tac/src/main/scala/org/opalj/tac/cg/PointsToCallGraphKey.scala +++ b/OPAL/tac/src/main/scala/org/opalj/tac/cg/PointsToCallGraphKey.scala @@ -52,7 +52,7 @@ trait PointsToCallGraphKey extends CallGraphKey { } } - private def getModuleFQN(moduleName: String): String = { + protected def getModuleFQN(moduleName: String): String = { s"org.opalj.tac.fpcf.analyses.pointsto.${pointsToType}${moduleName}AnalysisScheduler" } }