Added TypeUtilities, moved ClassHelper into it's own package so java 1.8

specific code can be compiled separately.
This commit is contained in:
nathan 2018-01-24 17:32:49 +01:00
parent b96ac4be89
commit b1872f8cf6
5 changed files with 54 additions and 25 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />

View File

@ -47,3 +47,4 @@ public abstract class ClassResolver {
return CALLER_RESOLVER.getClassContext()[CALL_CONTEXT_OFFSET + callerOffset];
}
}

View File

@ -1,19 +1,19 @@
/*
* Copyright 2010 dorkbox, llc
* Copyright 2018 dorkbox, llc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.util;
package dorkbox.util.generics;
import java.lang.reflect.Type;

View File

@ -0,0 +1,29 @@
/*
* Copyright 2018 dorkbox, llc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.util.generics;
import java.lang.reflect.Method;
/**
* This class must be compiled for java 8+, and is needed by the TypeResolver in some situations
*/
public
class DefaultMethodHelper {
static
boolean isDefaultMethod(Method m) {
return m.isDefault();
}
}

View File

@ -1,21 +1,19 @@
/*
* Copyright 2002-2017 Jonathan Halterman
* Copyright 2018 dorkbox, llc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* From: https://github.com/jhalterman/typetools
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.util;
package dorkbox.util.generics;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
@ -43,6 +41,7 @@ import sun.misc.Unsafe;
/**
* Enhanced type resolution utilities.
*
* From: https://github.com/jhalterman/typetools
* @author Jonathan Halterman
*/
@SuppressWarnings("restriction")
@ -544,7 +543,7 @@ class TypeResolver {
private static
boolean isDefaultMethod(Method m) {
return JAVA_VERSION >= 1.8 && m.isDefault();
return JAVA_VERSION >= 1.8 && DefaultMethodHelper.isDefaultMethod(m);
}
private static