Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java7 classes should no longer need reflection #3707

Closed
wants to merge 1 commit into from

Conversation

pjfanning
Copy link
Member

@pjfanning pjfanning commented Dec 25, 2022

  • Since Jackson 2.14, Java 8 is minimum needed
  • with newer Java releases, it is better to minimise the use of Java reflection
  • In theory, we could roll this code into parent classes but removing classes might be regarded as a breaking change - in the unlikely scenario, that someone has subclassed this part of the code

@cowtowncoder
Copy link
Member

I agree with the goals. But would this be problematic for Android users?

@pjfanning
Copy link
Member Author

I agree with the goals. But would this be problematic for Android users?

I don't know much about Android. I sort of assumed CI build was set up to check. I thought I saw mention of Animal Sniffer being used to verify compatibility with Android API level 26.

@pjfanning
Copy link
Member Author

I'll close this. Looks like this Java7 support class is needed for Android compatibility.

      <plugin>
	<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>
            <!-- 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>
      </plugin>

@pjfanning pjfanning closed this Dec 25, 2022
@pjfanning
Copy link
Member Author

It's possible that the java.nio classes are actually ok. Animal Sniffer only picks up on the 2 java.beans classes when I empty the ignores list.

[ERROR] /Users/pj.fanning/code/jackson-databind/src/main/java/com/fasterxml/jackson/databind/ext/Java7SupportImpl.java:29: Undefined reference: java.beans.Transient
[ERROR] /Users/pj.fanning/code/jackson-databind/src/main/java/com/fasterxml/jackson/databind/ext/Java7SupportImpl.java:31: Undefined reference: boolean java.beans.Transient.value()
[ERROR] /Users/pj.fanning/code/jackson-databind/src/main/java/com/fasterxml/jackson/databind/ext/Java7SupportImpl.java:38: Undefined reference: java.beans.ConstructorProperties
[ERROR] /Users/pj.fanning/code/jackson-databind/src/main/java/com/fasterxml/jackson/databind/ext/Java7SupportImpl.java:52: Undefined reference: java.beans.ConstructorProperties
[ERROR] /Users/pj.fanning/code/jackson-databind/src/main/java/com/fasterxml/jackson/databind/ext/Java7SupportImpl.java:54: Undefined reference: String[] java.beans.ConstructorProperties.value()
[ERROR] Failed to execute goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.22:check (default-cli) on project jackson-databind: Signature errors found. Verify them and ignore them with the proper annotation if needed. -> [Help 1]
[ERROR] 

@cowtowncoder
Copy link
Member

Ok, I think there are 2 things we can consider then:

  1. Remove Reflection for java.nio classes if they are ok with ADK 26
  2. See which ADK (if any?) would allow annotations, and consider future work for like Jackson 2.16 -- we can definitely raised ADK minimum over releases

For (2) we should probably file a new issue for 2.16 for follow-up work.

@pjfanning
Copy link
Member Author

replaced by #3708

@pjfanning pjfanning deleted the java7-support branch December 25, 2022 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants