Skip to content

Commit

Permalink
Merge pull request #306 from JarvisCraft/1.0.0-rc.8
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvisCraft authored Dec 21, 2021
2 parents 118c89e + dafaa12 commit b7babc8
Show file tree
Hide file tree
Showing 68 changed files with 1,561 additions and 1,225 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CodeQL

on:
push:
branches: [ master, development ]
pull_request:
branches: [ master, development ]
schedule:
- cron: '00 12 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

steps:
- uses: actions/[email protected]

- name: Set up Java 17
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'

- name: Initialize CodeQL
uses: github/codeql-action/[email protected]
with:
languages: java

- name: Autobuild
uses: github/codeql-action/[email protected]

- name: Perform CodeQL Analysis
uses: github/codeql-action/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/[email protected]

- name: Set up Java 17 & Deployment credentials
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '17'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/[email protected]

- name: Set up Java 17 & Deployment credentials
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '17'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/[email protected]

- name: Set up Java 17
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '17'
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/[email protected]

- name: Set up Java 17
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '17'
Expand Down
18 changes: 18 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Security Policy

## Supported Versions

| Version | Supported |
| ------------ | ------------------ |
| [1.0.0-rc.7] | :heavy_check_mark: |
| < 1.0.0-rc.7 | :x: |

## Reporting a Vulnerability

