2

I am using a Java 10 API in my source code, when I try to compiler this code with maven and idea, it throws an error:

// I use this Java 10 API
URLDecoder.decode(query, StandardCharsets.UTF_8)
// throw this error
Error:(10, 73) java: incompatible types: java.nio.charset.Charset cannot be converted to java.lang.String

My Env:

  • JDK 10

  • maven: 3.6

  • IDEA

I was fine if I remove this API.

And I do follow things:

  1. add compiler option to pom
 <maven.compiler.target>10</maven.compiler.target>
 <maven.compiler.source>10</maven.compiler.source>
  1. change IDEA language level to java10

    File -> Project Struct -> Module -> Language Level

Above two do not work.

Community
  • 1
  • 1
Shuai Li
  • 2,426
  • 4
  • 24
  • 43

1 Answers1

2

I've created a sample project according to your description and cannot reproduce the problem.

It compiles without errors in both IntelliJ IDEA and in the command line Maven.

If the issue is still reproducible for you, please contact support with the Minimal, Complete, and Verifiable example attached and also specify your IntelliJ IDEA version.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • somehow it works for me on local as well but fails in a pipeline environment – fireball.1 Apr 26 '21 at 06:37
  • @fireball.1 : I had the same issue - you might not have the same JDK locally. I used https://hub.docker.com/_/maven to run maven locally in the same version as used in GitHub Actions. https://github.com/nektos/act is your friend if you want to test GitHub Actions locally. – bmoers Apr 26 '21 at 20:35