RFR(S): 8248910: NPE when freeing the memory for a slice from a buffer

Alan Bateman Alan.Bateman at oracle.com
Tue Aug 18 11:14:11 UTC 2020


On 18/08/2020 09:13, Yangfei (Felix) wrote:
> :
> We spend some time looking into how Randoop works.
> Overall, this tool checks for public method in the specified class file and composes test cases from these methods.
> It calls the java compiler to compile the test cases and run them.  One of the auto-generated test case looks like:
>
> import org.junit.FixMethodOrder;
> import org.junit.Test;
> import org.junit.runners.MethodSorters;
>
> @FixMethodOrder(MethodSorters.NAME_ASCENDING)
> public class RandoopTemporarySeqTest285 {
>
>      public static boolean debug = false;
>
>      @Test
>      public void theSequence285() throws Throwable {
>          if (debug)
>              System.out.format("%n%s%n", "RandoopTemporarySeqTest285.theSequence285");
>          java.nio.ByteBuffer byteBuffer2 = sun.nio.ch.Util.getTemporaryAlignedDirectBuffer((int) (short) 100, (int) ' ');
>          sun.nio.ch.Util.releaseTemporaryDirectBuffer(byteBuffer2);
>          org.junit.Assert.assertNotNull(byteBuffer2);
>      }
> }
>
> So it looks to me like it is using the internal buffer cache directly.
>
Are you going to submit a bug to Randoop on this? It's way too fragile 
to have tools generating code that depend on JDK internal APIs. Also 
this will stop working once the java.base is full encapsulated and/or 
the class changes.

Separately, do need to do some adjustments for direct file I/O and 
aligned buffers but that is a separate discussion.

-Alan.


More information about the nio-dev mailing list