Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
3ed7aaad
Commit
3ed7aaad
authored
5 years ago
by
J. M. Bailey
Browse files
Options
Downloads
Patches
Plain Diff
Workaround jdk 8 bytecode bug in createPdu()
parent
5d54379e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/edu/nps/moves/dis7/util/PduFactory.java
+11
-5
11 additions, 5 deletions
src/edu/nps/moves/dis7/util/PduFactory.java
with
11 additions
and
5 deletions
src/edu/nps/moves/dis7/util/PduFactory.java
+
11
−
5
View file @
3ed7aaad
...
...
@@ -9,6 +9,7 @@ import edu.nps.moves.dis7.*;
import
edu.nps.moves.dis7.enumerations.*
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.nio.Buffer
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -1458,21 +1459,26 @@ public class PduFactory
/**
* PDU builder. Pass in an array of bytes, get the correct type of pdu back,
* based on the PDU type field contained in the byte buffer.
* based on the PDU type field contained in the byte buffer. (Implementation note: includes
* workaround code for a jdk8 bytecode bug.)
*
* @param buff
* @return the pdu or null if there was an error creating the Pdu
*/
public
Pdu
createPdu
(
java
.
nio
.
ByteBuffer
buff
)
{
int
pos
=
buff
.
position
();
// Save buffer's position
// The (unnecessary) casts around the position() calls are a workaround for an apparent bytecode bug with
// javac involving jdk 8. Google "java bytebuffer no such method position" and see https://github.com/eclipse/jetty.project/issues/3244
// specifically for the workaround used in three places below.
int
pos
=
((
Buffer
)
buff
).
position
();
// Save buffer's position
if
(
pos
+
2
>
buff
.
limit
())
{
// Make sure there's enough space in buffer
return
null
;
// Else return null
}
// end if: buffer too short
buff
.
position
(
pos
+
2
);
// Advance to third byte
((
Buffer
)
buff
).
position
(
pos
+
2
);
// Advance to third byte
final
int
pduIdx
=
Byte
.
toUnsignedInt
(
buff
.
get
());
// Read Pdu type
buff
.
position
(
pos
);
// Reset buffer
((
Buffer
)
buff
)
.
position
(
pos
);
// Reset buffer
DISPDUType
pduType
=
DISPDUType
.
getEnumForValue
(
pduIdx
);
return
createPdu
(
pduType
,
buff
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment