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

Turbine crashes on certain sealed usages #22109

Open
fmeum opened this issue Apr 24, 2024 · 4 comments
Open

Turbine crashes on certain sealed usages #22109

fmeum opened this issue Apr 24, 2024 · 4 comments
Labels
next_month Issues that we will review next month. This is currently mainly used by Configurability team P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug

Comments

@fmeum
Copy link
Collaborator

fmeum commented Apr 24, 2024

Description of the bug:

Turbine fails when using sealed with permits on a generated class:

java.lang.AssertionError: ERROR_TY
	at com.google.turbine.binder.TypeBinder.bind(TypeBinder.java:239)
	at com.google.turbine.binder.TypeBinder.bind(TypeBinder.java:149)
	at com.google.turbine.binder.Binder.bindTypes(Binder.java:319)
	at com.google.turbine.binder.Binder.bind(Binder.java:168)
	at com.google.turbine.binder.Binder.bind(Binder.java:110)
	at com.google.turbine.binder.Binder.bind(Binder.java:94)
	at com.google.turbine.main.Main.bind(Main.java:270)
	at com.google.turbine.main.Main.compile(Main.java:158)
	at com.google.turbine.main.Main.compile(Main.java:133)
	at com.google.turbine.main.Main.main(Main.java:89)
	at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

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.

  1. Check out Bazel at 45836d0.
  2. Apply this patch:
git diff src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileValue.java
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileValue.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileValue.java
index 7c7e38fd6c..bf8e2a10a5 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileValue.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileValue.java
@@ -27,7 +27,7 @@ import com.google.devtools.build.skyframe.SkyValue;
 import javax.annotation.Nullable;

 /** The result of {@link ModuleFileFunction}. */
-public abstract class ModuleFileValue implements SkyValue {
+public abstract sealed class ModuleFileValue implements SkyValue {

   public static final ModuleFileValue.Key KEY_FOR_ROOT_MODULE = key(ModuleKey.ROOT, null);

@@ -43,7 +43,8 @@ public abstract class ModuleFileValue implements SkyValue {

   /** The {@link ModuleFileValue} for non-root modules. */
   @AutoValue
-  public abstract static class NonRootModuleFileValue extends ModuleFileValue {
+  public abstract static sealed class NonRootModuleFileValue extends ModuleFileValue
+      permits AutoValue_ModuleFileValue_NonRootModuleFileValue {

     public static NonRootModuleFileValue create(InterimModule module, String moduleFileHash) {
       return new AutoValue_ModuleFileValue_NonRootModuleFileValue(module, moduleFileHash);
@@ -55,7 +56,8 @@ public abstract class ModuleFileValue implements SkyValue {
    * overrides.
    */
   @AutoValue
-  public abstract static class RootModuleFileValue extends ModuleFileValue {
+  public abstract static sealed class RootModuleFileValue extends ModuleFileValue
+      permits AutoValue_ModuleFileValue_RootModuleFileValue {
     /**
      * The overrides specified by the evaluated module file. The key is the module name and the
      * value is the override itself.
  1. Attempt to build //src:bazel-dev.

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

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?

No response

@fmeum
Copy link
Collaborator Author

fmeum commented Apr 24, 2024

cc @cushon

@github-actions github-actions bot added the team-Rules-Java Issues for Java rules label Apr 24, 2024
@cushon
Copy link
Contributor

cushon commented Apr 24, 2024

Thanks for the report! That's already fixed in google/turbine@468742f, I'm working on releasing a new version and updating Bazel's dependency on turbine.

@hvadehra hvadehra added P2 We'll consider working on this in future. (Assignee optional) next_month Issues that we will review next month. This is currently mainly used by Configurability team and removed untriaged labels Apr 29, 2024
@hvadehra
Copy link
Member

hvadehra commented May 8, 2024

Turbine got released and updated in 81117aa

Can we close this, or is there something else we need to wait for?

@fmeum
Copy link
Collaborator Author

fmeum commented May 8, 2024

@hvadehra I think that we need to have a new java_tools and rules_java release + bump in bazel_tools dependencies for this to be considered "done".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next_month Issues that we will review next month. This is currently mainly used by Configurability team P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug
Projects
None yet
Development

No branches or pull requests

6 participants