mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-19 23:05:42 +00:00
Fixed a bugs in the Java runtime that could cause an index out of bounds exception.
Tested: on Windows. Change-Id: I0d4cdafc21690eb9a509ba31f21e80dacfb602ff
This commit is contained in:
@@ -17,5 +17,5 @@ rem Compile then run the Java test.
|
||||
|
||||
set batch_file_dir=%~d0%~p0
|
||||
|
||||
javac -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest.java
|
||||
javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest.java
|
||||
java -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest
|
||||
|
||||
@@ -44,9 +44,12 @@ class JavaTest {
|
||||
TestBuffer(bb, 0);
|
||||
|
||||
// Second, let's create a FlatBuffer from scratch in Java, and test it also.
|
||||
// We set up the same values as monsterdata.json:
|
||||
// We use an initial size of 1 to exercise the reallocation algorithm,
|
||||
// normally a size larger than the typical FlatBuffer you generate would be
|
||||
// better for performance.
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(1);
|
||||
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(1024);
|
||||
// We set up the same values as monsterdata.json:
|
||||
|
||||
int str = fbb.createString("MyMonster");
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import flatbuffers.*;
|
||||
|
||||
public class Any {
|
||||
public static final byte NONE = 0;
|
||||
public static final byte Monster = 1;
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import flatbuffers.*;
|
||||
|
||||
public class Color {
|
||||
public static final byte Red = 0;
|
||||
public static final byte Green = 1;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Test extends Struct {
|
||||
public byte b() { return bb.get(bb_pos + 2); }
|
||||
|
||||
public static int createTest(FlatBufferBuilder builder, short a, byte b) {
|
||||
builder.prep(2, 0);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.putByte(b);
|
||||
builder.putShort(a);
|
||||
|
||||
@@ -18,9 +18,9 @@ public class Vec3 extends Struct {
|
||||
public Test test3(Test obj) { return obj.__init(bb_pos + 26, bb); }
|
||||
|
||||
public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, byte test2, short Test_a, byte Test_b) {
|
||||
builder.prep(16, 0);
|
||||
builder.prep(16, 32);
|
||||
builder.pad(2);
|
||||
builder.prep(2, 0);
|
||||
builder.prep(2, 4);
|
||||
builder.pad(1);
|
||||
builder.putByte(Test_b);
|
||||
builder.putShort(Test_a);
|
||||
|
||||
Reference in New Issue
Block a user