Skip to content

Commit

Permalink
Fixing a Java 9 and beyond regression. See github.com/apache/felix/pu…
Browse files Browse the repository at this point in the history
…ll/114 for details.
  • Loading branch information
ProgrammerDan committed Apr 2, 2021
1 parent 221682e commit 4d723d4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/haven/FastMesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private FillBuffer indfill(Indices ibuf, Environment env) {
FillBuffer dst = env.fillbuf(ibuf);
ShortBuffer buf = dst.push().asShortBuffer();
ShortBuffer tx = indb.duplicate();
tx.rewind();
((Buffer) tx).rewind();
buf.put(tx);
return(dst);
}
Expand Down
22 changes: 11 additions & 11 deletions src/haven/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1248,25 +1248,25 @@ public static boolean parsebool(String s, boolean def) {
public static FloatBuffer bufcp(float[] a) {
FloatBuffer b = mkfbuf(a.length);
b.put(a);
b.rewind();
((Buffer)b).rewind();
return(b);
}
public static ShortBuffer bufcp(short[] a) {
ShortBuffer b = mksbuf(a.length);
b.put(a);
b.rewind();
((Buffer)b).rewind();
return(b);
}
public static FloatBuffer bufcp(FloatBuffer a) {
a.rewind();
((Buffer)a).rewind();
FloatBuffer ret = mkfbuf(a.remaining());
ret.put(a).rewind();
((Buffer)ret.put(a)).rewind();
return(ret);
}
public static IntBuffer bufcp(IntBuffer a) {
a.rewind();
((Buffer)a).rewind();
IntBuffer ret = mkibuf(a.remaining());
ret.put(a).rewind();
((Buffer)ret.put(a)).rewind();
return(ret);
}
public static ByteBuffer mkbbuf(int n) {
Expand Down Expand Up @@ -1317,15 +1317,15 @@ public static ShortBuffer wsbuf(int n) {
return(ShortBuffer.wrap(new short[n]));
}
public static FloatBuffer wbufcp(FloatBuffer a) {
a.rewind();
((Buffer)a).rewind();
FloatBuffer ret = wfbuf(a.remaining());
ret.put(a.slice()).rewind();
((Buffer)ret.put(a.slice())).rewind();
return(ret);
}
public static IntBuffer wbufcp(IntBuffer a) {
a.rewind();
((Buffer)a).rewind();
IntBuffer ret = wibuf(a.remaining());
ret.put(a.slice()).rewind();
((Buffer)ret.put(a.slice())).rewind();
return(ret);
}

Expand All @@ -1335,7 +1335,7 @@ public static ByteBuffer growbuf(ByteBuffer buf, int req) {
int sz = buf.capacity();
while(sz - buf.position() < req)
sz <<= 1;
return(ByteBuffer.allocate(sz).order(buf.order()).put((ByteBuffer)buf.flip()));
return(ByteBuffer.allocate(sz).order(buf.order()).put((ByteBuffer)((Buffer)buf).flip()));
}

public static float[] c2fa(Color c) {
Expand Down
4 changes: 2 additions & 2 deletions src/haven/VertexBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void data(ByteBuffer bdst, int offset, int stride) {
throw(new AssertionError());
FloatBuffer dst = bdst.asFloatBuffer();
if(stride == elfmt.size()) {
dst.position(offset / 4);
((Buffer)dst).position(offset / 4);
dst.put(data);
} else if((stride % 4) == 0) {
for(int i = 0, o = offset / 4, fs = stride / 4; i < data.capacity(); i += elfmt.nc, o += fs) {
Expand Down Expand Up @@ -188,7 +188,7 @@ public void data(ByteBuffer bdst, int offset, int stride) {
throw(new AssertionError());
IntBuffer dst = bdst.asIntBuffer();
if(stride == elfmt.size()) {
dst.position(offset / 4);
((Buffer)dst).position(offset / 4);
dst.put(data);
} else if((stride % 4) == 0) {
for(int i = 0, o = offset / 4, fs = stride / 4; i < data.capacity(); i += elfmt.nc, o += fs) {
Expand Down
12 changes: 6 additions & 6 deletions src/haven/render/gl/BGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,21 @@ public void bglCallList(final BufferBGL list) {
public void bglCopyBufferf(final FloatBuffer dst, final int doff, final FloatBuffer src, final int soff, final int len) {
add(new Command() {
public void run(GL3 gl) {
dst.position(doff);
src.position(soff).limit(len);
((Buffer)dst).position(doff);
((Buffer)src).position(soff).limit(len);
dst.put(src);
dst.rewind();
src.rewind().limit(src.capacity());
((Buffer)dst).rewind();
((Buffer)src).rewind().limit(src.capacity());
}
});
}

public void bglCopyBufferf(final FloatBuffer dst, final int doff, final float[] src, final int soff, final int len) {
add(new Command() {
public void run(GL3 gl) {
dst.position(doff);
((Buffer)dst).position(doff);
dst.put(src, soff, len);
dst.rewind();
((Buffer)dst).rewind();
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/haven/render/gl/GLRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void run(GL3 gl) {
if(data.va.bufs[i].usage == EPHEMERAL)
buf.put(((HeapBuffer)bufs[i]).buf);
}
buf.flip();
((Buffer)buf).flip();
gl.glBufferData(GL.GL_ARRAY_BUFFER, jdsz, buf, GL3.GL_STREAM_DRAW);
}
});
Expand Down Expand Up @@ -436,7 +436,7 @@ public void pget(Pipe pipe, FragData buf, Area area, VectorFormat fmt, Consumer<
cgl.glBindBuffer(GL3.GL_PIXEL_PACK_BUFFER, 0);
pbo.dispose();
GLException.checkfor(cgl, env);
data.rewind();
((Buffer)data).rewind();
/* XXX: It's not particularly nice to do the
* flipping on the dispatch thread, but OpenGL
* does not seem to offer any GPU-assisted
Expand Down Expand Up @@ -486,7 +486,7 @@ public void pget(Texture.Image img, VectorFormat fmt, Consumer<ByteBuffer> callb
cgl.glBindBuffer(GL3.GL_PIXEL_PACK_BUFFER, 0);
pbo.dispose();
GLException.checkfor(cgl, env);
data.rewind();
((Buffer)data).rewind();
/* XXX: It's not particularly nice to do the
* flipping on the dispatch thread, but OpenGL
* does not seem to offer any GPU-assisted
Expand Down
4 changes: 2 additions & 2 deletions src/haven/render/gl/StreamBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ByteBuffer get() {
if(!used[i]) {
if(xfbufs[i] == null)
xfbufs[i] = mkbuf();
xfbufs[i].rewind();
((Buffer)xfbufs[i]).rewind();
used[i] = true;
return(xfbufs[i]);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ ByteBuffer get() {
synchronized(this) {
ByteBuffer ret = this.data;
this.data = null;
ret.rewind();
((Buffer)ret).rewind();
return(ret);
}
}
Expand Down

0 comments on commit 4d723d4

Please sign in to comment.