Skip to content

Commit

Permalink
Change minimal required JDK from 1.6 to 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
valfirst committed Jan 28, 2022
1 parent bebf42b commit d4112c9
Show file tree
Hide file tree
Showing 433 changed files with 2,385 additions and 2,570 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ jobs:
# ciPerformRelease must run only when the entire build has completed
# This guarantees that no release steps are executed when the build or tests fail
run: |
./gradlew assemble --stacktrace -PcheckJava6Compatibility \
./gradlew assemble --stacktrace \
&& ./gradlew -i --stacktrace check \
&& ./gradlew -i ciPerformRelease
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ buildscript {
classpath 'net.researchgate:gradle-release:2.4.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'org.shipkit:shipkit:2.3.5'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.4'
}
}

Expand All @@ -35,7 +34,7 @@ ext{
servletVersion = "2.5"
jacocoVersion = "0.7.7.201606060606"
eclipseJdt = "3.3.0-v_771"
checkstyleVersion= "7.6.1"
checkstyleVersion = "9.2.1"
systemRulesVersion="1.18.0"
}

Expand Down
16 changes: 11 additions & 5 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="UniqueProperties"/>
Expand Down Expand Up @@ -48,7 +48,6 @@
<module name="ThrowsCount"/>
<module name="AnnotationLocation">
<property name="allowSamelineMultipleAnnotations" value="true"/>
<property name="tokens" value="IMPLEMENTS_CLAUSE, INTERFACE_DEF, TYPECAST, PARAMETER_DEF, CTOR_DEF, VARIABLE_DEF, LITERAL_NEW, ANNOTATION_FIELD_DEF, LITERAL_THROWS, ENUM_DEF, ANNOTATION_DEF, CLASS_DEF, DOT, TYPE_ARGUMENT"/>
</module>
<module name="AnonInnerLength">
<property name="max" value="60"/>
Expand All @@ -65,7 +64,7 @@
</module>
<module name="NeedBraces">
<property name="allowSingleLineStatement" value="true"/>
<property name="tokens" value="LITERAL_DO, LITERAL_WHILE, LAMBDA"/>
<property name="tokens" value="LITERAL_DO, LITERAL_WHILE"/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowIfAllCharactersEscaped" value="true"/>
Expand Down Expand Up @@ -96,7 +95,7 @@
<property name="tokens" value="METHOD_DEF, PARAMETER_DEF"/>
</module>
<module name="IllegalToken">
<property name="tokens" value="EOF, STAR_ASSIGN, DIV_ASSIGN, RESOURCES, MOD_ASSIGN, BSR_ASSIGN, TYPE_EXTENSION_AND, RESOURCE_SPECIFICATION, UNARY_PLUS, METHOD_REF, SL_ASSIGN, STRICTFP, RESOURCE, DOUBLE_COLON"/>
<property name="tokens" value="STAR_ASSIGN, DIV_ASSIGN, MOD_ASSIGN, BSR_ASSIGN, TYPE_EXTENSION_AND, UNARY_PLUS, SL_ASSIGN, STRICTFP, DOUBLE_COLON"/>
</module>
<module name="ParameterNumber">
<property name="max" value="8"/>
Expand Down Expand Up @@ -140,7 +139,11 @@
<property name="applyToPublic" value="false"/>
</module>
<module name="ImportOrder">
<property name="ordered" value="false"/>
<property name="groups" value="org,/(java\.|javax\.)/,*"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="bottom"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<module name="SuperClone"/>
<module name="MethodName">
Expand All @@ -160,4 +163,7 @@
<property name="tokens" value="STAR, BOR_ASSIGN, STAR_ASSIGN, MINUS_ASSIGN, BOR, EQUAL, BAND_ASSIGN, DIV_ASSIGN, DIV, MINUS, LAND, BXOR, QUESTION, LE, BSR, LT, COLON, GT, SL, BAND, GE, NOT_EQUAL, LITERAL_INSTANCEOF, MOD_ASSIGN, SR_ASSIGN, SR, TYPE_EXTENSION_AND, METHOD_REF, SL_ASSIGN, PLUS_ASSIGN, BXOR_ASSIGN, BSR_ASSIGN, MOD"/>
</module>
</module>

<!-- Filter out Checkstyle warnings that have been suppressed with the @SuppressWarnings annotation -->
<module name="SuppressWarningsFilter"/>
</module>
14 changes: 6 additions & 8 deletions gradle/java-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'java'

