Skip to content

Add support for java.lang.Bool, Integer and Long classes #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 26, 2019

Conversation

qistoph
Copy link
Contributor

@qistoph qistoph commented Apr 22, 2019

This PR adds support for instances of

  • java.lang.Bool
  • java.lang.Integer
  • java.lang.Long

Test cases created with:

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;

public class Creator {
    public static void main(String[] args)
    throws Exception {
        HashMap hm1 = new HashMap();
        hm1.put("key1", "value1");
        hm1.put("key2", "value2");
        hm1.put("int", 9);
        hm1.put("ing2", new Integer(10));
        hm1.put("bool", true);
        hm1.put("bool2", new Boolean(true));
        FileOutputStream fs = new FileOutputStream("hashmap-1.ser");
        ObjectOutputStream os = new ObjectOutputStream(fs);
        os.writeObject(hm1);
        os.close();

        HashMap hm2 = new HashMap();
        hm2.put("key1", hm1);
        fs = new FileOutputStream("hashmap-2.ser");
        os = new ObjectOutputStream(fs);
        os.writeObject(hm2);
        os.close();
    }
}

Tested with:

#!/usr/bin/python3
  
import sys
import logging

logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)

import javaobj

#filename = 'creator/hashmap-1.ser'
filename = 'creator/hashmap-2.ser'
with open(filename, 'rb') as fd:
    jobj = fd.read()

pobj = javaobj.loads(jobj)
print(pobj)

@coveralls
Copy link

coveralls commented Apr 22, 2019

Coverage Status

Coverage decreased (-0.3%) to 79.237% when pulling a2c0172 on qistoph:master into 1dc4427 on tcalmant:master.

@tcalmant tcalmant merged commit a2c0172 into tcalmant:master Apr 26, 2019
tcalmant added a commit that referenced this pull request Apr 26, 2019
tcalmant added a commit that referenced this pull request Apr 26, 2019
@tcalmant
Copy link
Owner

Thank you for your contribution 👍
I've added the unit test plus the comparison operators to the loaded classes

tcalmant added a commit that referenced this pull request Apr 26, 2019
- Fixes #25
- Seems to have been unlocked thanks to #27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants