serializable

Java “Could Not Serialize the Data”

笑着哭i 提交于 2019-12-22 11:01:11
问题 I'm trying to get my clipboard to receive some custom data in a drag and drop. The custom data is another java type. This other type does implement serializable, so I'm really not sure why this isn't working. Any ideas are appreciated! imgView.setOnDragDetected(new EventHandler<MouseEvent>() { public void handle(MouseEvent event) { ClipboardContent content = new ClipboardContent(); content.put(dataFormat, RHSIconizedToken.this); Dragboard db = imgView.startDragAndDrop(TransferMode.ANY); db

How to pass a Bluetooth Socket to another Activity using Application interface

被刻印的时光 ゝ 提交于 2019-12-22 06:00:16
问题 so from what i gather, Socket connections are neither serializable or parcelable, but i need to pass a bluetooth connection to another Activity. i do not want to write a Service as a middle man, so please don't post this as a solution. i've heard that there is a way to pass these types of Objects using a custom Application interface, but i cannot, for the life of me, find a working example of this. i've seen plenty of documentation that says something to the effect of "this is possible" but

.NET Remoting, passing objects into methods

此生再无相见时 提交于 2019-12-22 04:15:33
问题 I am writing a .NET Remoting application. I have my dll, server, and client all working correctly. However, when I try to change my method call to take an object parameter instead of a simple type like an int, it complains with this error. Type System.Runtime.Remoting.ObjRef and the types from it (such as System.Runtime.Remoting.ObjRef) are not permitted to be deserialized at this security level. The method is something like this. public List<Orders> GetOrders(int UserID) { //Works public

When using ISerializable with DataContractSerializer, how do I stop the serializer from outputting type information?

China☆狼群 提交于 2019-12-22 03:22:27
问题 To get more control over serialization, I have converted a class from [DataContract] to [Serializable], implementing both GetObjectData and the special deserializing constructor. When I do this, the XML emitted now has type information applied to all elements. I don't want this superfluous information, and I'm wondering how to inform the serializer to not output it. Here's the sample code that uses [DataContract]: [DataContract(Namespace = "")] class Test { public Test() { } [DataMember]

ArrayList cannot be cast to custom class extending ArrayList

≯℡__Kan透↙ 提交于 2019-12-21 17:42:05
问题 I have class mentioned below: public class JsonHistoryList extends ArrayList<JsonHistory> implements Serializable{} I wish to pass it through intent using timerService.putExtra(TimerService.ACTIVITY_LIST_ARG, activities); But after I receive it (way below) JsonHistoryList temp = (JsonHistoryList) intent.getSerializableExtra(TimerService.ACTIVITY_LIST_ARG); in my service it gives me exception: Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.epstim.captime

When Java class is instance of Serializable

旧时模样 提交于 2019-12-21 14:06:11
问题 I wonder when Java Class is instance of Serializable. As I know class is serializable only if it implements Serializable interface. I'm trying to use junit to generate entity class (from some kind of template) and check if it is serializable. My generated class (which does NOT implement Serializable) looks like: package test; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import javax.annotation.Generated; import javax.persistence.Id; @Entity

Issue with declaration of Map<String,Class<? extends Serializable>>

断了今生、忘了曾经 提交于 2019-12-21 05:05:04
问题 Java provides me by <? extends class> a way of filtering the java classes that you can use to build in this case the new HashMap, for example: I can do that: Map<String,? extends Serializable> map1 = new HashMap<String,String>(); It is correct, because String implements Serializable, so the compiler let me do that. But when i try to do it: Map<String,GenericClass<? extends Serializable>> map2 = new HashMap<String, GenericClass<String>>(); Being the GenericClass as it: public class

Serialization Exception on spark

人走茶凉 提交于 2019-12-21 02:22:31
问题 I meet a very strange problem on Spark about serialization. The code is as below: class PLSA(val sc : SparkContext, val numOfTopics : Int) extends Serializable { def infer(document: RDD[Document]): RDD[DocumentParameter] = { val docs = documents.map(doc => DocumentParameter(doc, numOfTopics)) docs } } where Document is defined as: class Document(val tokens: SparseVector[Int]) extends Serializable and DocumentParameter is: class DocumentParameter(val document: Document, val theta: Array[Float]

Serialization Exception on spark

拈花ヽ惹草 提交于 2019-12-21 02:22:05
问题 I meet a very strange problem on Spark about serialization. The code is as below: class PLSA(val sc : SparkContext, val numOfTopics : Int) extends Serializable { def infer(document: RDD[Document]): RDD[DocumentParameter] = { val docs = documents.map(doc => DocumentParameter(doc, numOfTopics)) docs } } where Document is defined as: class Document(val tokens: SparseVector[Int]) extends Serializable and DocumentParameter is: class DocumentParameter(val document: Document, val theta: Array[Float]

de/serialize java objects across different applications using different package names

萝らか妹 提交于 2019-12-19 21:47:30
问题 I want to share java objects across different applications. As long as I use the same package names in the different projects it works fine. But if I change the package names it doesn't work anymore. I tried to solve this by extend the ObjectInputStream class and overriding the readClassDescriptor method. But by doing so I get the following error: java.io.StreamCorruptedException: invalid type code: 00 ... dont know how to solve this problem. Here is the code I use for the extended