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

[class-parse] Ignore module-info.class file. #1093

Merged
merged 2 commits into from
Apr 11, 2023
Merged

[class-parse] Ignore module-info.class file. #1093

merged 2 commits into from
Apr 11, 2023

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Apr 4, 2023

Some AndroidX packages contain a file called module-info.class that is not a standard .class file. Rather, this file is a metadata file for Java Modules (documentation).

image

class-parse emit this for the file:

<package
  name=""
  jni-name="">
  <class
    abstract="false"
    deprecated="not deprecated"
    final="false"
    name="module-info"
    jni-signature="Lmodule-info;"
    source-file-name="module-info.java"
    static="false"
    visibility="" />
</package>

When we try to resolve this type, generator emits the following warning:

warning BG8605: The Java type '' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)

This is neither useful nor actionable. Instead, we should ignore this file in class-parse.

@jpobst jpobst marked this pull request as ready for review April 10, 2023 14:34
@jonpryor jonpryor mentioned this pull request Apr 10, 2023
3 tasks
@jonpryor
Copy link
Member

jonpryor commented Apr 10, 2023

Commit message:

Context: https://repo1.maven.org/maven2/org/jetbrains/annotations/24.0.1/annotations-24.0.1.jar
Context: https://github.com/xamarin/java.interop/issues/1096

Some AndroidX packages contain a file called `module-info.class` that
uses unsupported `.class` constructs.  It contains metadata for Java
Modules.

![image](https://user-images.githubusercontent.com/179295/229861846-cbd04239-9d7b-470b-ae6c-844713009104.png)

`class-parse` emits this for the file:

	<package
	    name=""
	    jni-name="">
	  <class
	      abstract="false"
	      deprecated="not deprecated"
	      final="false"
	      name="module-info"
	      jni-signature="Lmodule-info;"
	      source-file-name="module-info.java"
	      static="false"
	      visibility="" />
	</package>

When we try to process this `<class/>`, `generator` emits the warning:

	warning BG8605: The Java type '' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)

This is neither useful nor actionable.

Ignore this file in `class-parse`, until we can properly parse it.

TODO: Issue #1096

if (entry.Name.EndsWith (".jnilib", StringComparison.OrdinalIgnoreCase))
return false;

using var s = entry.Open ();
Copy link
Member

Choose a reason for hiding this comment

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

In the context of #1092, should this instead use BufferedStream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we want it in this case, as we are reading a single value from the Stream and then closing it. If we use BufferedStream it would need to read xKB into the buffer instead of the single 4 byte read.

@jonpryor jonpryor merged commit 71e586b into main Apr 11, 2023
@jonpryor jonpryor deleted the no-module-info branch April 11, 2023 12:13
jonpryor pushed a commit to dotnet/android that referenced this pull request Apr 13, 2023
Changes: dotnet/java-interop@a172402...554d819

  * dotnet/java-interop@554d8193: [ci] Automatically retry failed native unit test failures once (dotnet/java-interop#1095)
  * dotnet/java-interop@71e586b0: [class-parse] Ignore `module-info.class` file. (dotnet/java-interop#1093)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants