{"action":"created","issue":{"url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/333","labels_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/333/labels{/name}","comments_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/333/comments","events_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/333/events","html_url":"https://github.com/EsotericSoftware/kryo/issues/333","id":99334675,"number":333,"title":"how kryo serialize field object with enum class within some object","user":{"login":"bwzhang2011","id":749788,"avatar_url":"https://avatars.githubusercontent.com/u/749788?v=3","gravatar_id":"","url":"https://api.github.com/users/bwzhang2011","html_url":"https://github.com/bwzhang2011","followers_url":"https://api.github.com/users/bwzhang2011/followers","following_url":"https://api.github.com/users/bwzhang2011/following{/other_user}","gists_url":"https://api.github.com/users/bwzhang2011/gists{/gist_id}","starred_url":"https://api.github.com/users/bwzhang2011/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwzhang2011/subscriptions","organizations_url":"https://api.github.com/users/bwzhang2011/orgs","repos_url":"https://api.github.com/users/bwzhang2011/repos","events_url":"https://api.github.com/users/bwzhang2011/events{/privacy}","received_events_url":"https://api.github.com/users/bwzhang2011/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-08-06T01:43:53Z","updated_at":"2015-08-07T01:26:40Z","closed_at":null,"body":"Hi, I encountered some problem when serialize field object with enum class within my bean between different jvm. here comes my bean like this:\r\n1. bean with enum class:\r\npublic class MonitorCtrlBean implements java.io.Serializable {\r\n\tprivate static final long serialVersionUID = 9082640203431233882L;\r\n\r\n\tprivate String instanceKey;\r\n\r\n\tprivate MonitorResourceType monitorResType;\r\n\r\n\tprivate MonitorOperType monitorOperType;\r\n\r\n\tpublic MonitorCtrlBean() {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic MonitorCtrlBean(String instanceKey, MonitorResourceType monitorResType,\r\n\t\t\tMonitorOperType monitorOperType) {\r\n\t\tthis.instanceKey = instanceKey;\r\n\t\tthis.monitorResType = monitorResType;\r\n\t\tthis.monitorOperType = monitorOperType;\r\n\t}\r\n\r\n\tpublic String getInstanceKey() {\r\n\t\treturn instanceKey;\r\n\t}\r\n\r\n\tpublic void setInstanceKey(String instanceKey) {\r\n\t\tthis.instanceKey = instanceKey;\r\n\t}\r\n\r\n\tpublic MonitorResourceType getMonitorResType() {\r\n\t\treturn monitorResType;\r\n\t}\r\n\r\n\tpublic void setMonitorResType(MonitorResourceType monitorResType) {\r\n\t\tthis.monitorResType = monitorResType;\r\n\t}\r\n\r\n\tpublic MonitorOperType getMonitorOperType() {\r\n\t\treturn monitorOperType;\r\n\t}\r\n\r\n\tpublic void setMonitorOperType(MonitorOperType monitorOperType) {\r\n\t\tthis.monitorOperType = monitorOperType;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic String toString() {\r\n\t\treturn new StringBuilder(\"MonitorCtrlInfo: \").append(\"instanceKey:\").append(instanceKey)\r\n\t\t\t\t.append(\",resourcceType:\").append(monitorResType).append(\",operateType:\")\r\n\t\t\t\t.append(monitorOperType).toString();\r\n\r\n\t}\r\n\r\n}\r\n\r\n2. enum class\r\npublic enum MonitorResourceType {\r\n\r\n\tALL, SQL, AOP, INTERFACE, HTTP, JEDIS, EJB\r\n}\r\n\r\npublic enum MonitorOperType {\r\n\r\n\tENABLE, DISABLE, RESET;\r\n}\r\n\r\n3. when I used kryo within jdk1.6 env to serialize MonitorCtrlBean  to be transferred to another application while in jdk1.8. I found that it could not be read. but the similar jdk1.8 (e.g jdk1.8.0_11 to jdk.1.8.0_51) or similiar jdk1.6 is OK. \r\n\r\nwhen I read the default serializers in kryo, I found there was no implicit support for enum class. so how to solve such problem. while I try to implement the serializer special for MonitorCtrlBean class like this (and also could not resolve the problem):\r\n\r\nprivate static class MonitorCtrlBeanSerializer extends Serializer<MonitorCtrlBean> {\r\n\r\n\t\t@Override\r\n\t\tpublic void write(Kryo kryo, Output output, MonitorCtrlBean object) {\r\n\t\t\toutput.writeString(object.getInstanceKey());\r\n\t\t\tkryo.writeClassAndObject(output, object.getMonitorResType());\r\n\t\t\tkryo.writeClassAndObject(output, object.getMonitorOperType());\r\n\t\t}\r\n\r\n\t\t@Override\r\n\t\tpublic MonitorCtrlBean read(Kryo kryo, Input input, Class<MonitorCtrlBean> type) {\r\n\t\t\tString instanceKey = input.readString();\r\n\t\t\tMonitorResourceType monitorResType = kryo.readObject(input, MonitorResourceType.class);\r\n\t\t\tMonitorOperType monitorOperType = kryo.readObject(input, MonitorOperType.class);\r\n\t\t\treturn new MonitorCtrlBean(instanceKey, monitorResType, monitorOperType);\r\n\t\t}\r\n\r\n\t}"},"comment":{"url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/comments/128555435","html_url":"https://github.com/EsotericSoftware/kryo/issues/333#issuecomment-128555435","issue_url":"https://api.github.com/repos/EsotericSoftware/kryo/issues/333","id":128555435,"user":{"login":"romix","id":1481811,"avatar_url":"https://avatars.githubusercontent.com/u/1481811?v=3","gravatar_id":"","url":"https://api.github.com/users/romix","html_url":"https://github.com/romix","followers_url":"https://api.github.com/users/romix/followers","following_url":"https://api.github.com/users/romix/following{/other_user}","gists_url":"https://api.github.com/users/romix/gists{/gist_id}","starred_url":"https://api.github.com/users/romix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romix/subscriptions","organizations_url":"https://api.github.com/users/romix/orgs","repos_url":"https://api.github.com/users/romix/repos","events_url":"https://api.github.com/users/romix/events{/privacy}","received_events_url":"https://api.github.com/users/romix/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T01:26:40Z","updated_at":"2015-08-07T01:26:40Z","body":"Also, have a look at:\r\nhttps://github.com/EsotericSoftware/kryo/blob/master/test/com/esotericsoftware/kryo/serializers/EnumNameSerializerTest.java\r\n\r\nand \r\n\r\nhttps://github.com/EsotericSoftware/kryo/blob/master/test/com/esotericsoftware/kryo/DefaultSerializersTest.java#L222-L262"}}