Skip to content

Conversation

jonathanpeppers
Copy link
Member

API 31 builds fail when using JDK 1.8 with:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3):
error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

To solve this issue, we must require JDK 11 for API 31.

There are two code paths here for "legacy" Xamarin.Android and .NET 6.
Legacy is straightforward, as we already had a pattern for this.

In .NET 6, I checked the $(TargetPlatformVersion) property for now
and require JDK 11 in that case. When API 31 is stable, we can
probably remove this code and just set this value by default:

<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>

I updated some tests in this area as well.

@jonathanpeppers jonathanpeppers marked this pull request as ready for review July 13, 2021 20:04
@jonpryor
Copy link
Contributor

We're starting to wonder if we properly understand what's going on here. The current PR build, which requires JDK 11 for API-31+, has lots of unit test failures, most of which are because of the new check, e.g. LatestTFV_OldTargetSdkVersion:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(239,5):
error XA0031: Java SDK 11.0 or above is required when using $(TargetFrameworkVersion) v11.0.99. 

These tests are currently building now, meaning most of our tests are currently able to target v11.0.99 ("API-S") and build. They're building now, without incurring the JAVAC0000 error about unrecognized Attribute name MODULE.

There's something important that we're not understanding here. :-(

More investigation is required.

@jonathanpeppers
Copy link
Member Author

jonathanpeppers commented Jul 16, 2021

The tests that fail in #6094 are Xamarin.Forms 4.0 apps that use Android Support libraries.

So I tried doing a Blank Android App in VS 2022, then changed TargetFrameworkVersion=v11.0.99. It also failed with the error.

The problem went away when I removed all AndroidX packages. So perhaps, the presence of Android Support or AndroidX causes the issue? Many of our tests just use plain Android.

@jonathanpeppers jonathanpeppers marked this pull request as draft July 20, 2021 20:32
@jonathanpeppers jonathanpeppers force-pushed the jdk11-api31 branch 3 times, most recently from 95e8eec to 2deaad5 Compare July 26, 2021 18:45
@jonathanpeppers jonathanpeppers marked this pull request as ready for review July 28, 2021 15:39
@jonathanpeppers
Copy link
Member Author

Ugh, need to fix the conflict

API 31 builds fail when using JDK 1.8 with:

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3):
    error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

To solve this issue, we must require JDK 11 for API 31.

There are two code paths here for "legacy" Xamarin.Android and .NET 6.
Legacy is straightforward, as we already had a pattern for this.

In .NET 6, I checked the `$(TargetPlatformVersion)` property for now
and require JDK 11 in that case. When API 31 is stable, we can
probably remove this code and just set this value by default:

    <MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>

* Add new `AssertTargetFrameworkVersionSupported()` method

In tests where it makes sense, I used a different
`$(TargetFrameworkVersion)` or just removed what was setting the
property entirely.

Other tests, I used a `AssertTargetFrameworkVersionSupported()` method
to `Assert.Ignore()` the test if it would not pass otherwise.
@jonpryor
Copy link
Contributor

API-31 builds fail when using JDK 1.8 and using AndroidX with:

	/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3):
	error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

There are two plausible solutions to better handle this:

 1. Only require JDK 11 when API-31 and AndroidX are being used, or
 2. Always required JDK 11 for API-31+

As we believe *most* apps will be using AndroidX, there is little
point to attempting so support (1); (2) it is!

We must require JDK 11 for API-31+.

There are two code paths here: one for "legacy" Xamarin.Android, and
one for .NET 6.

Legacy is straightforward, as we already had a pattern for this, we
just update the `<ValidateJavaVersion/>` task.

For .NET 6, I checked the `$(TargetPlatformVersion)` property for now
and require JDK 11 in that case.  When API-31 is stable, we can
probably remove this code and just set this value by default:

	<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>

For our unit tests -- most of which would be solution (1) (API-31
and *no* AndroidX use), but many of which started to fail because we
went with solution (2) -- we did one of two things:

 1. Use a different `$(TargetFrameworkVersion)` and/or remove
    `$(TargetFrameworkVersion)` entirely, or

 2. Use a new `BuildTest.AssertTargetFrameworkVersionSupported()`
    method which `Assert.Ignore()`s the test if it would not
    pass otherwise.

@jonpryor jonpryor merged commit 8140991 into dotnet:main Jul 29, 2021
@jonathanpeppers jonathanpeppers deleted the jdk11-api31 branch July 29, 2021 21:10
jonpryor pushed a commit to jonpryor/xamarin-android that referenced this pull request Aug 25, 2021
API-31 builds fail when using JDK 1.8 and using AndroidX with:

	/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3):
	error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

There are two plausible solutions to better handle this:

 1. Only require JDK 11 when API-31 and AndroidX are being used, or
 2. Always required JDK 11 for API-31+

As we believe *most* apps will be using AndroidX, there is little
point to attempting so support (1); (2) it is!

We must require JDK 11 for API-31+.

There are two code paths here: one for "legacy" Xamarin.Android, and
one for .NET 6.

Legacy is straightforward, as we already had a pattern for this, we
just update the `<ValidateJavaVersion/>` task.

For .NET 6, I checked the `$(TargetPlatformVersion)` property for now
and require JDK 11 in that case.  When API-31 is stable, we can
probably remove this code and just set this value by default:

	<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>

For our unit tests -- most of which would be solution (1) (API-31
and *no* AndroidX use), but many of which started to fail because we
went with solution (2) -- we did one of two things:

 1. Use a different `$(TargetFrameworkVersion)` and/or remove
    `$(TargetFrameworkVersion)` entirely, or

 2. Use a new `BuildTest.AssertTargetFrameworkVersionSupported()`
    method which `Assert.Ignore()`s the test if it would not
    pass otherwise.
jonpryor pushed a commit that referenced this pull request Aug 26, 2021
API-31 builds fail when using JDK 1.8 and using AndroidX with:

	/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1728,3):
	error JAVAC0000: java.lang.AssertionError: annotationType() : unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

There are two plausible solutions to better handle this:

 1. Only require JDK 11 when API-31 and AndroidX are being used, or
 2. Always required JDK 11 for API-31+

As we believe *most* apps will be using AndroidX, there is little
point to attempting so support (1); (2) it is!

We must require JDK 11 for API-31+.

There are two code paths here: one for "legacy" Xamarin.Android, and
one for .NET 6.

Legacy is straightforward, as we already had a pattern for this, we
just update the `<ValidateJavaVersion/>` task.

For .NET 6, I checked the `$(TargetPlatformVersion)` property for now
and require JDK 11 in that case.  When API-31 is stable, we can
probably remove this code and just set this value by default:

	<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>

For our unit tests -- most of which would be solution (1) (API-31
and *no* AndroidX use), but many of which started to fail because we
went with solution (2) -- we did one of two things:

 1. Use a different `$(TargetFrameworkVersion)` and/or remove
    `$(TargetFrameworkVersion)` entirely, or

 2. Use a new `BuildTest.AssertTargetFrameworkVersionSupported()`
    method which `Assert.Ignore()`s the test if it would not
    pass otherwise.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 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