Skip to content

Java version mismatch between JRE_CONTAINER and targetPlatform in M2E 2.0.0 #842

@CsCherrYY

Description

@CsCherrYY

steps to reproduce:

  1. given sample project: https://github.com/mybatis/mybatis-3.git
  2. open it in VS Code, with redhat.java extension 1.8.0 installed (which integrates m2e 2.0.0 snapshot).
  3. after project imported, VS Code reports an error in Item record under package org.apache.ibatis.submitted.record_type.

java.lang.Record cannot be resolved to a type.

as we know, record should be available in Java 16 but not in Java 8.

  1. check the generated .classpath file, the JRE_CONTAINER is set to JavaSE-1.8 VM.

classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"

  1. check the generated .settings/org.eclipse.jdt.prefs file, the target platform is set to Java 16 (which would be the expect source level since it's defined in https://github.com/mybatis/mybatis-3/blob/9da3467e96a03e8bd6e040139581a22ce5297c29/pom.xml#L449-L459)

org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
org.eclipse.jdt.core.compiler.compliance=16
org.eclipse.jdt.core.compiler.source=16

if we rollback to redhat.java 1.6.0, which uses m2e 1.18.2, this issue disappears. The JRE_CONTAINER in .classpath file is JavaSE-16, and the value of pref org.eclipse.jdt.core.compiler.codegen.targetPlatform is also 16.

I think this issue might related to #597 which introduces a new limitation from maven-enforcer-plugin. But I'm not sure it's caused by the plugin or m2e itself. When debugging, the two environments seem to mismatch:
image

cc: @fbricon @rgrunber

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions