Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up"java.sql.Timestamp" dose not be added in or not implement readObject() #24
Comments
|
Custom class should add by yourself. see https://github.com/node-modules/java.io#4-addobject |
|
see unittest for a demo Line 7 in 5f130ae |
|
I decode the timestamp class, the binary is not end with 0x78
this assert alway wrong, therefore i fork it and comment it. |
|
Not sure adding Custom class can handle it |
|
@Tsuki I try to handle readObject and use your raw.bin const io = require('java.io');
io.addObject('java.sql.Timestamp', {
readObject(io, obj) {
console.log('>> java.sql.Timestamp readObject');
io.readBlockHeader();
var fastTime = io.readLong().toNumber();
console.log('<< readObject | fastTime = %s', fastTime);
obj._$ = new Date(fastTime);
return obj;
},
writeObject(io, obj) {
io.writeBlockHeader(8);
io.writeLong(obj._$.getTime());
},
});
var ret = io.ObjectInputStream.read(fs.readFileSync('raw.bin'), true);
console.log(ret);{
'$': {},
'$class':
{ name: 'java.sql.Timestamp',
serialVersionUID: '2745179027874758501',
flags: 2,
fields: [ { type: 'I', name: 'nanos' } ],
superClass:
{ name: 'java.util.Date',
serialVersionUID: '7523967970034938905',
flags: 3,
fields: [],
superClass: null } },
'_$': new Date('2017-02-03T09:33:02.000Z'),
} |
|
It shoud be have nanos, when you add io.defaultReadObject(obj); you will get AssertionError: SC_WRITE_METHOD object should end with TC_ENDBLOCKDATA
|
this is my workaround
|
Uncaught Error: Class "java.sql.Timestamp" dose not be added in or not implement readObject()