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

COMPILATION ERROR #4

Closed
Albert-Gong opened this issue Oct 25, 2022 · 2 comments
Closed

COMPILATION ERROR #4

Albert-Gong opened this issue Oct 25, 2022 · 2 comments

Comments

@Albert-Gong
Copy link

Hi,
I am trying to run mBERT on my machine but here comes an error,

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] ***/MuBERT/src/main/java/mutation/CodeBERTMutation.java:[81,64] cannot find symbol
  symbol:   method of(java.lang.String)
  location: interface java.nio.file.Path
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.776 s
[INFO] Finished at: 2022-10-25T09:42:43+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mBERT: Compilation failure
[ERROR] ***/MuBERT/src/main/java/mutation/CodeBERTMutation.java:[81,64] cannot find symbol
[ERROR]   symbol:   method of(java.lang.String)
[ERROR]   location: interface java.nio.file.Path

my mvn and java version,

Maven home: /usr/local/apache-maven-3.8.6
Java version: 1.8.0_341, vendor: Oracle Corporation, runtime: /usr/local/java/jdk8/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-76-generic", arch: "amd64", family: "unix"

Thanks,
Albert

@rdegiovanni
Copy link
Owner

Dear Albert,
Thank you very much for your interest in our tool.

The simplest option to solve your compilation issue is to update your Java version to 11 or later.
Notice that in line 81 we use Files.readString(...) and Path.of(...) that were included since Java 11.

If you have to attach to Java 8, I can provide you with a workaround that I'll need to test it a bit more to include it in the release.
You can replace line 81 by the following lines:

Path path = FileSystems.getDefault().getPath(sourceCodeToBeMutated);
 byte[] encoded = Files.readAllBytes(path);
 String originalClassStr = new String(encoded, StandardCharsets.UTF_8);

and you will need to import:

import java.nio.file.FileSystems;
import java.nio.charset.StandardCharsets;

Notice that in line 81 we only read the source code into a string, so you can use any other option that you consider appropriate.

Please, let me you know if you could solve your issue.

Best,
Renzo

@Albert-Gong
Copy link
Author

Albert-Gong commented Oct 26, 2022

Dear Renzo,

Thanks for your help, I can run the tool now, with some source code replaced.

Best,
Albert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants