<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://www.typea.info/tips_/index.php?action=history&amp;feed=atom&amp;title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96</id>
	<title>SJC-P 直列化 - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://www.typea.info/tips_/index.php?action=history&amp;feed=atom&amp;title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96"/>
	<link rel="alternate" type="text/html" href="https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;action=history"/>
	<updated>2026-04-21T04:51:40Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;diff=6596&amp;oldid=prev</id>
		<title>2020年2月16日 (日) 04:32にPirotoによる</title>
		<link rel="alternate" type="text/html" href="https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;diff=6596&amp;oldid=prev"/>
		<updated>2020-02-16T04:32:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2020年2月16日 (日) 04:32時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;1行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;1行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==SJC-P 直列化==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/ins&gt;SJC-P 直列化&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]]&lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/io/ObjectOutputStream.html&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/io/ObjectOutputStream.html&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;====親クラスが直列化不可、子クラスが直列化可の場合====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;====親クラスが直列化不可、子クラスが直列化可の場合====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l93&quot; &gt;93行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;93行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;----&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;----&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{include_html banner_html, &amp;quot;!Java&amp;quot;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{include_html &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/ins&gt;banner_html&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]]&lt;/ins&gt;, &amp;quot;!Java&amp;quot;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Piroto</name></author>
		
	</entry>
	<entry>
		<id>https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;diff=3662&amp;oldid=prev</id>
		<title>2020年2月15日 (土) 08:05にPirotoによる</title>
		<link rel="alternate" type="text/html" href="https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;diff=3662&amp;oldid=prev"/>
		<updated>2020-02-15T08:05:48Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2020年2月15日 (土) 08:05時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l86&quot; &gt;86行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;86行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  シリアライズ前 : 5,10&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  シリアライズ前 : 5,10&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  java.io.InvalidClassException: sjcp.serialize.SerializeDeriv; no valid constructor&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  java.io.InvalidClassException: sjcp.serialize.SerializeDeriv; no valid constructor&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    at java.io.ObjectStreamClass.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;&lt;/del&gt;init&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt;&lt;/del&gt;(ObjectStreamClass.java:428)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    at java.io.ObjectStreamClass.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;lt;&lt;/ins&gt;init&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;amp;gt;&lt;/ins&gt;(ObjectStreamClass.java:428)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1029)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1029)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Piroto</name></author>
		
	</entry>
	<entry>
		<id>https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;diff=2507&amp;oldid=prev</id>
		<title>Piroto: ページの作成:「==SJC-P 直列化==  http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/io/ObjectOutputStream.html  ====親クラスが直列化不可、子クラスが直列化可の場…」</title>
		<link rel="alternate" type="text/html" href="https://www.typea.info/tips_/index.php?title=SJC-P_%E7%9B%B4%E5%88%97%E5%8C%96&amp;diff=2507&amp;oldid=prev"/>
		<updated>2020-02-15T07:35:39Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「==SJC-P 直列化==  http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/io/ObjectOutputStream.html  ====親クラスが直列化不可、子クラスが直列化可の場…」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==SJC-P 直列化==&lt;br /&gt;
