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

"java.lang.VerifyError: Bad type on operand stack" on switch case with Java 17 #95

Closed
keiki85 opened this issue Nov 10, 2021 · 4 comments
Labels
JDT Core Eclipse Java Development Tools (AspectJ fork) upstream-bug
Milestone

Comments

@keiki85
Copy link

keiki85 commented Nov 10, 2021

Hello,

I hope I'm in the right project as I am not that familiar of aspectj and its structure.

I do not know how the relation to eclipse JDT compiler is. There is a bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=576093 which is stopping me from upgrading to Java 17.
It's the same error. Maybe you already got the bugfix in place.
I hope to see a RC2 or final version soon which has that fixed.

Thank you very much.

@kriegaex
Copy link
Contributor

Thanks for the information. I can confirm this problem in AspectJ 1.9.8.RC1.

I do not know how the relation to eclipse JDT compiler is.

The AspectJ Compiler AJC is a regularly refreshed fork of the Eclipse Java Compiler ECJ, the latter being part of JDT Core. So this is simply an upstream error. Last time I merged the Java 17 support which was published for Eclipse 4.21 (2021-09), i.e. the current release. Therefore, it is no surprise that the same problem exists in AspectJ.

kriegaex added a commit to kriegaex/aspectj that referenced this issue Nov 10, 2021
Fixes JDT Core bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=576093
and related AspectJ issue eclipse-aspectj#95.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
@kriegaex
Copy link
Contributor

I just released 1.9.8.RC2, it is already on Maven Central. Try this. There should be no more verify errors when running the program from the console or from your IDE (I tried in IntelliJ IDEA, auto-importing the Maven project):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
  <artifactId>AJ_Issue_GH95</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <aspectj.version>1.9.8.RC2</aspectj.version>
  </properties>

  <build>

    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <!-- IMPORTANT -->
          <useIncrementalCompilation>false</useIncrementalCompilation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>dev.aspectj</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.13.1</version>
        <configuration>
          <!--<showWeaveInfo>true</showWeaveInfo>-->
          <complianceLevel>${maven.compiler.target}</complianceLevel>
          <Xlint>ignore</Xlint>
          <encoding>${project.build.sourceEncoding}</encoding>
          <!--<verbose>true</verbose>-->
          <!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn>-->
        </configuration>
        <executions>
          <execution>
            <!-- IMPORTANT -->
            <phase>process-sources</phase>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>${aspectj.version}</version>
          </dependency>
        </dependencies>
      </plugin>

    </plugins>

  </build>

  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>${aspectj.version}</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

</project>
package verifyerror;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class X {

  private static final Map<Z, Object> map = new HashMap<>();

  public static void main(String[] args) {
    crashNow();
  }

  static void crashNow() {
    for (Entry<Z, Object> entry : map.entrySet()) {
      switch (entry.getKey()) {
        case A:
          continue;
        default:
          break;
      }
    }
    System.out.println("No crash if you see this");
  }

}

enum Z {
  A, B
}

@kriegaex
Copy link
Contributor

@aclement, I think after merging the two PRs for JDT Core and AspectJ this issue can be closed, if there is positive feedback from @keiki85.

@kriegaex kriegaex mentioned this issue Nov 10, 2021
@keiki85
Copy link
Author

keiki85 commented Nov 11, 2021

Thank you very much for the fast reponse.

The bug was fixed with the update to RC2.

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JDT Core Eclipse Java Development Tools (AspectJ fork) upstream-bug
Projects
None yet
Development

No branches or pull requests

2 participants