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

osgi and aspectj annotations(?) are not recognized by ijar and logs are flooded with the noise #21781

Open
dkashyn-sfdc opened this issue Mar 22, 2024 · 13 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules type: feature request

Comments

@dkashyn-sfdc
Copy link

Description of the bug:

ijar produces extra logging that just floods the output without any real value.

That message is originating from

fprintf(stderr, "ijar: skipping unknown attribute: \"%s\".\n",
and it seems like different treatment required for different attributes.

aspectj output alone is huge

Which category does this issue belong to?

Java Rules

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

OSX, RHEL

What is the output of bazel info release?

7.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

INFO: From Extracting interface for jar external/org_osgi_org_osgi_core/org.osgi.core-4.3.0.jar [for tool]:
ijar: skipping unknown attribute: "Bridge".
ijar: skipping unknown attribute: "Bridge".
ijar: skipping unknown attribute: "Varargs".
ijar: skipping unknown attribute: "Varargs".
ijar: skipping unknown attribute: "Bridge".

aspectj is much more noisy, thousands of lines like (other annotations from org.aspectj.weaver are there as well see https://github.com/codehaus/backport175/blob/master/org.aspectj/modules/weaver/src/org/aspectj/weaver/AjAttribute.java for more of those)

ijar: skipping unknown attribute: "org.aspectj.weaver.EffectiveSignature".
ijar: skipping unknown attribute: "org.aspectj.weaver.AjSynthetic".
ijar: skipping unknown attribute: "org.aspectj.weaver.AjSynthetic".
ijar: skipping unknown attribute: "org.aspectj.weaver.AjSynthetic".
ijar: skipping unknown attribute: "org.aspectj.weaver.TypeMunger".
ijar: skipping unknown attribute: "org.aspectj.weaver.TypeMunger".
ijar: skipping unknown attribute: "org.aspectj.weaver.TypeMunger".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverVersion".
ijar: skipping unknown attribute: "org.aspectj.weaver.Aspect".
ijar: skipping unknown attribute: "org.aspectj.weaver.SourceContext".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverState".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLine
@hvadehra
Copy link
Member

hvadehra commented Apr 5, 2024

@dkashyn-sfdc do you have a minimal repro?

@dkashyn-sfdc
Copy link
Author

Not yet, but if you add org.osgi.core-4.3.0.jar as a dep to ANY project you'll see at least 4 of the warnings related to OSGI bit. I can try to locate exact aspectj dep to do the same if it helps.

@dkashyn-sfdc
Copy link
Author

dkashyn-sfdc commented Apr 5, 2024

Another one is INFO: From Extracting interface for jar external/org_apache_ws_commons_axiom_axiom_dom/axiom-dom-1.2.20.jar:

With endless output like

INFO: From Extracting interface for jar external/org_apache_ws_commons_axiom_axiom_dom/axiom-dom-1.2.20.jar:
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverVersion".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverState".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverVersion".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverState".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverVersion".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverState".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverVersion".
ijar: skipping unknown attribute: "org.aspectj.weaver.WeaverState".

and

❯ cat run_baseline.log | grep MethodDeclarationLineNumber |wc -l
3400

❯ cat run_baseline.log | grep '"org.aspectj.weaver.' |wc -l
8735

@dkashyn-sfdc
Copy link
Author

./ijar axiom-dom-1.2.20.jar axiom-dom-1.2.20-ijar.jar --target_label @@org_apache_ws_commons_axiom_axiom_dom//:org_apache_ws_commons_axiom_axiom_dom
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".
ijar: skipping unknown attribute: "org.aspectj.weaver.MethodDeclarationLineNumber".

https://repo1.maven.org/maven2/org/apache/ws/commons/axiom/axiom-dom/1.2.20/

@hvadehra
Copy link
Member

Thanks. It looks like this is WAI. There is some precedent for skipping this warning for well-known cases, but I'm not sure how well that scales for all such cases. Another option could be to cache these and only report an unknown attribute once per ijar invocation which could go a long way towards reducing spam?

That aside, I would have expected most builds today to use the header compiler (Turbine), and not ijar. what Bazel version are you using? Do you have header compilation explicitly disabled?

In the meantime, you might be able to workaround this with --output_filter and/or --ui_event_filters

@hvadehra hvadehra added type: feature request P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed type: bug more data needed labels Apr 16, 2024
@fmeum
Copy link
Collaborator

fmeum commented Apr 16, 2024

@hvadehra Based on the logs, I think that these warnings are emitted for java_import targets, which always use ijar.

@hvadehra
Copy link
Member

hvadehra commented Apr 16, 2024

I think that these warnings are emitted for java_import targets, which always use ijar.

Ah, right. Is it possible to maybe wrap the corresponding source jars in a java_library(..., srcs = ['org.osgi.core-4.3.0.srcjar']) instead (will likely need renaming the .jar to .srcjar)?

@dkashyn-sfdc
Copy link
Author

dkashyn-sfdc commented Apr 18, 2024

In our cases this is some external dep. Is it even beneficial to use ijar in this case? While it might help with the code that we own for external libs that are changing in ways that will erase all of the benefits from ijar anyway.

Turbine will be even more overkill in this case since artifacts are pre-built...

I suspect that in this case ijar and jar will be identical with probably even more overhead for ijar creation.

@hvadehra
Copy link
Member

Then maybe just build with --nouse_ijars? AFAICT it only applies to java_import. (well, also javac compilation iff header compilation is disabled).

@dkashyn-sfdc
Copy link
Author

I'll try --output_filter since java header compilation is something we are only experimenting with for now.

It is not speeding things up for us unless we use RBE and slowing them down for local env :(

Back to ijar: shouldn't those messages be deduplicated at least? There is no big value of reporting EVERY annotation and get 5k+ messages for a single jar file...

@fmeum
Copy link
Collaborator

fmeum commented Apr 22, 2024

@dkashyn-sfdc Are you using a recent version of rules_java and Bazel, which use a Graal Native Image of Turbine? Together with --experimental_java_classpath=bazel, I've found it to be faster on incremental changes even locally (although I haven't tested it on truly large individual files, e.g. generated code).

@fmeum
Copy link
Collaborator

fmeum commented Apr 22, 2024

I submitted #22072 to deduplicate the warnings.

copybara-service bot pushed a commit that referenced this issue Apr 30, 2024
Work towards #21781

Closes #22072.

PiperOrigin-RevId: 629359080
Change-Id: I2c813d3a9069ec125a914bfc57e6c9068c83d3bc
Kila2 pushed a commit to Kila2/bazel that referenced this issue May 13, 2024
Work towards bazelbuild#21781

Closes bazelbuild#22072.

PiperOrigin-RevId: 629359080
Change-Id: I2c813d3a9069ec125a914bfc57e6c9068c83d3bc
@dkashyn-sfdc
Copy link
Author

still seeing this with 7.2.0rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules type: feature request
Projects
None yet
Development

No branches or pull requests

6 participants