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

Java: Location.getFile().getAbsolutePath() contains Windows drive letter for non-source classes #5712

Open
Marcono1234 opened this issue Apr 19, 2021 · 0 comments
Labels
Java question Further information is requested

Comments

@Marcono1234
Copy link
Contributor

Marcono1234 commented Apr 19, 2021

Version

CodeQL CLI version 2.5.0

Description

For types which are not part of the source, Location.getFile().getAbsolutePath() returns a path which contains the Windows drive letter.
For tests which have the path (as part of the URL) in their expected output this therefore results in test failures on Windows.
For example if I run on Windows the test added by #5711 it fails due to the file URL mismatch.

However, it looks like there are no existing tests in this repository with non-source types in their exepcted output, and CodeQL CLI explicitly warns about this:

Locations outside the test directory do not work well for regression tests.

Though it is still rather weird why the Windows drive letter is included in the first place.

Example

Code QL query:

import java

from TypeObject t
select t, t.getLocation().getFile().getAbsolutePath()

Under Windows with the database being under C:\... the result is: C:/modules/java.base/java/lang/Object.class
Under Linux the result is: /modules/java.base/java/lang/Object.class

(Note: For some demo projects the path is /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar/java/lang/Object.class (Query Console link); I am not sure on what this depends and whether this could cause issues for other users as well)

@Marcono1234 Marcono1234 added the question Further information is requested label Apr 19, 2021
@hmakholm hmakholm added the Java label Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants