forked from TNG/ArchUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect *checkcast* asm instructions as TypeCast (similar to InstanceofCheck) Implicit checkcast instructions generated by compiler due to method invocations are ignored Signed-off-by: Allan Jones <[email protected]>
- Loading branch information
Showing
34 changed files
with
691 additions
and
3 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
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
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
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
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
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
90 changes: 90 additions & 0 deletions
90
archunit/src/main/java/com/tngtech/archunit/core/domain/TypeCast.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,90 @@ | ||
/* | ||
* Copyright 2014-2023 TNG Technology Consulting GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.tngtech.archunit.core.domain; | ||
|
||
import com.tngtech.archunit.PublicAPI; | ||
import com.tngtech.archunit.core.domain.properties.HasOwner; | ||
import com.tngtech.archunit.core.domain.properties.HasSourceCodeLocation; | ||
import com.tngtech.archunit.core.domain.properties.HasType; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS; | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public final class TypeCast implements HasType, HasOwner<JavaCodeUnit>, HasSourceCodeLocation { | ||
|
||
private final JavaCodeUnit owner; | ||
private final JavaClass type; | ||
private final int lineNumber; | ||
private final boolean declaredInLambda; | ||
private final SourceCodeLocation sourceCodeLocation; | ||
|
||
private TypeCast(JavaCodeUnit owner, JavaClass type, int lineNumber, boolean declaredInLambda) { | ||
this.owner = checkNotNull(owner); | ||
this.type = checkNotNull(type); | ||
this.lineNumber = lineNumber; | ||
this.declaredInLambda = declaredInLambda; | ||
sourceCodeLocation = SourceCodeLocation.of(owner.getOwner(), lineNumber); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public JavaClass getRawType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public JavaType getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public JavaCodeUnit getOwner() { | ||
return owner; | ||
} | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public int getLineNumber() { | ||
return lineNumber; | ||
} | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public boolean isDeclaredInLambda() { | ||
return declaredInLambda; | ||
} | ||
|
||
@Override | ||
public SourceCodeLocation getSourceCodeLocation() { | ||
return sourceCodeLocation; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return toStringHelper(this) | ||
.add("owner", owner) | ||
.add("type", type) | ||
.add("lineNumber", lineNumber) | ||
.add("declaredInLambda", declaredInLambda) | ||
.toString(); | ||
} | ||
|
||
static TypeCast from(JavaCodeUnit owner, JavaClass type, int lineNumber, boolean declaredInLambda) { | ||
return new TypeCast(owner, type, lineNumber, declaredInLambda); | ||
} | ||
} |
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
Oops, something went wrong.