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

[javac] some differences ecj <-> javac regarding 'recent' features #2959

Open
stephan-herrmann opened this issue Sep 15, 2024 · 4 comments
Open
Assignees
Labels
test Work on unit tests, no change of productive code

Comments

@stephan-herrmann
Copy link
Contributor

While taking stock of run.javac test results regarding Java 23 I observed the following differences which might be within reach for resolution:

  • PrimitiveInPatternsTestSH
  • MarkdownCommentTest:
    • 1 error, javac not complaining about unresolvable @see reference
  • ModuleCompilationTests
    • 4 errors
  • PatternMatching16Test -- is this a structural problem?
    • 83 failures, obviously not suitable for running back-to-back with javac23
    • 67 errors vs javac16
  • RecordPatternTest 3 errors, javac-generated code throws ArithmeticException instead of expected MatchException (see comments in tests):
    • testGH1977_instance_field()
    • testGH1977_static_field()
    • testIssue1985_2()
  • SwitchExpressionsYieldTest
    • currently 175 failures, many of which due to ill-configured javac invocation
    • remaining: 17 failures
  • SwitchPatternTest: 5 errors (some related to wrongly configured --enable-preview, others not yet analysed)
  • SwitchPatternTest21: 2 errors
    * testInternalDomination_this() (ecj no error, javac 2 errors)
    * testNaming() // javac jdk21 allows components to be named, but they can't be referenced
@stephan-herrmann stephan-herrmann self-assigned this Sep 15, 2024
stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.core that referenced this issue Sep 15, 2024
+ fix arguments of javac invocations
+ remove a forgotten test filter

relates to eclipse-jdt#2959
@stephan-herrmann stephan-herrmann added the test Work on unit tests, no change of productive code label Sep 15, 2024
stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.core that referenced this issue Sep 24, 2024
+ fix arguments of javac invocations
+ remove a forgotten test filter

relates to eclipse-jdt#2959
stephan-herrmann added a commit that referenced this issue Sep 24, 2024
…2960)

+ fix arguments of javac invocations
+ remove a forgotten test filter

relates to #2959
@stephan-herrmann
Copy link
Contributor Author

SwitchPatternTest21: 2 errors

  • testInternalDomination_this() (ecj no error, javac 2 errors)
  • testNaming() // javac jdk21 allows components to be named, but they can't be referenced

The class has been renamed to SwitchPatternTest22.

@srikanth-sankaran are those differences of interest for your current work?

testInternalDomination_this()

  • javac reports errors, that are not (yet?) detected by ecj:
X.java:5: error: this case label is dominated by a preceding case label
      case Object _, Integer _, X _ when o != null : System.out.println("Integer");
                     ^
X.java:5: error: this case label is dominated by a preceding case label
      case Object _, Integer _, X _ when o != null : System.out.println("Integer");
                                ^
2 errors

testNaming():

  • javac does not report the expected error, but only a warning:
X.java:6: warning: [fallthrough] possible fall-through into case
      default: System.out.println("Object");
      ^
1 warning

Test case has this comment "javac jdk21 allows components to be named, but they can't be referenced".

When those are clarified, we can accept this test class into the paradise of successful run.javac comparison :)

@stephan-herrmann
Copy link
Contributor Author

After #3218 also SwitchPatternTest is on the home stretch with just three test cases where javac reports errors which ecj doesn't see:

And then the errors from #3009 look similar:

X.java:26: error: illegal start of type
		case W<Short>.NG.I<Integer>.S<Long, Integer, X> e -> 42;
		                                                ^
1 error

@stephan-herrmann
Copy link
Contributor Author

After first successful builds I have set https://ci.eclipse.org/jdt/job/eclipse.jdt.core-run.javac-23/ to run weekly (on weekends)

Currently these test classes have opted in:

  • ImplicitlyDeclaredClassesTest
  • ModuleImportTests
  • PrimitivePatternTest
  • PrimitivePatternTestSH
  • SealedTypesTest
  • SuperAfterStatementsTest

More classes will be admitted once they are green in run.javac mode.

@srikanth-sankaran
Copy link
Contributor

More classes will be admitted once they are green in run.javac mode.

Thanks a lot for doing this!

In my first innings as well, I never seem to have paid close attention (scratch that, any attention) to this capability. In fact I seem to have invented a completely new mechanism that is a lot less sophisticated, see org.eclipse.jdt.core.tests.compiler.parser.AbstractSyntaxTreeTest.CHECK_JAVAC_PARSER

This is useful and I can participate in contributing and maintaining this in 2025 - after my reviews of Java 10-23 are over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Work on unit tests, no change of productive code
Projects
None yet
Development

No branches or pull requests

2 participants