Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 28 2020 12:05
    pushed to delors/opal
    Merged in florian_kuebler/readmemarkdown-edited-online-with-bitbuc-1578400042961 (pull request #534) Updated Readme.markdown with deprecation/github migration statement Approved-by: errt <helm@cs.tu-darmstadt.de> (compare)
  • Apr 28 2020 12:05
    pushed to delors/opal
    0 commits
  • Jan 07 2020 12:28
    pushed to delors/opal
    Updated Readme.markdown with deprecation/github migration statement (compare)
  • Oct 10 2019 13:54
    pushed to delors/opal
    A few minor adaptions (compare)
  • Oct 10 2019 13:23
    pushed to delors/opal
    Formatting... (compare)
  • Oct 10 2019 13:16
    pushed to delors/opal
    Measure performace on 5 runs (compare)
  • Oct 07 2019 11:35
    pushed to delors/opal
    Adapt to changes in OPAL implementation (compare)
  • Aug 30 2019 11:52
    pushed to delors/opal
    fixed an issue related to the removal of dependers from a final EPK state (compare)
  • Aug 30 2019 09:09
    pushed to delors/opal
    3 commits
  • Aug 30 2019 09:04
    pushed to delors/opal
    Don't schedule PointsTo Analysis for other CGs (compare)
  • Aug 29 2019 14:32
    pushed to delors/opal
    2 commits
  • Aug 29 2019 14:27
    pushed to delors/opal
    3 commits
  • Aug 29 2019 14:09
    pushed to delors/opal
    2 commits
  • Aug 29 2019 13:36
    pushed to delors/opal
    2 commits
  • Aug 29 2019 13:18
    pushed to delors/opal
    10 commits
  • Aug 29 2019 13:16
    pushed to delors/opal
    More code duplication but should be slightly faster (compare)
  • Aug 29 2019 13:06
    pushed to delors/opal
    Prevent useless partial results (compare)
  • Aug 28 2019 15:04
    pushed to delors/opal
    improved the performance of LongTrieSet by specializing the grow function (compare)
  • Aug 27 2019 13:47
    pushed to delors/opal
    4 commits
  • Aug 27 2019 13:24
    pushed to delors/opal
    Commit just for testing purposes (compare)
Michael Eichberg
@Delors
To get the bytecode you can simply ask the project. <project>.classFile(ObjectType(“java/util/List”)).
Please note that you have to use the binary name which seperates the packages using “/“ and not “.”.
If you are interested in the 3-address code, the way how to get it depends on the way how you computed it. In this case, you should simply post the respective code snippet.
Michael Eichberg
@Delors
The simplest way to get the 3-address code is to use the “DefaultTACAIKey”.
val m : Method = …;
val tacAI = <project>.get(DefaultTACAIKey)(m)
You can also find a number of snippets related to common tasks on:[https://bitbucket.org/snippets/delors/]
Florian Kübler
@florian-kuebler

@majestocx Regarding the Call Graph:
Call Graphs in Opal are represented as two distinct properties, handling either the callers of a certain method (org.opalj.br.fpcf.cg.properties.CallersProperty), or for a given call site (method and program counter) the set of potential targets (org.opalj.br.fpcf.cf.properties.Callees).

In order two retrieve these properties for a given Method you have to do the follwing three steps:
1: Build the call graph.

val ps = project.get(PropertyStoreKey)
val manager = project.get(FPCFAnalysesManagerKey)
implicit val declaredMethods = project.get(DeclaredMethodsKey)
manager.runAll(
                RTACallGraphAnalysisScheduler,
                TriggeredStaticInitializerAnalysis,
                TriggeredLoadedClassesAnalysis,
                TriggeredFinalizerAnalysisScheduler,
                TriggeredThreadRelatedCallsAnalysis,
                TriggeredSerializationRelatedCallsAnalysis,
                TriggeredReflectionRelatedCallsAnalysis,
                TriggeredInstantiatedTypesAnalysis,
                TriggeredConfiguredNativeMethodsAnalysis,
                TriggeredSystemPropertiesAnalysis,
                LazyCalleesAnalysis(
                    Set(
                        StandardInvokeCallees,
                        SerializationRelatedCallees,
                        ReflectionRelatedCallees,
                        ThreadRelatedIncompleteCallSites
                    )
                ),
                LazyL0BaseAIAnalysis,
                TACAITransformer
)
  1. “Convert” a method to declared method

    val dm = declaredMethods(method)
  2. Retrieve the callers/callees for that declared method:

    ps(dm, CallersProperty.key /*Callees.key*/)

I have to admit, that this is rather complicated.
Unfortunately, a more elegant way to retrieve the call graph is under development right now, and only available at the feature/CallGraphKey branch.

Alexander Gössl
@majestocx
Ok i have the tacAI Variable how can i get the Text representation of the TAC ?
Alexander Gössl
@majestocx
Is tacAI not applicable on a class?
def getTacForClass(tacForClass : TACForClass) : String = {
val tacAI = project.get(DefaultTACAIKey)
val tacClass = project.allClassFiles.find(_.fqn == tacForClass.fqn).get
tacAI(tacClass);
}
Florian Kübler
@florian-kuebler
No the TAC is a function from Method to TACode
Alexander Gössl
@majestocx
ok is there a way to get from a class to tac in txt format ?
Michael Eichberg
@Delors
Yes… you can use the ToTxt class which provides a respective function.
For a concrete usage of that class see “org.opalj.tac.TAC”.
The latter class also provides a command-line interface to get the TAC of a specific method.
 val aiResult = BaseAI(m, d)
                        val tac @ TACode(params, code, _, cfg, ehs, _) =
                            TACAI(m, project.classHierarchy, aiResult)(Nil)
                        if (toString) Console.out.println(m.toJava(tac.toString))

                        (
                            ToTxt(params, code, cfg, skipParams = false, true, true).mkString("\n”),
does this help?
Alexander Gössl
@majestocx
yes
thank you
Alexander Gössl
@majestocx
I have another question: Is the fqn of a class like this: org.opalj.tac.TAC ok like this: org/opalj/tac/TAC or none of it?
Michael Eichberg
@Delors
The latter - if you want the first variant call „toJava“
Michael Eichberg
@Delors
To get a specific class file belonging to a project use project.classFile(ObjectType(<Name of class in fqn>)). This is a constant operation; using find is linear operation!
kebiro
@kebiro

Hello,

we had a little chat about this before: there is possibly a bug in OPAL regarding an escaping backslash. It seems to escape them before outputting the text. I'll provide an example.

image.png
This is the original string in String.java
In String.classit looks like this:
image.png
Alexander Gössl
@majestocx
ok i got my method working thanks all for your help!
kebiro
@kebiro
However, the TAC output looks like this:
image.png
There is only a single backslash left, hence the following " is escaped, so until another " appears everything will be seen as a string.
Michael Eichberg
@Delors
Yep
Alexander Gössl
@majestocx
Ok im working on this again so i have some more questions.
I try to use the MethodDescriptor object like this: MethodDescriptor("(): void").
I get this exception:
[info] java.lang.IllegalArgumentException: : void is not a valid field type descriptor
[info] at org.opalj.br.FieldType$.apply(Type.scala:361)
[info] at org.opalj.br.ReturnType$.apply(Type.scala:278)
[info] at org.opalj.br.MethodDescriptor$.apply(MethodDescriptor.scala:667)
Is my argument wrong?
I also tried this: MethodDescriptor("(java.lang.String[]): void") but i get java.lang.IllegalArgumentException: j is not a valid field type descriptor
I get same results with / instead of .
Michael Reif
@mreif

This is indeed wrong. When passing a String argument to a MethodDescriptor you have to pass it in JVM notation.

MethodDescriptor("([Ljava/lang/String;)V")

However, I would not recommend doing this because it's rather error-prone. You should use the other apply methods MethodDescriptor offers. Here are two examples:

MethodDescriptor(ArrayType(ObjectType.String), VoidType) // first parameter represents the parameter list, the second the return type MethodDescriptor(RefArray(LongType,ByteType,ObjectType.String), BooleanType) // a method with (long, byte, String): boolean

You can find more example in OPAL's MethodDescriptor class itself
Alexander Gössl
@majestocx
ok i will give it a try
thanks for your answer
Alexander Gössl
@majestocx
it works :)
Michael Reif
@mreif
Good :-)
Alexander Gössl
@majestocx
@florian-kuebler I implemented your snippeet about the call graph. I have org.opalj.fpcf.EOptionP[org.opalj.br.DefinedMethod,org.opalj.br.fpcf.cg.properties.CallersProperty]. Is there a method to get from that to an svg?
Florian Kübler
@florian-kuebler
Unfortunately, the answer is no
Alexander Gössl
@majestocx
ok
Alexander Gössl
@majestocx
Is it possible to get the TAC from a class inside the jdk ? Like java/lang/String ?
Florian Kübler
@florian-kuebler
If the JDK is part of the project, it works just as for any other class. The File constant org.opalj.bytecode.RTJar, is the File of the current Java Runtime.
Alexander Gössl
@majestocx
Ok thanks for the information @florian-kuebler. I tried to get the TAC but method.body seems to be None. The jdk is part of the Analysis and libraryClassFilesAreInterfacesOnly is set to false.
Michael Eichberg
@Delors
How do you load the library? The method body should only be None if the method doesn’t have one (native or abstract) or if it is discarded while loading it. BTW libraryClassFilesAreInterfacesOnly actually doesn’t change how the classes are loaded - it basically reflects how the classes are expected to be loaded. That is, it might be possible that the “discarding" loader was used but libraryClassFilesAreInterfacesOnly is still false.
Alexander Gössl
@majestocx
Ok i will check wether the method is native / abstract. This is how the librarie is loaded:
val libraryClassFiles = Java9LibraryFramework.AllClassFiles(opalInit.libraries.map(new File(_)) :+ org.opalj.bytecode.RTJar )
Michael Eichberg
@Delors
ok…. Java9LibraryFramework kills the method bodies