Skip to content

Commit

Permalink
Merge pull request #581 from ethereum/java-lint
Browse files Browse the repository at this point in the history
java: add proper lint task to CI
  • Loading branch information
chfast authored Mar 23, 2021
2 parents 4b4b95c + 8d7e3fb commit 77122cf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
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
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

bindings-rust:
docker:
Expand Down

0 comments on commit 77122cf

Please sign in to comment.