Skip to content

Commit 0d77db6

Browse files
committed
Fixing a Java 9 and beyond regression. See github.com/apache/felix/pull/114 for details.
1 parent 54a5f2e commit 0d77db6

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

src/haven/FastMesh.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private FillBuffer indfill(Indices ibuf, Environment env) {
5959
FillBuffer dst = env.fillbuf(ibuf);
6060
ShortBuffer buf = dst.push().asShortBuffer();
6161
ShortBuffer tx = indb.duplicate();
62-
tx.rewind();
62+
((Buffer) tx).rewind();
6363
buf.put(tx);
6464
return(dst);
6565
}

src/haven/Utils.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,25 +1248,25 @@ public static boolean parsebool(String s, boolean def) {
12481248
public static FloatBuffer bufcp(float[] a) {
12491249
FloatBuffer b = mkfbuf(a.length);
12501250
b.put(a);
1251-
b.rewind();
1251+
((Buffer)b).rewind();
12521252
return(b);
12531253
}
12541254
public static ShortBuffer bufcp(short[] a) {
12551255
ShortBuffer b = mksbuf(a.length);
12561256
b.put(a);
1257-
b.rewind();
1257+
((Buffer)b).rewind();
12581258
return(b);
12591259
}
12601260
public static FloatBuffer bufcp(FloatBuffer a) {
1261-
a.rewind();
1261+
((Buffer)a).rewind();
12621262
FloatBuffer ret = mkfbuf(a.remaining());
1263-
ret.put(a).rewind();
1263+
((Buffer)ret.put(a)).rewind();
12641264
return(ret);
12651265
}
12661266
public static IntBuffer bufcp(IntBuffer a) {
1267-
a.rewind();
1267+
((Buffer)a).rewind();
12681268
IntBuffer ret = mkibuf(a.remaining());
1269-
ret.put(a).rewind();
1269+
((Buffer)ret.put(a)).rewind();
12701270
return(ret);
12711271
}
12721272
public static ByteBuffer mkbbuf(int n) {
@@ -1317,15 +1317,15 @@ public static ShortBuffer wsbuf(int n) {
13171317
return(ShortBuffer.wrap(new short[n]));
13181318
}
13191319
public static FloatBuffer wbufcp(FloatBuffer a) {
1320-
a.rewind();
1320+
((Buffer)a).rewind();
13211321
FloatBuffer ret = wfbuf(a.remaining());
1322-
ret.put(a.slice()).rewind();
1322+
((Buffer)ret.put(a.slice())).rewind();
13231323
return(ret);
13241324
}
13251325
public static IntBuffer wbufcp(IntBuffer a) {
1326-
a.rewind();
1326+
((Buffer)a).rewind();
13271327
IntBuffer ret = wibuf(a.remaining());
1328-
ret.put(a.slice()).rewind();
1328+
((Buffer)ret.put(a.slice())).rewind();
13291329
return(ret);
13301330
}
13311331

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

13411341
public static float[] c2fa(Color c) {

src/haven/VertexBuf.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void data(ByteBuffer bdst, int offset, int stride) {
158158
throw(new AssertionError());
159159
FloatBuffer dst = bdst.asFloatBuffer();
160160
if(stride == elfmt.size()) {
161-
dst.position(offset / 4);
161+
((Buffer)dst).position(offset / 4);
162162
dst.put(data);
163163
} else if((stride % 4) == 0) {
164164
for(int i = 0, o = offset / 4, fs = stride / 4; i < data.capacity(); i += elfmt.nc, o += fs) {
@@ -188,7 +188,7 @@ public void data(ByteBuffer bdst, int offset, int stride) {
188188
throw(new AssertionError());
189189
IntBuffer dst = bdst.asIntBuffer();
190190
if(stride == elfmt.size()) {
191-
dst.position(offset / 4);
191+
((Buffer)dst).position(offset / 4);
192192
dst.put(data);
193193
} else if((stride % 4) == 0) {
194194
for(int i = 0, o = offset / 4, fs = stride / 4; i < data.capacity(); i += elfmt.nc, o += fs) {

src/haven/render/gl/BGL.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,21 @@ public void bglCallList(final BufferBGL list) {
228228
public void bglCopyBufferf(final FloatBuffer dst, final int doff, final FloatBuffer src, final int soff, final int len) {
229229
add(new Command() {
230230
public void run(GL3 gl) {
231-
dst.position(doff);
232-
src.position(soff).limit(len);
231+
((Buffer)dst).position(doff);
232+
((Buffer)src).position(soff).limit(len);
233233
dst.put(src);
234-
dst.rewind();
235-
src.rewind().limit(src.capacity());
234+
((Buffer)dst).rewind();
235+
((Buffer)src).rewind().limit(src.capacity());
236236
}
237237
});
238238
}
239239

240240
public void bglCopyBufferf(final FloatBuffer dst, final int doff, final float[] src, final int soff, final int len) {
241241
add(new Command() {
242242
public void run(GL3 gl) {
243-
dst.position(doff);
243+
((Buffer)dst).position(doff);
244244
dst.put(src, soff, len);
245-
dst.rewind();
245+
((Buffer)dst).rewind();
246246
}
247247
});
248248
}

src/haven/render/gl/GLRender.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public void run(GL3 gl) {
223223
if(data.va.bufs[i].usage == EPHEMERAL)
224224
buf.put(((HeapBuffer)bufs[i]).buf);
225225
}
226-
buf.flip();
226+
((Buffer)buf).flip();
227227
gl.glBufferData(GL.GL_ARRAY_BUFFER, jdsz, buf, GL3.GL_STREAM_DRAW);
228228
}
229229
});
@@ -436,7 +436,7 @@ public void pget(Pipe pipe, FragData buf, Area area, VectorFormat fmt, Consumer<
436436
cgl.glBindBuffer(GL3.GL_PIXEL_PACK_BUFFER, 0);
437437
pbo.dispose();
438438
GLException.checkfor(cgl, env);
439-
data.rewind();
439+
((Buffer)data).rewind();
440440
/* XXX: It's not particularly nice to do the
441441
* flipping on the dispatch thread, but OpenGL
442442
* does not seem to offer any GPU-assisted
@@ -486,7 +486,7 @@ public void pget(Texture.Image img, VectorFormat fmt, Consumer<ByteBuffer> callb
486486
cgl.glBindBuffer(GL3.GL_PIXEL_PACK_BUFFER, 0);
487487
pbo.dispose();
488488
GLException.checkfor(cgl, env);
489-
data.rewind();
489+
((Buffer)data).rewind();
490490
/* XXX: It's not particularly nice to do the
491491
* flipping on the dispatch thread, but OpenGL
492492
* does not seem to offer any GPU-assisted

src/haven/render/gl/StreamBuffer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public ByteBuffer get() {
6363
if(!used[i]) {
6464
if(xfbufs[i] == null)
6565
xfbufs[i] = mkbuf();
66-
xfbufs[i].rewind();
66+
((Buffer)xfbufs[i]).rewind();
6767
used[i] = true;
6868
return(xfbufs[i]);
6969
}
@@ -120,7 +120,7 @@ ByteBuffer get() {
120120
synchronized(this) {
121121
ByteBuffer ret = this.data;
122122
this.data = null;
123-
ret.rewind();
123+
((Buffer)ret).rewind();
124124
return(ret);
125125
}
126126
}

0 commit comments

Comments
 (0)