In order to report a vulnerability simply create an [issues](https://github.com/JarvisCraft/padla/issues) for it.

These are checked regularly and are the primary support channel.

<!-- Version links -->

[1.0.0-rc.7]: https://mvnrepository.com/artifact/ru.progrm-jarvis/padla/1.0.0-rc.7
2 changes: 1 addition & 1 deletion java-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ru.progrm-jarvis</groupId>
<artifactId>padla</artifactId>
<version>1.0.0-rc.7</version>
<version>1.0.0-rc.8</version>
</parent>
<artifactId>java-commons</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
/**
* Marker indicating that {@link Object#equals(Object)} and {@link Object#hashCode()} methods
* are not overridden for this class for some reason.
*
* @deprecated this annotation is applicable by default thus it is redundant
*/
@Deprecated
@Inherited
@Documented
@Target(ElementType.TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.progrm_jarvis.javacommons.util.BlackHole;

/**
* Utilities for creation of <a href="https://github.com/ben-manes/caffeine">Caffeine</a>-based
Expand All @@ -19,16 +18,16 @@ public class CaffeineCache {
/**
* Flag indicating whether {@link Caffeine} is available
*/
private static final boolean AVAILABLE;
private final @Nullable CacheFactory CACHE_FACTORY;

static {
boolean available = true;
try { // check if Caffeine class is available
BlackHole.consume(Caffeine.class);
CacheFactory cacheFactory;
try { // check if Caffeine is available
cacheFactory = new CaffeineCacheFactory(Caffeine::newBuilder);
} catch (final Throwable ignored) {
available = false;
cacheFactory = null;
}
AVAILABLE = available;
CACHE_FACTORY = cacheFactory;
}

/**
Expand All @@ -38,19 +37,19 @@ public class CaffeineCache {
*
* @throws IllegalStateException if Caffeine is not available
*/
public static @NotNull CacheFactory createFactory() {
if (AVAILABLE) return CaffeineCacheFactory.INSTANCE;
public @NotNull CacheFactory createFactory() {
if (CACHE_FACTORY == null) throw new IllegalStateException("Caffeine Cache is not available");

throw new IllegalStateException("Caffeine Cache is not available");
return CACHE_FACTORY;
}

/**
* Attempts to create a Caffeine Cache factory.
*
* @return created Caffeine Cache factory or {@code null} if it is unavailable
*/
public static @Nullable CacheFactory tryCreateFactory() {
return AVAILABLE ? CaffeineCacheFactory.INSTANCE : null;
public @Nullable CacheFactory tryCreateFactory() {
return CACHE_FACTORY;
}

/**
Expand All @@ -61,9 +60,9 @@ public class CaffeineCache {
private static final class CaffeineCacheFactory implements CacheFactory {

/**
* Singleton instance of this {@link CacheFactory} implementation
* Factory used for creation of {@link Caffeine} builder
*/
private static final @NotNull CacheFactory INSTANCE = new CaffeineCacheFactory();
private @NotNull CaffeineBuilderFactory factory;

/**
* Wraps the provided {@link com.github.benmanes.caffeine.cache.Cache Caffeine Cache} into {@link Cache}.
Expand All @@ -81,17 +80,30 @@ private static final class CaffeineCacheFactory implements CacheFactory {

@Override
public <K, V> @NotNull Cache<K, V> weakKeysCache() {
return wrap(Caffeine.newBuilder().weakKeys().build());
return wrap(factory.newBuilder().weakKeys().build());
}

@Override
public <K, V> @NotNull Cache<K, V> weakValuesCache() {
return wrap(Caffeine.newBuilder().weakValues().build());
return wrap(factory.newBuilder().weakValues().build());
}

@Override
public <K, V> @NotNull Cache<K, V> softValuesCache() {
return wrap(Caffeine.newBuilder().softValues().build());
return wrap(factory.newBuilder().softValues().build());
}

/**
* Factory responsible for creation of {@link Caffeine} builder.
*/
public interface CaffeineBuilderFactory {

/**
* Creates a {@link Caffeine} builder.
*
* @return Caffeine builder
*/
Caffeine<Object, Object> newBuilder();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import java.util.List;
import java.util.Map;

/**
* Object used for runtime class definition.
*/
public interface ClassDefiner {

/**Uns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public class CollectionFactory {
/**
* {@link Lookup lookup} of this class.
*/
private static final Lookup LOOKUP = MethodHandles.lookup();
private final Lookup LOOKUP = MethodHandles.lookup();

/**
* Class naming strategy used to allocate names for generated immutable enum set classes
*/
private static final @NonNull ClassNamingStrategy IMMUTABLE_ENUM_SET_CLASS_NAMING_STRATEGY = ClassNamingStrategy
private final @NonNull ClassNamingStrategy IMMUTABLE_ENUM_SET_CLASS_NAMING_STRATEGY = ClassNamingStrategy
.createPaginated(CollectionFactory.class.getName() + "$$Generated$$ImmutableEnumSet$$");

/**
Expand All @@ -57,18 +57,18 @@ public class CollectionFactory {
/**
* {@link CtClass} representation of {@link AbstractImmutableSet} wrapped in {@link Lazy}
*/
private static final @NonNull Lazy<CtClass> ABSTRACT_IMMUTABLE_SET_CT_CLASS = Lazy
private final @NonNull Lazy<CtClass> ABSTRACT_IMMUTABLE_SET_CT_CLASS = Lazy
.createThreadSafe(() -> toCtClass(AbstractImmutableSet.class));
/**
* Array storing single reference to {@link CtClass} representation of {@link Iterator} wrapped in {@link Lazy}
*/
private static final @NonNull Lazy<CtClass[]> ITERATOR_CT_CLASS_ARRAY = Lazy
private final @NonNull Lazy<CtClass[]> ITERATOR_CT_CLASS_ARRAY = Lazy
.createThreadSafe(() -> new CtClass[]{toCtClass(Iterator.class)});

/**
* Empty array of {@link CtClass}es.
*/
public static final @NotNull CtClass @NotNull @Unmodifiable [] EMPTY_CT_CLASS_ARRAY = new CtClass[0];
public final @NotNull CtClass @NotNull @Unmodifiable [] EMPTY_CT_CLASS_ARRAY = new CtClass[0];

/**
* Creates an immutable enum {@link Set set} from the given array of stored enum constants.
Expand All @@ -83,7 +83,7 @@ public class CollectionFactory {
* instanceof} and {@code switch} by {@link Enum#ordinal()} are used for containment-related checks and {@link}
*/
@SafeVarargs
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "varargs"})
@Deprecated // should be remade via ASM or totally removed due to specific behaviour of anonymous class referencing
@UsesBytecodeModification(value = CommonBytecodeLibrary.JAVASSIST, optional = true)
public <E extends Enum<E>> Set<E> createImmutableEnumSet(final @NonNull E... values) {
Expand All @@ -97,7 +97,6 @@ public <E extends Enum<E>> Set<E> createImmutableEnumSet(final @NonNull E... val
.sorted()
.toArray(Enum[]::new);

//noinspection unchecked
return (Set<E>) IMMUTABLE_ENUM_SETS.get(enumValues, valuesArray -> {
//<editor-fold desc="Class generation" defaultstate="collapsed">
val enumType = valuesArray.getClass().getComponentType();
Expand Down
Loading

0 comments on commit b7babc8

Please sign in to comment.