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

Can not find symbol RulesJni #98

Open
liuyangc3 opened this issue Mar 3, 2023 · 0 comments
Open

Can not find symbol RulesJni #98

liuyangc3 opened this issue Mar 3, 2023 · 0 comments

Comments

@liuyangc3
Copy link

I followed the document, but can not build with jni

bazelisk build //:FuzzerWithNative
INFO: Analyzed target //:FuzzerWithNative (1 packages loaded, 2 targets configured).
INFO: Found 1 target...
ERROR: /server/jazzer_test/fuzzing/BUILD:17:12: Building FuzzerWithNative.jar (1 source file) failed: (Exit 1): java failed: error executing command (from target //:FuzzerWithNative) external/remotejdk11_linux/bin/java -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 16 arguments skipped)
src/main/java/com/example/jazzer/FuzzerWithNative.java:4: error: package com.github.fmeum.rules_jni does not exist
import com.github.fmeum.rules_jni.RulesJni;
                                 ^
src/main/java/com/example/jazzer/FuzzerWithNative.java:10: error: cannot find symbol
    RulesJni.loadLibrary(native_lib, ExampleFuzzerWithNative.class);
                                     ^
  symbol:   class ExampleFuzzerWithNative
  location: class FuzzerWithNative
src/main/java/com/example/jazzer/FuzzerWithNative.java:10: error: cannot find symbol
    RulesJni.loadLibrary(native_lib, ExampleFuzzerWithNative.class);
    ^
  symbol:   variable RulesJni
  location: class FuzzerWithNative
Target //:FuzzerWithNative failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.196s, Critical Path: 0.12s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

src/main/java/com/example/jazzer/FuzzerWithNative.java

package com.example.jazzer;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.github.fmeum.rules_jni.RulesJni;


public class FuzzerWithNative {
  static {
    String native_lib = System.getenv("EXAMPLE_NATIVE_LIB");
    RulesJni.loadLibrary(native_lib, ExampleFuzzerWithNative.class);
  }

  public static void fuzzerTestOneInput(FuzzedDataProvider data) {
    System.out.print("FuzzerWithNative");
  }
}

BUILD

java_binary(
    name = "FuzzerWithNative",
    srcs = glob(["src/main/java/com/example/jazzer/FuzzerWithNative.java"]),
    main_class = "com.example.jazzer.FuzzerWithNative",
    deps = [
        "@maven//:com_code_intelligence_jazzer", # use query "@maven//:*" see all packages
        "@maven//:com_code_intelligence_jazzer_api",
    ]
)

WORKSPACE

# fmeum_rules_jni
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "fmeum_rules_jni",
    sha256 = "9a387a066f683a8aac4d165917dc7fe15ec2a20931894a97e153a9caab6123ca",
    strip_prefix = "rules_jni-0.4.0",
    url = "https://github.com/fmeum/rules_jni/archive/refs/tags/v0.4.0.tar.gz",
)

load("@fmeum_rules_jni//jni:repositories.bzl", "rules_jni_dependencies")

rules_jni_dependencies()


# maven packages
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "4.5"
RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"

http_archive(
    name = "rules_jvm_external",
    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
    sha256 = RULES_JVM_EXTERNAL_SHA,
    url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
    artifacts = [
        "com.code-intelligence:jazzer:0.15.0",
    ],
    repositories = [
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
    ],
)
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

1 participant