Skip to content

Adding wrong jar version to the classpath #566

Closed
microsoft/java-debug
#281

Description

@dampcake

The correct version of the JAR shows up Java Dependencies Pane but when executed a different version is added to the -cp arguments.

Environment
  • Operating System: OSX
  • JDK version: 1.8.0_201
  • Visual Studio Code version: 1.33.1
  • Java extension version: 0.42.1
  • Java Debugger extension version: 0.17.0
Steps To Reproduce

Sample: https://github.com/dampcake/incubator-druid/tree/fix-eclipse
run mvn install -Pdist -DskipTests to generate dependencies.

Language Server Returning the wrong JAR

Config for project can be found in gist. Either way jetty-util should be 9.4.10 as shown in the dependency view.

Current Result

Wrong JAR dependency version is added to the classpath.

Expected Result

Correct JAR dependency version is added to the classpath.

Additional Informations

This project runs correctly in eclipse so I am not sure where the error is as the dependency view shows the correct JAR.

Activity

  1. yaohaizh commented on Apr 16, 2019

    @yaohaizh
    Contributor

    Jinbo Wang (@testforstephen) Could you help take a look at this issue?

  2. testforstephen commented on Apr 17, 2019

    @testforstephen
    Contributor

    i can reproduce the issue, should be a bug.

  3. yaohaizh commented on Apr 18, 2019

    @yaohaizh
    Contributor

    Sheng Chen (@jdneo) Is this the same issue that tester fixed?

  4. rcl4444 commented on May 12, 2019

    @rcl4444
    • Operating System: Windows_NT x64 10.0.18362
    • JDK version: 1.8.0_181-1-redhat
    • Visual Studio Code version: 1.33.1
    • Java extension version: 0.7.1
    • Java Debugger extension version: 0.18.0

    I also encountered this problem.

  5. rcl4444 commented on May 12, 2019

    @rcl4444

    in My situation, the Different versions exist simultaneously in the -cp arguments..

  6. testforstephen commented on Jun 14, 2019

    @testforstephen
    Contributor

    Dependency mediation - this determines what version of an artifact will be chosen when multiple versions are encountered as dependencies. Maven picks the "nearest definition". That is, it uses the version of the closest dependency to your project in the tree of dependencies. You can always guarantee a version by declaring it explicitly in your project's POM. Note that if two dependency versions are at the same depth in the dependency tree, the first declaration wins.
    "nearest definition" means that the version used will be the closest one to your project in the tree of dependencies. For example, if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0.

    When there are multiple versions for the same dependency existed in the dependency tree, maven will use BFS algorithm to use the nearest version as the target one.

    Currently, java-debug used DFS algorithm to determine the dependency, that's the reason why the wrong JAR is added to the classpath. We will take advantage of the same mechanism as what maven did.

  7. testforstephen commented on Jul 2, 2019

    @testforstephen
    Contributor

    A new release is ready in vscode marketplace. Have a try!

    //Adam Peck (@dampcake) rcl4444

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions