GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Illegal reflective access by org.msgpack.core.buffer.DirectBufferAccess · Issue #605 · msgpack/msgpack-java

Illegal reflective access by org.msgpack.core.buffer.DirectBufferAccess #605

New issue
Copy link
New issue
Copy link
Open
Open
Illegal reflective access by org.msgpack.core.buffer.DirectBufferAccess#605
Copy link

Description

@t-horikawa
t-horikawa
opened on Nov 18, 2021
Issue body actions

When I run my program, I get a warning message with the title. The message also said "Please consider reporting this to the maintainers of org.msgpack.core.buffer.DirectBufferAccess", so I will report it here.

A simple reproduction program (named ReproduceCase.java) is below.

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.msgpack.core.MessagePack;
import org.msgpack.core.MessagePacker;
import org.msgpack.core.MessageUnpacker;
import org.msgpack.core.buffer.ByteBufferInput;

public final class ReproduceCase {
    class ByteBufferBackedInput extends ByteBufferInput {
        ByteBufferBackedInput(ByteBuffer byteBuffer) {
            super(byteBuffer);
        }
    }

    ReproduceCase() {
    }

    ByteBufferInput encode() throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        MessagePacker packer = org.msgpack.core.MessagePack.newDefaultPacker(outputStream);

        packer.packLong((long) 123456789);
        packer.flush();

        byte[] ba = outputStream.toByteArray();
        var length = ba.length;

        var directByteBuffer = ByteBuffer.allocateDirect(length);
        directByteBuffer.put(ba, 0, length);
        directByteBuffer.rewind();

        return new ByteBufferBackedInput(directByteBuffer);
    }

    void decode(ByteBufferInput buffer) throws IOException {
        var unpacker = org.msgpack.core.MessagePack.newDefaultUnpacker(buffer);
        System.out.println(unpacker.unpackLong());
    }

    public static void main(String[] args) {
        try {
            var reproduce = new ReproduceCase();
            var buffer = reproduce.encode();
            reproduce.decode(buffer);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

The warning message is output when the following line is executed.

        var unpacker = org.msgpack.core.MessagePack.newDefaultUnpacker(buffer);

The following is supplementary information.

  1. This happens with both msgpack-core-0.8.24 and 0.9.0.
  2. unpacker.unpackLong() works fine, as you can see when you run the program.
  3. If you used ByteBuffer.allocate(length) instead of ByteBuffer.allocateDirect(length), you will not get that warning. However, that is not a solution for me because my program needs to use direct byte buffer.

Activity

  1. xerial commented on Jun 28, 2022

    @xerial
    xerial
    on Jun 28, 2022
    Member
    More actions

    I think this is a JDK17-specific issue, which will be fixed in #660.

    Adding two JVM options would be necessary:

    --add-opens=java.base/java.nio=ALL-UNNAMED
    --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.