http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/io/ObjectOutputStream.html&lt;br /&gt;
====親クラスが直列化不可、子クラスが直列化可の場合====&lt;br /&gt;
&lt;br /&gt;
*直列化不可の親クラスは、子クラスが直列化しても親クラスの保持する情報は保存されない。&lt;br /&gt;
*子クラスのオブジェクトを復元するときには、親クラスのデフォルトコンストラクタにより、親クラスの情報が生成される。&lt;br /&gt;
*デフォルトコンストラクタが存在しない場合、java.io.InvalidClassException が投げられる&lt;br /&gt;
&lt;br /&gt;
'''UnSerializeSupper.java'''&lt;br /&gt;
&lt;br /&gt;
 package sjcp.serialize;&lt;br /&gt;
 &lt;br /&gt;
 import java.io.File;&lt;br /&gt;
 import java.io.FileInputStream;&lt;br /&gt;
 import java.io.FileOutputStream;&lt;br /&gt;
 import java.io.ObjectInputStream;&lt;br /&gt;
 import java.io.ObjectOutputStream;&lt;br /&gt;
 import java.io.Serializable;&lt;br /&gt;
 &lt;br /&gt;
 /**&lt;br /&gt;
  * java.io.Serializable を実装しない親クラス&lt;br /&gt;
  */&lt;br /&gt;
 public class UnSerializeSupper {&lt;br /&gt;
     protected Integer num1;&lt;br /&gt;
     &lt;br /&gt;
     /*&lt;br /&gt;
      * この親クラスは、直列化不可のため、子クラスが直列化しても親クラスの保持する情報は保存されない。&lt;br /&gt;
      * 子クラスのオブジェクトを復元するときには、親クラスのデフォルトコンストラクタにより、親クラスの情報が生成される。&lt;br /&gt;
      * デフォルトコンストラクタが存在しない場合、java.io.InvalidClassException が投げられる&lt;br /&gt;
      */&lt;br /&gt;
     public UnSerializeSupper() {&lt;br /&gt;
         num1 = new Integer(-1);&lt;br /&gt;
     }&lt;br /&gt;
     public UnSerializeSupper(int num) {&lt;br /&gt;
         num1 = new Integer(num);&lt;br /&gt;
     }&lt;br /&gt;
     public Integer getNumber() {&lt;br /&gt;
         return num1;&lt;br /&gt;
     }&lt;br /&gt;
     &lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         SerializeDeriv deriv = new SerializeDeriv(5);&lt;br /&gt;
         &lt;br /&gt;
         try {&lt;br /&gt;
             File serFile = new File(&amp;quot;c:\\work\\test.ser&amp;quot;);&lt;br /&gt;
             ObjectOutputStream writer&lt;br /&gt;
                 = new ObjectOutputStream(&lt;br /&gt;
                         new FileOutputStream(serFile));&lt;br /&gt;
         &lt;br /&gt;
             System.out.printf(&amp;quot;シリアライズ前 : %d,%d\n&amp;quot;, deriv.getNumber(),deriv.getNumber2());&lt;br /&gt;
             writer.writeObject(deriv);&lt;br /&gt;
         &lt;br /&gt;
             ObjectInputStream reader&lt;br /&gt;
                 = new ObjectInputStream(&lt;br /&gt;
                         new FileInputStream(serFile));&lt;br /&gt;
             &lt;br /&gt;
             SerializeDeriv d2 = (SerializeDeriv)reader.readObject();&lt;br /&gt;
             System.out.printf(&amp;quot;シリアライズ後 : %d,%d\n&amp;quot;, d2.getNumber(),d2.getNumber2());&lt;br /&gt;
         &lt;br /&gt;
         } catch (Exception e) {&lt;br /&gt;
             e.printStackTrace();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 /**&lt;br /&gt;
  * java.io.Serializable を実装した子クラス&lt;br /&gt;
  */&lt;br /&gt;
 class SerializeDeriv extends UnSerializeSupper implements Serializable {&lt;br /&gt;
     protected Integer num2;&lt;br /&gt;
 &lt;br /&gt;
     public SerializeDeriv(int num) {&lt;br /&gt;
         super(num);&lt;br /&gt;
         num2 = new Integer(num * 2);&lt;br /&gt;
     }&lt;br /&gt;
     public Integer getNumber2() {&lt;br /&gt;
         return num2;&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
=====実行結果=====&lt;br /&gt;
 シリアライズ前 : 5,10&lt;br /&gt;
 シリアライズ後 : -1,10&lt;br /&gt;
&lt;br /&gt;
=====実行結果(UnSerializeSupper クラスのデフォルトコンストラクタを削除)=====&lt;br /&gt;
UnSerializeSupper クラスのデフォルトコンストラクタを削除すると、子クラスの復元において例外となる。&lt;br /&gt;
 シリアライズ前 : 5,10&lt;br /&gt;
 java.io.InvalidClassException: sjcp.serialize.SerializeDeriv; no valid constructor&lt;br /&gt;
   at java.io.ObjectStreamClass.&amp;lt;init&amp;gt;(ObjectStreamClass.java:428)&lt;br /&gt;
   at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)&lt;br /&gt;
   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1029)&lt;br /&gt;
   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)&lt;br /&gt;
   at sjcp.serialize.UnSerializeSupper.main(UnSerializeSupper.java:42)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{{include_html banner_html, &amp;quot;!Java&amp;quot;}}&lt;/div&gt;</summary>
		<author><name>Piroto</name></author>
		
	</entry>
</feed>