targetCompatibility = 1.6
sourceCompatibility = 1.6
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8

tasks.withType(JavaCompile) {
options.warnings = false
}

if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
apply plugin: 'checkstyle'
checkstyle {
toolVersion = checkstyleVersion
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
apply plugin: 'checkstyle'
checkstyle {
toolVersion = checkstyleVersion
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}

test{
Expand Down
10 changes: 0 additions & 10 deletions gradle/modules.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ configure(genericModules) { project ->
}
}

if (project.hasProperty('checkJava6Compatibility') && !System.getenv("SKIP_RELEASE")) {
//if we're skipping release, let's also skip checking compatibility (faster builds)
configure(publishableModules) { project ->
project.apply plugin: 'ru.vyarus.animalsniffer'
project.dependencies {
signature 'org.codehaus.mojo.signature:java16:1.0@signature'
}
}
}

project(":powermock-reflect") {
description = "Various utilities for accessing internals of a class."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ private void initInjectMocksSupported() {
Class<?> clazz = Class.forName("org.easymock.EasyMockSupport");
clazz.getDeclaredMethod("injectMocks", Object.class);
injectMocksSupported = true;
} catch (NoSuchMethodException e) {
injectMocksSupported = false;
} catch (ClassNotFoundException e) {
} catch (NoSuchMethodException | ClassNotFoundException e) {
injectMocksSupported = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/
package org.powermock.api.easymock;

import net.sf.cglib.proxy.Enhancer;
import org.easymock.ConstructorArgs;
import org.easymock.EasyMock;
import org.easymock.IExpectationSetters;
import org.easymock.IMocksControl;
import org.easymock.internal.LastControl;
import org.easymock.internal.MockInvocationHandler;
import org.easymock.internal.MocksControl;
import org.powermock.api.easymock.internal.invocationcontrol.EasyMockMethodInvocationControl;
import org.powermock.api.easymock.internal.invocationcontrol.NewInvocationControlAssertionError;
import org.powermock.api.easymock.internal.invocationcontrol.EasyMockNewInvocationControl;
import org.powermock.api.easymock.internal.invocationcontrol.NewInvocationControlAssertionError;
import org.powermock.api.easymock.internal.mockstrategy.MockStrategy;
import org.powermock.api.easymock.internal.mockstrategy.impl.DefaultMockStrategy;
import org.powermock.api.easymock.internal.mockstrategy.impl.NiceMockStrategy;
Expand Down Expand Up @@ -58,6 +58,8 @@
import java.util.List;
import java.util.Set;

import net.sf.cglib.proxy.Enhancer;

/**
* PowerMock extends EasyMock functionality with several new features such as
* mocking static and private methods, mocking new instances and more. Use
Expand Down Expand Up @@ -616,7 +618,7 @@ public static synchronized void mockStaticPartialNice(Class<?> clazz, String...

static <T> T doMockSpecific(Class<T> type, MockStrategy mockStrategy, String[] methodNamesToMock,
ConstructorArgs constructorArgs, Class<?>... argumentTypes) {
List<Method> methods = new LinkedList<Method>();
List<Method> methods = new LinkedList<>();
for (String methodName : methodNamesToMock) {
methods.add(WhiteboxImpl.findMethodOrThrowException(type, methodName, argumentTypes));
}
Expand Down Expand Up @@ -1246,13 +1248,13 @@ public static synchronized <T> IExpectationSetters<T> expectPrivate(Object insta

/**
* This method just delegates to EasyMock class extensions
* {@link org.easymock.EasyMock#expectLastCall()} method.
* {@link EasyMock#expectLastCall()} method.
*
* @return The expectation setter.
* @see org.easymock.EasyMock#expectLastCall()
* @see EasyMock#expectLastCall()
*/
public static synchronized IExpectationSetters<Object> expectLastCall() {
return org.easymock.EasyMock.expectLastCall();
return EasyMock.expectLastCall();
}

/**
Expand Down Expand Up @@ -1375,7 +1377,7 @@ public static synchronized void reset(Object... mocks) {
* no handler registered for this object.
*/
try {
org.easymock.EasyMock.reset(mock);
EasyMock.reset(mock);
} catch (RuntimeException e) {
throw new RuntimeException(mock + " is not a mock object", e);
}
Expand Down Expand Up @@ -1441,7 +1443,7 @@ public static synchronized void replay(Object... mocks) {
* no handler registered for this object.
*/
try {
org.easymock.EasyMock.replay(mock);
EasyMock.replay(mock);
} catch (RuntimeException e) {
throw new RuntimeException(mock + " is not a mock object", e);
}
Expand Down Expand Up @@ -1483,7 +1485,7 @@ public static synchronized void verify(Object... objects) {
* handler registered for this object.
*/
try {
org.easymock.EasyMock.verify(mock);
EasyMock.verify(mock);
} catch (RuntimeException e) {
throw new RuntimeException(mock + " is not a mock object", e);
}
Expand Down Expand Up @@ -1645,7 +1647,7 @@ private static <T> IExpectationSetters<T> doExpectNew(Class<T> type, MockStrateg
if (newInvocationControl == null) {
InvocationSubstitute<T> mock = doMock(InvocationSubstitute.class, false, mockStrategy, null,
(Method[]) null);
newInvocationControl = new EasyMockNewInvocationControl<T>(mock, type);
newInvocationControl = new EasyMockNewInvocationControl<>(mock, type);
MockRepository.putNewInstanceControl(type, newInvocationControl);
MockRepository.addObjectsToAutomaticallyReplayAndVerify(WhiteboxImpl.getOriginalUnmockedType(type));
}
Expand Down Expand Up @@ -1924,12 +1926,7 @@ private static <T> T doMock(Class<T> type, boolean isStatic, MockStrategy mockSt
/*
* Clear the EasyMock state after the test method is executed.
*/
MockRepository.addAfterMethodRunner(new Runnable() {
@Override
public void run() {
LastControl.reportLastControl(null);
}
});
MockRepository.addAfterMethodRunner(() -> LastControl.reportLastControl(null));

IMocksControl control = mockStrategy.createMockControl(type);
MockRepository.addAfterMethodRunner(new EasyMockStateCleaner());
Expand All @@ -1943,8 +1940,8 @@ public void run() {
MockInvocationHandler h = new MockInvocationHandler((MocksControl) control);
final Set<Method> methodsToMock = toSet(methods);
if (isStatic) {
MockRepository.putStaticMethodInvocationControl(type, new EasyMockMethodInvocationControl<Object>(h,
methodsToMock, replica));
MockRepository.putStaticMethodInvocationControl(type,
new EasyMockMethodInvocationControl<>(h, methodsToMock, replica));
MockRepository.addObjectsToAutomaticallyReplayAndVerify(type);
return null;
} else {
Expand All @@ -1960,7 +1957,7 @@ public void run() {
}
}
MockRepository.putInstanceMethodInvocationControl(newInstance,
new EasyMockMethodInvocationControl<Object>(h, methodsToMock, replica));
new EasyMockMethodInvocationControl<>(h, methodsToMock, replica));
if (!(newInstance instanceof InvocationSubstitute<?>)) {
MockRepository.addObjectsToAutomaticallyReplayAndVerify(newInstance);
}
Expand All @@ -1972,8 +1969,8 @@ public void run() {
MockInvocationHandler h = new MockInvocationHandler((MocksControl) control);
final Set<Method> methodsToMock = toSet(methods);
if (isStatic) {
MockRepository.putStaticMethodInvocationControl(type, new EasyMockMethodInvocationControl<T>(h,
methodsToMock, mock));
MockRepository.putStaticMethodInvocationControl(type,
new EasyMockMethodInvocationControl<>(h, methodsToMock, mock));
MockRepository.addObjectsToAutomaticallyReplayAndVerify(type);
} else {
MockRepository.putInstanceMethodInvocationControl(mock, new EasyMockMethodInvocationControl<T>(h,
Expand Down Expand Up @@ -2035,7 +2032,7 @@ private static <T> T doCreateMock(Class<T> type, ConstructorArgs constructorArgs
}

private static Set<Method> toSet(Method[] methods) {
return methods == null ? null : new HashSet<Method>(Arrays.asList(methods));
return methods == null ? null : new HashSet<>(Arrays.asList(methods));
}

private static Class<?>[] mergeArgumentTypes(Class<?> firstArgumentType, Class<?>... additionalArgumentTypes) {
Expand All @@ -2056,7 +2053,7 @@ private static Class<?>[] mergeArgumentTypes(Class<?> firstArgumentType, Class<?
private static <T> IExpectationSetters<T> doExpectPrivate(Object instance, Method methodToExpect,
Object... arguments) throws Exception {
WhiteboxImpl.performMethodInvocation(instance, methodToExpect, arguments);
return (IExpectationSetters<T>) org.easymock.EasyMock.expectLastCall();
return (IExpectationSetters<T>) EasyMock.expectLastCall();
}

private static synchronized void replay(Class<?>... types) {
Expand Down Expand Up @@ -2125,7 +2122,7 @@ private void clearStateFromOtherClassLoaders() {
}

private Iterable<ClassLoader> classloadersToClear() {
List<ClassLoader> loaders = new ArrayList<ClassLoader>();
List<ClassLoader> loaders = new ArrayList<>();
final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (classFoundInClassloader(LastControl.class, systemClassLoader)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.powermock.api.easymock.internal.mockstrategy.impl;

import org.easymock.IMocksControl;
import org.easymock.internal.MocksControl;
import org.easymock.MockType;
import org.easymock.internal.MocksControl;
import org.powermock.api.easymock.internal.mockstrategy.MockStrategy;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class JclMockPolicy extends AbstractEasyMockLogPolicyBase {
/**
* Loads all log4j classes with the mock classloader.
*/
protected String[] getFullyQualifiedNamesOfClassesToLoadByMockClassloader() {
@Override
protected String[] getFullyQualifiedNamesOfClassesToLoadByMockClassloader() {
return new String[] { "org.apache.commons.logging.*", "org.apache.log4j.Appender", "org.apache.log4j.xml.DOMConfigurator" };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* <p>
* Before each test method all fields annotated with
* {@link Mock}, {@link org.powermock.api.easymock.annotation.Mock}, {@link org.easymock.Mock}
* {@link Mock}, {@link Mock}, {@link org.easymock.Mock}
* {@link MockNice} or {@link MockStrict} will have mock objects created for
* them and injected to the fields.
* </p>
Expand All @@ -42,7 +42,7 @@
* {@code null}).
* </p>
*
* @see org.powermock.api.easymock.annotation.Mock
* @see Mock
* @see org.easymock.Mock
* @see org.easymock.TestSubject
*
Expand All @@ -51,6 +51,7 @@
public class AnnotationEnabler extends AbstractPowerMockTestListenerBase implements AnnotationEnablerListener {


@Override
@SuppressWarnings("unchecked")
public Class<? extends Annotation>[] getMockAnnotations() {
return new Class[]{Mock.class, MockNice.class, MockStrict.class};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
*/
class AnnotationGlobalMetadata {

private final List<MockMetadata> qualifiedInjections = new ArrayList<MockMetadata>(5);
private final List<MockMetadata> qualifiedInjections = new ArrayList<>(5);

private final List<MockMetadata> unqualifiedInjections = new ArrayList<MockMetadata>(5);
private final List<MockMetadata> unqualifiedInjections = new ArrayList<>(5);

private final Set<String> qualifiers = new HashSet<String>();
private final Set<String> qualifiers = new HashSet<>();

public List<MockMetadata> getQualifiedInjections() {
return qualifiedInjections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,18 @@

package org.powermock.api.extension.listener;

import java.lang.reflect.Method;
import org.powermock.api.easymock.PowerMock;

import static org.powermock.api.easymock.PowerMock.createMock;
import static org.powermock.api.easymock.PowerMock.createNiceMock;
import static org.powermock.api.easymock.PowerMock.createStrictMock;

/**
*
*/
class AnnotationMockCreatorFactory {
public AnnotationMockCreator createDefaultMockCreator() {
return new AnnotationMockCreator() {
@Override
public Object createMockInstance(Class<?> type, Method[] methods) {
return createMock(type, methods);
}
};
return PowerMock::createMock;
}

public AnnotationMockCreator createNiceMockCreator() {
return new AnnotationMockCreator() {
@Override
public Object createMockInstance(Class<?> type, Method[] methods) {
return createNiceMock(type, methods);
}
};
return PowerMock::createNiceMock;
}

public AnnotationMockCreator createStrictMockCreator() {
return new AnnotationMockCreator() {
@Override
public Object createMockInstance(Class<?> type, Method[] methods) {
return createStrictMock(type, methods);
}
};
return PowerMock::createStrictMock;
}
}
Loading

0 comments on commit d4112c9

Please sign in to comment.