Skip to content

Commit 9d9bdb6

Browse files
author
Dominik Helm
committed
ObjectType -> ClassType
1 parent adab20c commit 9d9bdb6

File tree

11 files changed

+3589
-3589
lines changed

11 files changed

+3589
-3589
lines changed

artifacts/DeadMethods_JDK7u80/caseStudyCPA.html

Lines changed: 2385 additions & 2385 deletions
Large diffs are not rendered by default.

artifacts/DeadMethods_JDK7u80/caseStudyNaive.html

Lines changed: 592 additions & 592 deletions
Large diffs are not rendered by default.

artifacts/DeadMethods_JDK7u80/caseStudyOPA.html

Lines changed: 592 additions & 592 deletions
Large diffs are not rendered by default.

examples/BytecodeEngineering.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ <h3 id="adding-line-numbers">Adding Line Numbers</h3>
231231
).toDA()
232232
</code></pre>
233233
<h3 id="adding-further-attributes">Adding Further attributes</h3>
234-
<p>The DSL interacts seamlessly with the bytecode representation and all attibutes can always be added to the attributes as expected. For example, the following class file is marked as being <code>Synthetic</code> and the origin is set using <code>SourceFile(&quot;...&quot;)</code>. The method is marked as being <code>Deprecated</code> and as throwing the exceptions <code>java.lang.Exception</code>. In the last case, we use the DSL's <code>EXCEPTIONS</code> table builder. It enables us to just specify the names of the exceptions. Alternatively, it would have been possible to directly create the underlying <code>br.ExceptionsTable</code> using <code>ObjectType</code>s.</p>
234+
<p>The DSL interacts seamlessly with the bytecode representation and all attibutes can always be added to the attributes as expected. For example, the following class file is marked as being <code>Synthetic</code> and the origin is set using <code>SourceFile(&quot;...&quot;)</code>. The method is marked as being <code>Deprecated</code> and as throwing the exceptions <code>java.lang.Exception</code>. In the last case, we use the DSL's <code>EXCEPTIONS</code> table builder. It enables us to just specify the names of the exceptions. Alternatively, it would have been possible to directly create the underlying <code>br.ExceptionsTable</code> using <code>ClassType</code>s.</p>
235235
<pre><code>val cb = CLASS(
236236
accessModifiers = PUBLIC SUPER,
237237
thisType = &quot;SimpleMethodClass&quot;,

examples/ClassHierarchy.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ <h1 id="querying-the-class-hierarchy">Querying the Class Hierarchy</h1>
8989
val classHierarchy = p.classHierarchy
9090
</code></pre>
9191
<p>The class hierarchy, e.g., directly makes the information about a type's super/sub types available:</p>
92-
<pre><code>def subtypeInformation(ObjectType) : SubtypeInformation
93-
def supertypeInformation(ObjectType) : SupertypeInformation
92+
<pre><code>def subtypeInformation(ClassType) : SubtypeInformation
93+
def supertypeInformation(ClassType) : SupertypeInformation
9494
</code></pre>
9595
<p>To get, e.g., all subtypes of <code>java.io.Serializable</code>, it is sufficient to query the subtypes information:</p>
96-
<pre><code>val subtypesOfSerializable = classHierarchy.subtypeInformation(ObjectType(&quot;java/io/Serializable&quot;))
96+
<pre><code>val subtypesOfSerializable = classHierarchy.subtypeInformation(ClassType(&quot;java/io/Serializable&quot;))
9797
</code></pre>
9898
<blockquote>
9999
<p>Recall that in Java bytecode package names are separated using &quot;/&quot; and not &quot;.&quot; as used in Java/Scala/... source code.</p>
@@ -102,7 +102,7 @@ <h1 id="querying-the-class-hierarchy">Querying the Class Hierarchy</h1>
102102
<p>OPAL's class hierarchy supports partial class hierarchies and - in case that a class hierarchy is incomplete – generally follows a best-effort approach to determine sub-/supertype relations. In particular, when <code>isSubtypeOf</code> is used, <code>java.lang.Object</code> will always be treated as the supertype and an <strong>interface</strong> will never be the subtype of a class type, even if the supertype hierarchy for the interface is incomplete. As a matter of fact, the standard JDK/rt.jar contains references to classes that are not delivered as part of the JDK and therefore the class hierarchy is basically always incomplete.</p>
103103
</blockquote>
104104
<p>If you don't know whether a given type is known to the class hierarchy, you should call the <code>get</code> method to avoid potential <code>NoSuchElementExceptions</code>.</p>
105-
<pre><code>classHierarchy.subtypeInformation.get(ObjectType(&quot;java/io/Serializable&quot;)).foreach{subtypeInformation =&gt; ... }
105+
<pre><code>classHierarchy.subtypeInformation.get(ClassType(&quot;java/io/Serializable&quot;)).foreach{subtypeInformation =&gt; ... }
106106
</code></pre>
107107

108108
</div>

examples/TAC.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ <h3 id="using-the-3-address-code">Using the 3-Address Code</h3>
104104
<pre><code>val tac = p.get(ComputeACAIKey)
105105
</code></pre>
106106
<p><em>Step 3</em> - To get the TAC of a specific method with a body just look it up:</p>
107-
<pre><code>val cf = p.classFile(ObjectType(&quot;ai/domain/IntegerValuesFrenzy&quot;)).get
107+
<pre><code>val cf = p.classFile(ClassType(&quot;ai/domain/IntegerValuesFrenzy&quot;)).get
108108
val m = cf.findMethod(&quot;someSwitch&quot;).head
109109
val taCode = tac(m)
110110
</code></pre>
@@ -201,7 +201,7 @@ <h2 id="examples">Examples</h2>
201201
<pre><code>import org.opalj._
202202
val p = br.analyses.Project(new java.io.File(&quot;OPAL/bi/target/scala-2.13/resource_managed/test/ai.jar&quot;))
203203
val tacAIKey = p.get(tac.ComputeTACAIKey)
204-
val code = tacAIKey(p.classFile(br.ObjectType(&quot;ai/MethodsWithTypeChecks&quot;)).get.findMethod(&quot;requiredCast&quot;).head)
204+
val code = tacAIKey(p.classFile(br.ClassType(&quot;ai/MethodsWithTypeChecks&quot;)).get.findMethod(&quot;requiredCast&quot;).head)
205205
</code></pre>
206206
<p>The 3-address code of the above method is shown next:</p>
207207
<pre><code>static java.io.FileNotFoundException requiredCast(java.lang.Cloneable){

tutorial/ClassImmutabilityAnalysis.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import java.net.URL
22

33
import org.opalj.br.ClassFile
44
import org.opalj.br.Field
5-
import org.opalj.br.ObjectType
5+
import org.opalj.br.ClassType
66
import org.opalj.br.analyses.BasicReport
77
import org.opalj.br.analyses.Project
88
import org.opalj.br.analyses.ProjectAnalysisApplication
@@ -82,7 +82,7 @@ class ClassImmutabilityAnalysis(val project: SomeProject) extends FPCFAnalysis {
8282

8383
val superclassType = classFile.superclassType
8484

85-
if (superclassType.isDefined && superclassType.get != ObjectType.Object) {
85+
if (superclassType.isDefined && superclassType.get != ClassType.Object) {
8686
val superclass = project.classFile(superclassType.get)
8787
if (superclass.isEmpty)
8888
return Result(classFile, MutableClass)
@@ -238,9 +238,9 @@ class FieldImmutabilityAnalysis(val project: SomeProject) extends FPCFAnalysis {
238238
if (field.isFinal) field.fieldType match {
239239
case bt if bt.isBaseType =>
240240
TransitivelyImmutableField
241-
case wt: ObjectType if ObjectType.isPrimitiveTypeWrapper(wt) =>
241+
case wt: ClassType if ClassType.isPrimitiveTypeWrapper(wt) =>
242242
TransitivelyImmutableField
243-
case st if st == ObjectType.String =>
243+
case st if st == ClassType.String =>
244244
TransitivelyImmutableField
245245
case _ =>
246246
NonTransitivelyImmutableField

tutorial/CollaborativeAnalyses.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ <h1 id="collaborative-analyses">Collaborative Analyses</h1>
8888
<p>We will develop the implementation in small steps, but you can get the complete, runnable source code for this analysis <a href="InstantiatedTypesAnalysis.scala">here</a>.</p>
8989
<h2 id="defining-a-lattice">Defining a Lattice</h2>
9090
<p>As is always the case for fixed-point analyses in OPAL, we need a suitable lattice to represent our analysis' results.<br />
91-
In order to represent the set of all classes potentially instantiated, we thus create a lattice of set<sup title="OPAL's UIDSet is an optimized set for several kinds of entities in OPAL, including, e.g., ObjectType which represents the type of a class.">[note]</sup> values:</p>
91+
In order to represent the set of all classes potentially instantiated, we thus create a lattice of set<sup title="OPAL's UIDSet is an optimized set for several kinds of entities in OPAL, including, e.g., ClassType which represents the type of a class.">[note]</sup> values:</p>
9292
<pre><code class="language-scala">sealed trait InstantiatedTypesPropertyMetaInformation extends PropertyMetaInformation {
9393
final type Self = InstantiatedTypes
9494
}
9595

96-
case class InstantiatedTypes(classes: UIDSet[ObjectType]) extends InstantiatedTypesPropertyMetaInformation with OrderedProperty {
96+
case class InstantiatedTypes(classes: UIDSet[ClassType]) extends InstantiatedTypesPropertyMetaInformation with OrderedProperty {
9797
override def checkIsEqualOrBetterThan(e: Entity, other: InstantiatedTypes): Unit = {
9898
if (!classes.subsetOf(other.classes)) {
9999
throw new IllegalArgumentException(s&quot;$e: illegal refinement of $other to $this&quot;)
@@ -113,7 +113,7 @@ <h2 id="defining-a-lattice">Defining a Lattice</h2>
113113
)
114114
}
115115
</code></pre>
116-
<p>We use a case class here to provide a container for an arbitrary set of <a href="/library/api/SNAPSHOT/org/opalj/br/ObjectType.html"><code>ObjectType</code></a>s.</p>
116+
<p>We use a case class here to provide a container for an arbitrary set of <a href="/library/api/SNAPSHOT/org/opalj/br/ClassType.html"><code>ClassType</code></a>s.</p>
117117
<p>Note that for the <code>key</code>, we didn't just provide a fallback value, but a small function that is called whenever <code>InstantiatedTypes</code> are needed, but have not been computed.<br />
118118
This is to distinguish between two cases:<br />
119119
Either, the analysis (which we will implement below) was executed, but there simply are no classes that have been instantiated.

tutorial/FixedPointAnalyses.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ <h2 id="implementing-the-analysis">Implementing the Analysis</h2>
196196

197197
val superclassType = classFile.superclassType
198198

199-
if(superclassType.isDefined &amp;&amp; superclassType.get != ObjectType.Object) {
199+
if(superclassType.isDefined &amp;&amp; superclassType.get != ClassType.Object) {
200200
[...]
201201
}
202202

@@ -205,9 +205,9 @@ <h2 id="implementing-the-analysis">Implementing the Analysis</h2>
205205
</code></pre>
206206
<p>First, we get the type of the superclass from our classfile.<br />
207207
Note that some classes, in particular <code>java.lang.Object</code>, do not have superclasses, in which case we can't (and don't have to) check any superclass' immutability.<br />
208-
We also don't have to check the immutability of <code>java.lang.Object</code> (represented by <code>ObjectType.Object</code>) as we know it is transitively immutable because it has no fields.<br />
208+
We also don't have to check the immutability of <code>java.lang.Object</code> (represented by <code>ClassType.Object</code>) as we know it is transitively immutable because it has no fields.<br />
209209
Checking whether the superclass is <code>java.lang.Object</code> not only allows us to skip checking the superclass, but also allows to get useful results even when the JDK is not part of our analyzed software and thus the classfile for <code>java.lang.Object</code> is not available.</p>
210-
<pre><code class="language-scala"> if(superclassType.isDefined &amp;&amp; superclassType.get != ObjectType.Object) {
210+
<pre><code class="language-scala"> if(superclassType.isDefined &amp;&amp; superclassType.get != ClassType.Object) {
211211
val superclass = project.classFile(superclassType.get)
212212
if(superclass.isEmpty)
213213
return Result(classFile, MutableClass)

tutorial/InstantiatedTypesAnalysis.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import java.net.URL
22

33
import org.opalj.collection.immutable.UIDSet
44
import org.opalj.br.DeclaredMethod
5-
import org.opalj.br.ObjectType
5+
import org.opalj.br.ClassType
66
import org.opalj.br.analyses.BasicReport
77
import org.opalj.br.analyses.Project
88
import org.opalj.br.analyses.ProjectAnalysisApplication
@@ -44,7 +44,7 @@ sealed trait InstantiatedTypesPropertyMetaInformation extends PropertyMetaInform
4444
final type Self = InstantiatedTypes
4545
}
4646

47-
case class InstantiatedTypes(classes: UIDSet[ObjectType]) extends InstantiatedTypesPropertyMetaInformation with OrderedProperty {
47+
case class InstantiatedTypes(classes: UIDSet[ClassType]) extends InstantiatedTypesPropertyMetaInformation with OrderedProperty {
4848
override def checkIsEqualOrBetterThan(e: Entity, other: InstantiatedTypes): Unit = {
4949
if (!classes.subsetOf(other.classes)) {
5050
throw new IllegalArgumentException(s"$e: illegal refinement of $other to $this")

0 commit comments

Comments
 (0)