Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import constant pool of classes #309

Closed
codecholeric opened this issue Feb 8, 2020 · 0 comments · Fixed by #518
Closed

Import constant pool of classes #309

codecholeric opened this issue Feb 8, 2020 · 0 comments · Fixed by #518

Comments

@codecholeric
Copy link
Collaborator

If it is feasible with reasonable effort, we could take the constant pool of classes into account when importing classes. This would make it possible to detect dependencies which occur just through the constant pool of a class (compare #298)

Note that ASM does not support a direct access to the constant pool, thus I don't know out of the box how to achieve this in the best way. Maybe it would be possible to observe all the ldc instructions of all classes through ASM. Or we would need a different approach to read the constant pool of classes.

codecholeric added a commit that referenced this issue Jan 31, 2021
So far ArchUnit has not been able to detect the pure usage of class objects as dependencies. E.g. the following example would not have detected a dependency on `Evil`, since besides the reference to the class object no further dependency on `Evil` (like a field access or method call) has occurred.

```
class Example {
  final Map<Class<?>, Object> association = Map.of(Evil.class, anything);
}
```

With this PR `JavaClass` now knows its `referencedClassObjects`, including the respective line number. Furthermore class objects are now parts of the `dependencies{From/To}Self` of a `JavaClass`.

Resolves: #309 
Issue: #446 
Resolves: #474 
Resolves: #515
codecholeric added a commit that referenced this issue Feb 21, 2021
So far ArchUnit has not been able to detect the pure usage of class objects as dependencies. E.g. the following example would not have detected a dependency on `Evil`, since besides the reference to the class object no further dependency on `Evil` (like a field access or method call) has occurred.

```
class Example {
  final Map<Class<?>, Object> association = Map.of(Evil.class, anything);
}
```

With this PR `JavaClass` now knows its `referencedClassObjects`, including the respective line number. Furthermore class objects are now parts of the `dependencies{From/To}Self` of a `JavaClass`.

Resolves: #309 
Issue: #446 
Resolves: #474 
Resolves: #515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant