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

An illegal reflective access operation has occurred #2312

Closed
marcospassos opened this issue Apr 29, 2019 · 5 comments
Closed

An illegal reflective access operation has occurred #2312

marcospassos opened this issue Apr 29, 2019 · 5 comments

Comments

@marcospassos
Copy link
Contributor

Hello,

I'm facing the following error trying to serialize a class using mixins in Java 8:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.fasterxml.jackson.databind.util.ClassUtil (file:/jackson-databind/2.9.8/jackson-databind-2.9.8.jar) to field java.time.Duration.seconds
WARNING: Please consider reporting this to the maintainers of com.fasterxml.jackson.databind.util.ClassUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
@JsonAutoDetect(
    fieldVisibility = Visibility.NONE,
    creatorVisibility = Visibility.NONE,
    getterVisibility = Visibility.NONE,
    setterVisibility = Visibility.NONE,
    isGetterVisibility = Visibility.NONE
)
public abstract class DurationMixin {
    @JsonCreator
    public static Duration ofSeconds(
        @JsonProperty("seconds")
        final long seconds,
        @JsonProperty("nano")
        final long nanoAdjustment
    ) {
        return null;
    }

    @JsonProperty("seconds")
    abstract long getSeconds();

    @JsonProperty("nano")
    abstract int getNano();
}

final ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule("MyModule", new Version(1, 0, 0, null));
mapper.addMixIn(Duration.class, DurationMixin.class);
mapper.readerFor(Duration.class).readValue(mapper.writeValueAsString(Duration.ofDays(1)));

Any guess on how to fix it?

@GedMarc
Copy link

GedMarc commented Apr 29, 2019

That's a Java9^ error xD In Java 8 you won't get that.
V3 I believe? or 2.10,

I solved the problem for jaxb and annotations btw @cowtowncoder

https://search.maven.org/artifact/com.jwebmp.thirdparty/javax.activation/0.67.0.5/jar
Including this as optional/provided will build correctly leaving it the consumer to specify which library to use,

sadly https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api/1.3.4 is unusable, and not planned for any jpms (jakarta jdk 8 only)

@cowtowncoder
Copy link
Member

@GedMarc ok so wrt JAXB module, what exactly needs to be added and where (in pom.xml vs class-info for Moditect)?

@GedMarc
Copy link

GedMarc commented Apr 29, 2019

@cowtowncoder If you are happy with that I can finish the osgi and guice ones for you quickly

@cowtowncoder
Copy link
Member

With 2.10.0.pr2, we should have module-info so hopefully that helps.

Otherwise more info would be needed; may be reopened if this is still a problem.

@cowtowncoder
Copy link
Member

Looks like there are other similar issues, see #2464

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

No branches or pull requests

3 participants