VAO+glDrawElements - bug in JOGL 2.0

This code


//Init
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , vbo);
gl.glBufferData (GL.GL_ARRAY_BUFFER ,vertexBuffer.capacity()*BufferUtil.SIZEOF_FLOAT, vertexBuffer,GL.GL_STATIC_DRAW );
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , 0);
		
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , vboe);
gl.glBufferData (GL.GL_ELEMENT_ARRAY_BUFFER , indexBuffer.capacity()*BufferUtil.SIZEOF_INT,indexBuffer,GL.GL_STATIC_DRAW );
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , 0);


gl.glBindVertexArray(vao);

gl.glBindBuffer (GL.GL_ARRAY_BUFFER , vbo);
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , vboe);
	
gl.glEnableVertexAttribArray(0);
gl.glVertexAttribPointer(0, 3, GL.GL_FLOAT, false, 0, 0);
		
gl.glBindVertexArray(0);
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , 0);
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , 0);

//Draw


gl.glBindVertexArray(vao);
gl.glDrawElements (GL.GL_TRIANGLES, 6, GL2.GL_UNSIGNED_INT, 0);
gl.glBindVertexArray(0);

Generate exception
javax.media.opengl.GLException: element vertex_buffer_object must be enabled to call this method

This is wrong!
vertex array object stores GL_ELEMENT_ARRAY_BUFFER_BINDING
and I do not have it each time set

this code works but it is not correct!!!


gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , vboe);
gl.glBindVertexArray(vao);
gl.glDrawElements (GL.GL_TRIANGLES, 6, GL2.GL_UNSIGNED_INT, 0);
gl.glBindVertexArray(0);

vboe can point to any, even non-existent buffer and the code will work but it is not correct!!!

That’s why this is happening

glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , 0); 
call bufferStateTracker.setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
call bindingMap.put(GL_ELEMENT_ARRAY_BUFFER, box(0));

and

glDrawElements (GL.GL_TRIANGLES, 6, GL2.GL_UNSIGNED_INT, 0);
call checkElementVBOEnabled(true);
call checkBufferObject(true, true, false, true, GL_ELEMENT_ARRAY_BUFFER, "element ertex_buffer_object", true);
call int j = bufferStateTracker.getBoundBufferObject(GL_ELEMENT_ARRAY_BUFFER, this);
(getBoundBufferObject return bindingMap.get(box(GL_ELEMENT_ARRAY_BUFFER)).intValue())

flag3 = true
flag4 = true
j = 0

and in checkBufferObject generated exception


if(flag3)
        {
            if(j == 0)
                if(flag4)
                    throw new GLException(s + " must be enabled to call this method");

is correct when not in use VAO,
but when I call glBindVertexArray can not take the current
GL_ELEMENT_ARRAY_BUFFER of bindingMap field
(in the class GLBufferStateTracker)
need to re-read it glGetIntegerv