Skip to content

How to pass command line parameters to the java compiler #2304

Closed

Description

@slPerryRhodan

In my project we use spring data with named parameter, which is running fine with IntelliJ, but in VSCode I get the following exception:

2022-01-28 11:01:15,170 |-ERROR in at.***.commons.exception.RestExceptionHandler - For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.; nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
org.springframework.dao.InvalidDataAccessApiUsageException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.; nested exception is java.lang.IllegalStateException: For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on Java 8+ use the javac flag -parameters.
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:371)
EntityManagerFactoryUtils.java:371
	...

In IntelliJ I can set "Additional command line parameters" under Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler. And this issue is solved, if I add "-parameters" as command line parameter in IntelliJ, but I have no clue how to do this in VSCode. I can only find information about passing vmarg parameters in VSCode.

Environment
  • Operating System: Win 10
  • JDK version: 11
  • Visual Studio Code version: 1.63.2
  • Java extension version: Language Support for Java(TM) by Red Hat v1.3.0
Steps To Reproduce

Use Spring Data with named parameters (Spring Docu Named Parameters) without the annotation @PARAM and the compiler flag
"-parameters" is not #set.

Current Result
  • Can run the applications until the the application tries to access via spring data the database and then it throws the mentioned exception
  • Run & Debug Tests (e.g. Integration / Karate tests) not possible because of the mentioned excetpion
Expected Result
  • pass java compiler flags like "-parameters" should be possible
Additional Informations

#2269

Activity

  1. rgrunber commented on Feb 8, 2022

    @rgrunber
    Member

    I'm not sure if this is possible currently for unmanaged projects under vscode-java. CC'ing @snjeza. There's a bunch of compiler options that can be set listed at https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences but I don't think this is there.

  2. snjeza commented on Feb 8, 2022

    @snjeza
    Collaborator

    Run & Debug Tests (e.g. Integration / Karate tests) not possible because of the mentioned excetpion

    @slPerryRhodan @rgrunber You may want to take a look at https://code.visualstudio.com/docs/java/java-debugging#_configuration-options

  3. chad-russell commented on Feb 11, 2022

    @chad-russell

    For those running into this in the future: I was able to solve it by adding this to my .prefs file (the one specified by the java.settings.url setting)

    org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
    
  4. rgrunber commented on Feb 11, 2022

    @rgrunber
    Member

    Good catch! That definitely looks like the right thing, and https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java#n2333 confirms it. So no need to use vscode-java-debug unless there's more customization that's needed. Closing this for now.

  5. slPerryRhodan commented on Feb 18, 2022

    @slPerryRhodan
    Author

    @snjeza I looked at it many times and it's not helpful.

    @chad-russell thanks, thats good. A bit (very) inconvenient to configure compared to eclipse and intelliJ, but at least it's possible.

  6. thiagoprazeres commented on Jan 4, 2023

    @thiagoprazeres

    Create file:
    .settings/org.eclipse.jdt.core.prefs
    Content:
    org.eclipse.jdt.core.compiler.codegen.methodParameters=generate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions