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: add proper lint task to CI #581

Merged
merged 3 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bindings/java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ SOURCE_DIR = $(realpath $(CURDIR)/../..)
OUT_DIR = $(CURDIR)/c/build
BUILD_DIR = $(OUT_DIR)/_cmake_build

lint: gradlew
./gradlew --no-daemon clean spotlessCheck

build: gradlew $(OUT_DIR)/lib/libevmc-java.so
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also make build depend on lint. And rename the gradlew task to gradle-setup. And reorder the file.

mkdir -p ./java/build
./gradlew --no-daemon clean spotlessApply build
Expand Down
18 changes: 9 additions & 9 deletions bindings/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ allprojects {
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
// This path needs to be relative to each project
target fileTree('.') {
include '**/*.java'
exclude '**/.gradle/**'
}
importOrder 'org.ethereum', 'java', ''
trimTrailingWhitespace()
endWithNewline()
googleJavaFormat('1.7')
// This path needs to be relative to each project
target fileTree('.') {
include '**/*.java'
exclude '**/.gradle/**'
}
importOrder 'org.ethereum', 'java', ''
trimTrailingWhitespace()
endWithNewline()
googleJavaFormat('1.7')
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package org.ethereum.evmc;

public class EvmcLoaderException extends Exception {
public EvmcLoaderException(String message) {
super(message);
}
public EvmcLoaderException(String message) {
super(message);
}
}
10 changes: 3 additions & 7 deletions bindings/java/java/src/main/java/org/ethereum/evmc/EvmcVm.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Licensed under the Apache License, Version 2.0.
package org.ethereum.evmc;

import org.ethereum.evmc.EvmcLoaderException;

import java.nio.ByteBuffer;
import java.util.Objects;

Expand All @@ -21,7 +19,7 @@ public final class EvmcVm implements AutoCloseable {
* This method loads the specified evm shared library and loads/initializes the jni bindings.
*
* @param filename /path/filename of the evm shared object
* @throws EvmcLoaderException
* @throws org.ethereum.evmc.EvmcLoaderException
*/
public static EvmcVm create(String filename) throws EvmcLoaderException {
if (!EvmcVm.isEvmcLibraryLoaded) {
Expand Down Expand Up @@ -49,7 +47,7 @@ private EvmcVm(String filename) throws EvmcLoaderException {
*
* @param Path to the dynamic object representing the EVM implementation.
* @return Internal object pointer.
* @throws EvmcLoaderException
* @throws org.ethereum.evmc.EvmcLoaderException
*/
private static native ByteBuffer load_and_create(String filename) throws EvmcLoaderException;

Expand Down Expand Up @@ -152,9 +150,7 @@ public int set_option(String name, String value) {
/** get size of result struct */
private static native int get_result_size();

/**
* This method cleans up resources.
*/
/** This method cleans up resources. */
@Override
public void close() {
destroy(nativeVm);
Expand Down
10 changes: 3 additions & 7 deletions bindings/java/java/src/main/java/org/ethereum/evmc/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
// Licensed under the Apache License, Version 2.0.
package org.ethereum.evmc;

import static java.util.Objects.requireNonNull;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* The Host interface.
*
* <p>The set of all callback functions expected by VM instances.
*/
final class Host {
static private ByteBuffer ensureDirectBuffer(ByteBuffer input) {
private static ByteBuffer ensureDirectBuffer(ByteBuffer input) {
// Reallocate if needed.
if (!input.isDirect())
if (!input.isDirect()) {
return ByteBuffer.allocateDirect(input.remaining()).put(input);
}
return input;
}

Expand Down
9 changes: 5 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,15 @@ jobs:
- checkout
- build
- test
- run:
name: "Java Lint (spotlessCheck)"
command: cd bindings/java && make lint
- run:
name: "Java Build"
command: |
cd bindings/java && make clean build
command: cd bindings/java && make clean build
- run:
name: "Java Test"
command: |
cd bindings/java && make test
command: cd bindings/java && make test
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove these whitespaces changes.


bindings-rust:
docker:
Expand Down