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

Fix several bugs #212

Merged
merged 8 commits into from
Apr 12, 2024
Merged

Fix several bugs #212

merged 8 commits into from
Apr 12, 2024

Conversation

kriegaex
Copy link
Contributor

This PR should, step by step, fix all problems mentioned in #211, not just the original one, but also the other ones mentioned in comments. The plan is to push and build commit by commit in order to find out if the bugfixes actually break existing tests which falsely expect faulty behaviour.

I might force-push commits, adding other tests or editing commit messages, referring to future issues I might open in order to split the catch-all issue #211 into distinct issues per topic, which later we can also refer to from release notes.

@kriegaex kriegaex self-assigned this Jan 17, 2023
@kriegaex kriegaex added bug Something isn't working enhancement New feature or request labels Jan 17, 2023
@kriegaex kriegaex added this to the 1.9.20 milestone Jan 17, 2023
Copy link
Contributor Author

@kriegaex kriegaex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete due to force push, please see next comment.

@kriegaex
Copy link
Contributor Author

@aclement, I am quite satisfied with the other commits in this PR, but for commit a70ffd3 even more than for the others I would like to get your feedback. Please read the lengthy commit comment and recommend a way to handle this situation. Thank you so much.

It is unnecessary to represent a pattern list 'A,B,C' as '(A,B,C)'. Not
only does it look ugly in a type signature like 'org.acme.Foo<(A,B,C)>',
but also is it not valid Java syntax. While the latter might not be
strictly necessary in a String representation, it certainly is
desirable, if such representations are ever used to generate code or
@AspectJ pointcut annotations.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
For array reference types, match type parameters on component type, not
on array type itself.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
In generic type lists, after a '*' in any type parameter list, sometimes
the '*' (which should be converted to '?') itself and always the
subsequent parameters would be missing from the signature:

  - '[Pjava/util/Collection<*>;' yielded
    'java.util.Collection<>[]', but should be
    'java.util.Collection<?>[]'

  - '[Pjava/util/Map<*Pjava/util/List<[Ljava/lang/Integer;>;>;' yielded
    'java.util.Map<?>[]', but should be
    'java.util.Map<?,java.util.List<java.lang.Integer[]>>[]'

This is now fixed.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Because void arrays are illegal (and nonsensical), now there is a new
Xlint warning whenever World.resolve resolves a new 'void[]'. Because
in the World class we do not have any source context, no path + line
number are logged. The user only sees something like:

  [warning] arrays cannot have a void type, but found 'void[]' in
  pointcut [Xlint:arrayCannotBeVoid]

Then later, if due to the returned MissingResolvedTypeWithKnownSignature
type a joinpoint does not match, there is an additional

  my/path/MyAspect.aj:42 [warning] advice defined in MyAspect has not
  been applied [Xlint:adviceDidNotMatch]

log line, but not necessarily anywhere near the former one.

On the one hand, this is better than nothing. OTOH, comparing the
situation with no logging message other than Xlint:adviceDidNotMatch in
case of something equally illegal like 'Foo<int>' (primitive generic
type parameter), this is actually more than we have in several other
situations and might even be regarded as superfluous. In case of
multiple 'void[]' cases within a big number of aspects, the same aspect
or even the same pointcut, the user would have no clue where exactly to
search for it. He would just see multiple log messages without source
context.

One option would be to set 'arrayCannotBeVoid=ignore' in
XlintDefault.properties, so the user would have to explicitly activate
it. But IMO, this message should be visible by default.

Another option would be to find out how to defer logging the messages
until later similarly to BcelWeaver.warnOnUnmatchedAdvice and then to
bulk-print them. But in order to achieve that, the information about the
existence of any 'void[]' occurrences would have to be stored in a flag
similar to BcelAdvice.hasMatchedAtLeastOnce, bloating BcelAdvice for
that rare case. Alternatively, each advice pointcut could be
heuristically scanned for the literal substring 'void[]', logging the
Xlint message if it is found anywhere.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
The test needs to expect the lately introduced Xlint:arrayCannotBeVoid
warning to be thrown, because one of the pointcuts in
tests/bugs165/pr272233/Iffy2.java contains a 'void[]' return type in a
method signature.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
- Bugfix: Flush stream.
- Adjust format to more closely resemble JVM format. E.g., do not print
  the causing exception name twice.
- Add TODO, because this whole custom stack trace printing can just go
  away. The JVM format should do just fine. This commit is merely meant
  to document the decision to remove the cruft in the next commit.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
- Improvement: Also add CompilationAndWeavingContext for constructor
  with causing exception
- Remove home-brew stack trace printing, just call super constructors

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Add more funky pointcuts concerning 'void[]' and pointcuts matching
arrays of generic types. Remove TODO after previously committed bugfix.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
@kriegaex kriegaex marked this pull request as ready for review April 12, 2024 13:32
@kriegaex kriegaex merged commit 287ec8f into master Apr 12, 2024
1 of 4 checks passed
@kriegaex kriegaex deleted the gh-211 branch April 12, 2024 13:32
@kriegaex kriegaex modified the milestones: 1.9.23, 1.9.22.1 Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant