Skip to content

Commit

Permalink
Seems like java.nio.file.Path is safe for Android API level 26 (#3708)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Dec 25, 2022
1 parent 958677f commit c8fd50f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
22 changes: 9 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,22 @@
mvn animal-sniffer:check
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.22</version>
<configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.22</version>
<configuration>
<signature>
<groupId>com.toasttab.android</groupId>
<artifactId>gummy-bears-api-${version.android.sdk}</artifactId>
<version>${version.android.sdk.signature}</version>
</signature>
<ignores>
<ignores>
<!-- These are only accessed (safely) via "Java7SupportImpl.java" so ignore
-->
<ignore>java.beans.ConstructorProperties</ignore>
<ignore>java.beans.Transient</ignore>
<ignore>java.nio.file.FileSystemNotFoundException</ignore>
<ignore>java.nio.file.Path</ignore>
<ignore>java.nio.file.Paths</ignore>
<ignore>java.nio.file.spi.FileSystemProvider</ignore>
</ignores>
</configuration>
<ignore>java.beans.ConstructorProperties</ignore>
<ignore>java.beans.Transient</ignore>
</ignores>
</configuration>
</plugin>

</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,19 @@

import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.util.ClassUtil;

/**
* To support Java7-incomplete platforms, we will offer support for JDK 7
* datatype(s) (that is, {@link java.nio.file.Path} through this class, loaded
* dynamically; if loading fails, support will be missing.
* This class is the non-JDK-7-dependent API, and {@link Java7HandlersImpl} is
* JDK7-dependent implementation of functionality.
* Since v2.15, {@link Java7HandlersImpl} is no longer loaded via reflection.
* <p>
* Prior to v2.15, this class supported Java7-incomplete platforms, specifically
* platforms that do not support {@link java.nio.file.Path}.
* </p>
*
* @since 2.10 (cleaved off of {@link Java7Support})
*/
public abstract class Java7Handlers
{
private final static Java7Handlers IMPL;

static {
Java7Handlers impl = null;
try {
Class<?> cls = Class.forName("com.fasterxml.jackson.databind.ext.Java7HandlersImpl");
impl = (Java7Handlers) ClassUtil.createInstance(cls, false);
} catch (Throwable t) {
// 09-Sep-2019, tatu: Could choose not to log this, but since this is less likely
// to miss (than annotations), do it
// 02-Nov-2020, Xakep_SDK: Remove java.logging module dependency
// java.util.logging.Logger.getLogger(Java7Handlers.class.getName())
// .warning("Unable to load JDK7 types (java.nio.file.Path): no Java7 type support added");
}
IMPL = impl;
}
private final static Java7Handlers IMPL = new Java7HandlersImpl();

public static Java7Handlers instance() {
return IMPL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.fasterxml.jackson.databind.JsonSerializer;

/**
* Since v2.15, this is no longer loaded via reflection.
*
* @since 2.10
*/
public class Java7HandlersImpl extends Java7Handlers
Expand Down

0 comments on commit c8fd50f

Please sign in to comment.