CS140 Final Exam - Spring, 2012 - James S. Plank
Answers and Grading
Question 1
This is straight from the lecture notes. My code differs a little, but it's functionally
equivalent:
int Sudoku::Recursive_Solve(int r, int c)
{
int i, nr, nc;
if (r == 9) return 1;
nc = c+1;
nr = r;
if (nc == 9) { nc = 0; nr++; }
if (Grid[r][c] != ' ') return Recursive_Solve(nr, nc);
for (i = '1'; i <= '9'; i++) {
Grid[r][c] = i;
if (Is_Row_Valid(r) && Is_Col_Valid(c) &&
Is_Panel_Valid(r, c) && Recursive_Solve(nr, nc)) return 1;
}
Grid[r][c] = ' ';
return 0;
}
|
Grading
10 points. Basically, if you had the right code, you started with 10 points and were
deducted for errors. If you didn't have the right code, I assigned you the number of
points that I thought reflected how well you communicated to me that you understood
some of the principles.
Question 2
- Statement A: You can delete any node in a binary search tree: False
- Statement B: Destructors are called on local variables when their procedures
return: False
- Statement C: The only time you copy megabytes with an assignment statement is
when the two variables are objects, not pointers to objects. Pointers just copy pointers: True
- Statement D: See the lecture notes -- statement H is the correct one: False
- Statement E: Exactly: True
- Statement F: See the lecture notes on big-O: True
- Statement G: That's the whole point of B-Trees: Nodes are stored in disk blocks,
and disk reads are expensive. Searching for keys is fast: True
- Statement H: See Statement D: True
- Statement I: One child has to have height h-1. The other may have height
h-1 or h-2: False
- Statement J: Nope, it's an inorder traversal: False
- Statement K: All leaf nodes are the same distance from the root, so this one is: True
- Statement L: Gotta think about this -- log2(f(n)) is less than f(n). Therefore, (f(n) + log2(f(n))) is less than 2f(n). So,
by Statement F, this is: True
- Statement M: Definition of B-Trees: False
- Statement N: They are both O(log2(n)): False
- Statement O: If it's not balanced, this is: True
Grading
One point per question.
Question 3
Part A: No rebalancing required:
Part B: On this one, you need to rebalance:
Part C: On this one, you need to rebalance too, but it's more subtle, as the
imbalance is higher up the tree:
Grading
Two points for part A, and three for each of the other trees.
Question 4
Part A: There are imbalances at nodes I and K.
Part B: There are two legal answers. Either
you recursively delete I and replace J with I, or
you recursively delete K and replace J with K:
Grading
Three points for Part A. To receive full credit, you had to specify a
node that was imbalanced. Also, three points for Part B.
Question 5
Part A: When you delete F, node G is imbalanced, and
the rebalancing required is a Zig-Zag: Double Rotate About H. The
resulting tree will be balanced.
Part B: When you delete B, you replace it with A.
Node E is imbalanced, and
the rebalancing required is a Zig-Zig: Rotate About G. The
resulting tree will be balanced.
Part C: When you delete L, node M is imbalanced, and you
must perform a double rotation about N. When that's done, node K
is imbalanced, and that too is a Zig-Zag, requiring a double rotation about G.
Thus, the answer is:
- Rotate about N.
- Rotate about N.
- Rotate about G.
- Rotate about G.
Grading
- 2 points for Part A.
- 2 points for Part B.
- 4 points for Part C.
You lost a point per part if you drew me trees rather than specifying
rotations, and you had to give me the correct tree.
Question 6
You read each team into a vector of names. Then you sort the vector and construct a
string from the vector, which contains each name in sorted order separated by a
space (or a colon, or any other non-lowerspace letter). That string becomes a key
that you insert into a set. Since you don't insert duplicate keys into a set, whenever
you try to insert the same team into the set twice, the second insertion fails.
Thus, the size of the set is the number of unique teams:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
main()
{
set <string> teams;
vector <string> team;
string key, n;
int i;
while (1) {
team.clear();
for (i = 0; i < 7; i++) {
if (cin >> n) {
team.push_back(n);
} else {
cout << teams.size() << endl;
exit(0);
}
}
sort(team.begin(), team.end());
key = "";
for (i = 0; i < 7; i++) {
key += team[i];
key += " ";
}
teams.insert(key);
}
}
|
Obviously, you only need one string, but two make it clearer.
Grading
This one was 15 points. As with question 1, you either started with 15 and
were deducted, or your answer was off-base, and I assigned partial credit according
to how well you communicated to me that you could do various parts of this.
If you gave me an n2 solution, you received half credit.


Class Cutter
Version
1.0.
Cutter
Defined in: Cutter.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Cutter()
Cutter is a class that allows HTML code to cut a number of words contained in the nodes, keeping intact the HTML markup.
|
| Field Attributes | Field Name and Description |
|---|---|
|
bNeedViewMore is a property that will check it it's necessary to add the link to view more or not
It checks if its necessary if for some reason the content is cutted.
|
|
|
bNotViewMore is a property that could be setted by the user to add or not the link to view more content if needed.
|
|
|
bTest is a property to now if you want to test the Cutter class
This is used to change the type of id for each element.
|
|
|
nIdTest is the property for testing that will save the order for id.
|
|
|
nWords is the number of words to Cut
|
|
|
nWordsCounter is the counter of words when finding them in code
|
|
|
oApplyTo is the Dom object where we want to use the cutter.
|
|
|
oBackupApplyTo is the clone from Dom object to get it when showing the content.
|
|
|
oClasses is the config singleton for classes used in Cutter
|
|
|
oDocumentFragment is the DocumentFragment where the Dom elements are inserted before insert on Target
|
|
|
oSerialized is the JSON object where Cutter serializes all the DOM objects inside the oApplyTo Dom element
|
|
|
oTarget is the Dom object where to put the cutted code
|
|
|
oTexts is the config singleton for texts used in Cutter
|
|
|
oViewMore is a reference to the "see more" link.
|
| Method Attributes | Method Name and Description |
|---|---|
| <private> |
_countWords(sText)
_countWords is an utilities method used to count the words in a String
|
| <private> |
_getFirstElementOfObject(oObject)
_getFirstElementOfObject is an utilities method used to get the first element in a JSON object
|
| <private> |
_getOnlyNumberOfWords(sString, nWords)
_getOnlyNumberOfWords is an utilities method used to get a number of words from the string
|
| <private> |
_trim(sString)
_trim is an utilities method used to keep out all the spaces before or after the sentence
|
| <private> |
addEvent(oElement, sType, fpCallback)
addEvent is the wrapper method to add a new event to the element
|
|
applyTo(oApplyTo)
applyTo is the method that sets the Dom object where to apply the cutter
|
|
| <private> |
createViewMore is the method that creates the link to see all the content again
|
| <private> |
deserializeObject(oSerialized, oParent)
deserializeObject is an utilities method used to deserialize a JSON object in a Dom element
|
| <private> |
deserializeSerializedObject(oSerialized, oParent)
deserializeSerializedObject is an utilities method used to deserialize all the Dom elements that where serialized and is where the cut is applied.
|
|
init()
init is the method that makes all the work.
|
|
| <private> |
loopOnDeserialize(oSerializedElements, oParent)
loopOnDeserialize is an utilities method used to loop over all the serialized elements
|
| <static> |
Cutter.run(oApplyTo, oTarget, nWords, oTexts, oClasses)
run is the static method to make API simple.
|
| <private> |
serializeDomObject(oDom, oSerializeObject)
serializeDomObject is an utilities method used to serialize all the Dom elements in a JSON object
This method is the brain of the class.
|
| <private> |
setBehaviour is the method that applies the behaviour to the "see more" link to get the full content again when makink click on it
|
|
setClasses(oClasses)
setClasses is the method that sets the config singleton of Classes used in Cutter
|
|
|
setTarget(oTarget)
setTarget is the method that sets the Dom object where to put the cutted code
|
|
|
setTexts(oTexts)
setTexts is the method that sets the config singleton of Texts used in Cutter
|
|
|
setWords(nWords)
setWords is the method used to set the max number of words before cut the code.
|
|
| <private> |
showAll()
showAll is the method that put the initial content to the target Dom element
|
Class Detail
Cutter()
Cutter is a class that allows HTML code to cut a number of words contained in the nodes, keeping intact the HTML markup.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
Field Detail
{Boolean}
bNeedViewMore
bNeedViewMore is a property that will check it it's necessary to add the link to view more or not
It checks if its necessary if for some reason the content is cutted.
false by default.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Boolean}
bNotViewMore
bNotViewMore is a property that could be setted by the user to add or not the link to view more content if needed.
false by default.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Boolean}
bTest
bTest is a property to now if you want to test the Cutter class
This is used to change the type of id for each element.
false by default.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Number}
nIdTest
nIdTest is the property for testing that will save the order for id.
0 by default.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Number}
nWords
nWords is the number of words to Cut
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Number}
nWordsCounter
nWordsCounter is the counter of words when finding them in code
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oApplyTo
oApplyTo is the Dom object where we want to use the cutter.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oBackupApplyTo
oBackupApplyTo is the clone from Dom object to get it when showing the content.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oClasses
oClasses is the config singleton for classes used in Cutter
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oDocumentFragment
oDocumentFragment is the DocumentFragment where the Dom elements are inserted before insert on Target
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oSerialized
oSerialized is the JSON object where Cutter serializes all the DOM objects inside the oApplyTo Dom element
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oTarget
oTarget is the Dom object where to put the cutted code
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oTexts
oTexts is the config singleton for texts used in Cutter
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
oViewMore
oViewMore is a reference to the "see more" link.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
Method Detail
<private>
{Number}
_countWords(sText)
_countWords is an utilities method used to count the words in a String
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {string} sText
- The text where to know how many words are.
- Returns:
- the number of words in the string
<private>
{Object}
_getFirstElementOfObject(oObject)
_getFirstElementOfObject is an utilities method used to get the first element in a JSON object
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oObject
- The JSON object from which to obtain the first element
- Returns:
- the first element in the JSON object
<private>
{Number}
_getOnlyNumberOfWords(sString, nWords)
_getOnlyNumberOfWords is an utilities method used to get a number of words from the string
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {string} sString
- The text from which to extract the words
- {number} nWords
- The number of words to get
- Returns:
- the number of words in the string
<private>
{String}
_trim(sString)
_trim is an utilities method used to keep out all the spaces before or after the sentence
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {string} sString
- This is the text to be trimmed
- Returns:
- the trimmed string
<private>
addEvent(oElement, sType, fpCallback)
addEvent is the wrapper method to add a new event to the element
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {DOM} oElement
- {String} sType
- {Function} fpCallback
{Object}
applyTo(oApplyTo)
applyTo is the method that sets the Dom object where to apply the cutter
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oApplyTo
- This is the Dom element
- Returns:
- the instance of the Cutter
<private>
createViewMore()
createViewMore is the method that creates the link to see all the content again
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
<private>
deserializeObject(oSerialized, oParent)
deserializeObject is an utilities method used to deserialize a JSON object in a Dom element
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oSerialized
- The JSON object from which to obtain the Dom element information
- {object} oParent
- The Dom element where to add the new Dom element
<private>
deserializeSerializedObject(oSerialized, oParent)
deserializeSerializedObject is an utilities method used to deserialize all the Dom elements that where serialized and is where the cut is applied.
This method is the core of the class.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oSerialized
- The JSON object to deserialize
- {object} oParent
- The DOM object where to put the new finished code.
init()
init is the method that makes all the work.
Serialize the Dom.
Deserialize the JSON object to Dom elements only with the words that were wanted
Remove the firstChild in oDocumentFragment because this node is the oApplyTo content.
Clean the content on oTarget.
Create the "see more" link
Append the "see more" link to the oDocumentFragment.
Insert the oDocumentFragment content in the oTarget element
At least the behaviour is applied to the link to make possible to get the original content before the cut.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
<private>
loopOnDeserialize(oSerializedElements, oParent)
loopOnDeserialize is an utilities method used to loop over all the serialized elements
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oSerializedElements
- The JSON object on which to run the loop
- oParent
<static>
Cutter.run(oApplyTo, oTarget, nWords, oTexts, oClasses)
run is the static method to make API simple.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {DOM} oApplyTo
- {DOM} oTarget
- {Number} nWords
- {Object} oTexts
- {Object} oClasses
<private>
serializeDomObject(oDom, oSerializeObject)
serializeDomObject is an utilities method used to serialize all the Dom elements in a JSON object
This method is the brain of the class.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oDom
- The Dom element to serialize
- {object} oSerializeObject
- The JSON object where to serialize the Dom element
<private>
setBehaviour()
setBehaviour is the method that applies the behaviour to the "see more" link to get the full content again when makink click on it
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
{Object}
setClasses(oClasses)
setClasses is the method that sets the config singleton of Classes used in Cutter
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oClasses
- This is the singleton config
- Returns:
- the instance of the Cutter
{Object}
setTarget(oTarget)
setTarget is the method that sets the Dom object where to put the cutted code
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oTarget
- This is the Dom element
- Returns:
- the instance of the Cutter
{Object}
setTexts(oTexts)
setTexts is the method that sets the config singleton of Texts used in Cutter
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {object} oTexts
- This is the singleton config
- Returns:
- the instance of the Cutter
{Object}
setWords(nWords)
setWords is the method used to set the max number of words before cut the code.
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.
- Parameters:
- {number} nWords
- This is the number of words to see.
- Returns:
- the instance of the Cutter
<private>
showAll()
showAll is the method that put the initial content to the target Dom element
Author: Tomas Corral Casas.
Author: Tomas Corral Casas.


2 items
Shopping cart
Item
Quantity
Price
Coastal Harness
1 item - Remove
U$ 21,90
Total U$51,98
Total U$ 51,98
You might also like:


This is Jim Tomic. Here is some text about him. It is placed in the second cell of the first row !
This is Carl Buck. His information is placed in the first cell of the second row.


These terms and conditions ("Terms of Service") govern your access to and use of Social Media Frontiers Limited SLA's ("Twadar") products, software, services, and web site (collectively "Services"), and any and all information, text, graphics, photos or other materials uploaded, downloaded, or appearing on the Services (collectively "Content"). By accessing and using the Services, you are agreeing to be bound by these Terms of Service. If you do not agree to be bound by these Terms of Service, you are not allowed to use the Services. Wherever used in these Terms of Service, "you", "your" or similar terms mean the person or legal entity utilizing or accessing the Services.
Social Media Frontiers Limited SLA may update and change the Terms of Service from time to time without notice. Continued use of the Service after any such changes shall constitute your consent to such changes. You are responsible for regularly reviewing the most current version of the Terms of Service.
These Terms of Service include Social Media Frontiers Limited SLA's privacy policy. By accessing and using the Services you are consenting to (or promising that you have obtained appropriate consent for) the collection and use of personal information by Social Media Frontiers Limited SLA in accordance with the privacy policy of Social Media Frontiers Limited SLA.
  Social Media Frontiers Limited SLA DOES NOT MAKE ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS ABOUT THE QUALITY, ACCURACY, SECURITY, RELIABILITY, COMPLETENESS, QUIET ENJOYMENT, CURRENCY, OR TIMELINESS OF THE SERVICES.
 TO THE FULLEST EXTENT PERMISSIBLE PURSUANT TO APPLICABLE LAW.


原文地址：Chapter 7 of Inside the Java Virtual Machine
The previous chapter described in detail the format of the Java class file, the standard binary form for representing Java types.
This chapter looks at what happens when binary type data is imported into a Java virtual machine.
The chapter follows the lifetime of a type (class or interface) from the type's initial entrance into the virtual machine to its ultimate exit.
It discusses the processes of loading, linking, and initialization that occur at the beginning of a type's lifetime;
the processes of object instantiation, garbage collection, and finalization that can occur in the prime of a type's lifetime;
and the unloading that can occur at the end of a type's lifetime.
本章要讲的内容有哪些
Type Loading, Linking, and Initialization
The Java virtual machine makes types available to the running program through a process of loading, linking, and initialization.
Loading is the process of bringing a binary form for a type into the Java virtual machine.
Linking is the process of incorporating the binary type data into the runtime state of the virtual machine.
Linking is divided into three sub-steps: verification, preparation, and resolution.
Verification ensures the type is properly formed and fit for use by the Java virtual machine.
Preparation involves allocating memory needed by the type, such as memory for any class variables.
Resolution is the process of transforming symbolic references in the constant pool into direct references.
Implementations may delay the resolution step until each symbolic reference is actually used by the running program.
After verification, preparation, and (optionally) resolution are completed, the type is ready for initialization.
During initialization, the class variables are given their proper initial values.
See Figure 7-1 for a graphical depiction of this process.
对loading、linking和initialization进行介绍。
Figure 7-1. The beginning of a type's lifetime.
As you can see from Figure 7-1, the processes of (1) loading, (2) linking, and (3) initialization must take place in that order.
The only exception to this required ordering is the third phase of linking, resolution,
which may optionally take place after initialization.
触发顺序
The Java virtual machine specification gives implementations flexibility
in the timing of class and interface loading and linking, but strictly defines the timing of initialization.
All implementations must initialize each class or interface on its first active use.
The following six situations qualify as active uses:
这里讲了initialization和active use的关系。不管是class，还是interface，只要进行了active use，就要进行initialization
-
A new instance of a class is created (in bytecodes, the execution of a
new
instruction. Alternatively, via implicit creation, reflection, cloning, or deserialization.) -
The invocation of a static method declared by a class (in bytecodes, the execution of an
invokestatic
instruction) -
The use or assignment of a static field declared by a class or interface,
except for static fields that are
final
and initialized by a compile-time constant expression (in bytecodes, the execution of agetstatic
orputstatic
instruction) -
The invocation of certain reflective methods in the Java API,
such as methods in class
Class
or in classes in thejava.lang.reflect
package - The initialization of a subclass of a class (Initialization of a class requires prior initialization of its superclass.)
-
The designation of a class as the initial class
(with the
main()
method) when a Java virtual machine starts up
All other uses of a type besides the six listed here are passive uses,
which don't trigger an initialization of the type.
Several examples illustrating the difference between active and passive uses are given later in this chapter.
active use + passive use
As mentioned in the previous list, initialization of a class requires prior initialization of its superclass.
Applied recursively, this rule means that all of a class's superclasses must be initialized prior to the initialization of the class.
The same is not true, however, of interfaces.这对于接口来说，不成立
An interface is initialized only because a non-constant field declared by the interface is used,
never because a subinterface or class that implements the interface needs to be initialized.
Thus, initialization of a class requires prior initialization of all its superclasses, but not its superinterfaces.
Initialization of an interface does not require initialization of its superinterfaces.
对于class和interface来说，initialization的要求是不一样的。
The "initialize on first active use" rule drives the mechanism that loads, links, and initializes classes.
On its first active use, a type must be initialized.
Before it can be initialized, however, it must be linked.
And before it can be linked, it must be loaded.
At their option, implementations may load and link types early.
They need not wait until the type's first active use to load and link the type.
If a type hasn't been loaded and linked before its first active use, however,
it must be loaded and linked at that time, so that it can be initialized.
active use对于loading、linking和initialization的影响。
Loading
The loading process consists of three basic activities. To load a type, the Java virtual machine must:
- given the type's fully qualified name, produce a stream of binary data that represents the type
- parse the stream of binary data into internal data structures in the method area
-
create an instance of class
java.lang.Class
that represents the type
The stream of binary data may adhere to the Java class file format, but could alternatively follow some other format.
As mentioned in previous chapters, all Java virtual machine implementations must recognize the Java class file format,
but individual implementations may also recognize other binary formats.
binary data要遵循Java class file format
The Java virtual machine specification does not say how the binary data for a type must be produced.
Some potential ways to produce binary data for a type are:
- load a Java class file from the local file system
- download a Java class file across a network
- extract a Java class file from a ZIP, JAR, CAB, or other archive file
- extract a Java class file from a proprietary database
- compile a Java source file on the fly into the class file format
- compute the class file data for a type on the fly
- any of the above, but using a binary file format other than the Java class file
Given the binary data for a type, the Java virtual machine must process that data to a great enough extent
that it can create an instance of class java.lang.Class
.
The virtual machine must parse the binary data into implementation-dependent internal data structures.
(See Chapter 5, "The Java Virtual Machine," for a discussion of potential internal data structures for storing class data.)
The Class
instance, the end product of the loading step,
serves as an interface between the program and the internal data structures.这个想法，我之前没有意识到。
To access information about a type that is stored in the internal data structures,
the program invokes methods on the Class
instance for that type.
Together, the processes of parsing the binary data for a type into internal data structures in the method area and
instantiating a Class
object on heap are called creating the type.
这段很重要，值得一读。
As described in previous chapters, types are loaded either through the bootstrap class loader or through user-defined class loaders.
The bootstrap class loader, a part of the virtual machine implementation, loads types (including the classes and interfaces of the Java API) in an implementation-dependent way.
User-defined class loaders, instances of subclasses of java.lang.ClassLoader
, load classes in custom ways.
The inner workings of user-defined class loaders are described in more detail later in Chapter 8, "The Linking Model."
引出class loader
Class loaders (bootstrap or user-defined) need not wait until a type's first active use before they load the type.
Class loaders are allowed to cache binary representations of types, load types early in anticipation of eventual use, or load types together in related groups.
If a class loader encounters a problem during early loading, however,
it must report that problem (by throwing a subclass of LinkageError
) only upon the type's first active use.
In other words, if a class loader encounters a missing or malformed class file during early loading,
it must wait to report that error until the class's first active use by the program.
If the class is never actively used by the program, the class loader will never report the error.
这套方式，可能只适合于JVM当中使用，不适合于人类社会。
Verification
After a type is loaded, it is ready to be linked.
The first step of the linking process is verification--
ensuring that the type obeys the semantics of the Java language and
that it won't violate the integrity of the virtual machine.
进入linking的verification阶段
Verification is another area in which implementations of the Java virtual machine have some flexibility.
Implementation designers can decide how and when to verify types.
The Java virtual machine specification lists all the exceptions that a virtual machine can throw and under what circumstances it must throw them.
No matter what kind of trouble a Java virtual machine might encounter, there is an exception or error it is supposed to throw.
The specification says what exception or error should be thrown in each situation.
In some cases, the specification says exactly when the exception or error should be thrown,
but usually doesn't dictate precisely how or when the error condition should be detected.
检测出错误时机是灵活的，而报告错误的时机是由JVM specification来规定的。
Nevertheless, certain kinds of checks are very likely to take place at certain times in most Java virtual machine implementations.
For example, during the loading process, the virtual machine must parse the stream of binary data that represents the type and build internal data structures.
At this point, certain checks will have to be done just to ensure the initial act of parsing the binary data won't crash the virtual machine.
During this parsing, implementations will likely check the binary data to make sure it has the expected overall format.
Parsers of the Java class file format might check the magic number,
make sure each component is in the right place and of the proper length,
verify that the file isn't too short or too long, and so on.
Although these checks take place during loading, before the official verification phase of linking,
they are still logically part of the verification phase.
The entire process of detecting any kind of problem with loaded types is placed under the category of verification.
verification是一个“逻辑”上的概念，有些检查是发生在loading阶段。
Another check that likely occurs during loading is making sure that every class except Object
has a superclass.
This may be done during loading because when the virtual machine loads a class,
it must also make sure all of the class's superclasses are loaded also.
The only way a virtual machine can know the name of a given class's superclass is by peering into the binary data for the class.
Since the virtual machine is looking at every class's superclass data during loading anyway,
it may as well make this check during the loading phase.
verification，有的部分比较早。例如，在loading过程中，检查superclass信息。
Another check--one that likely occurs after the official verification phase in most implementations--
is the verification of symbolic references.
As described in earlier chapters, the process of dynamic linking involves locating classes, interfaces, fields, and methods
referred to by symbolic references stored in the constant pool, and replacing the symbolic references with direct references.
When the virtual machine searches for a symbolically referenced entity (type, field, or method), it must first make sure the entity exists.
If the virtual machine finds that the entity exists,
it must further check that the referencing type has permission to access the entity, given the entity's access permissions.
These checks for existence and access permission are logically a part of verification, the first phase of linking,
but most likely happen during resolution, the third phase of linking.
Resolution itself can be delayed until each symbolic reference is first used by the program,
so these checks may even take place after initialization.
verification，有的部分比较晚。例如，在resolution过程中，检查symbolic reference信息。
So what gets checked during the official verification phase?
Anything that hasn't already been checked before the official verification phase and that won't get checked after it.
Here are two lists of some of the things that are good candidates for checking during the official verification phase.
This first list is composed of checks that ensure classes are binary compatible with each other:
那么，在official verification阶段，会检查哪些东西呢？
- checking that final classes are not subclassed
- checking that final methods are not overridden
- making sure no incompatible method declarations (such as two methods that have the same name, the same number, order, and types of parameters, but different return types) appear between the type and its supertypes
Note that while these checks require looking at other types, they only require looking at supertypes.
Superclasses need to be initialized before subclasses, so these classes are likely already loaded.
Superinterfaces do not need to be initialized when a class that implements them is initialized.
However, superinterfaces must be loaded when the class that implements them (or the interface that extends them) is loaded.
(They won't be initialized, just loaded and possibly linked at the option of the virtual machine implementation.)
All a class's supertypes will be loaded when the class is loaded.
At verification time, the class and all its supertypes will be to make sure they are all still binary compatible with one another.
这里讲load和initialize的关系
-
checking that all constant pool entries are consistent with each other.
(For example, the
string_index
item of aCONSTANT_String_info
entry must be the index of aCONSTANT_Utf8_info
entry.) - checking that all special strings contained in the constant pool (class names, field and method names, field and method descriptors) are well-formed
- verifying the integrity of the bytecodes
The most complicated task in the above list is the last one: bytecode verification.
All Java virtual machines must in some way verify the integrity of the bytecodes for every method they execute.
For example, implementations are not allowed to crash because a jump instruction sends the virtual machine beyond the end of a method.
They must detect that the jump instruction is invalid through some process of bytecode verification, and throw an error.
在verification阶段，最难的部分是进行bytecode verification
Java virtual machine implementations are not required to verify bytecodes during the official verification phase of linking.并没有明确要求，一定在official verification阶段完成
Implementations are free, for example, to verify individual instructions as each instruction is executed.
One of the design goals of the Java virtual machine instruction set, however, was that
it yield bytecodes streams that can be verified all at once by a data flow analyzer.
The ability to verify bytecode streams all at once during linking, rather than on the fly as the program runs,
gives a big boost to the potential execution speed of Java programs.
对bytecode verification进一步详细说明。
When verifying bytecodes via a data flow analyzer, the virtual machine may have to load other classes to
ensure that the semantics of the Java language are being followed.
For example, imagine a class contained a method
that assigned a reference to an instance of java.lang.Float
to a field of type java.lang.Number
.
In this case, the virtual machine would have to load class Float
during bytecode verification
to make sure it was a subclass of class Number
.
It would have to load Number
to make sure it wasn't declared final.
The virtual machine must not initialize class Float
at this time, just load it.
Float
will be initialized only upon its first active use.
这里引出了data flow analyzer
For more information on the class verification process, see Chapter 3, "Security."
Preparation
After a Java virtual machine has loaded a class and performed whatever verification it chooses to do up front,
the class is ready for preparation.
During the preparation phase, the Java virtual machine allocates memory for the class variables and sets them to default initial values.
The class variables are not initialized to their proper initial values until the initialization phase.
(No Java code is executed during the preparation step.)
During preparation, the Java virtual machine sets the newly allocated memory for the class variables to a default value determined by the type of the variable.
The default values for the various types are shown in Table 7-1.
这里开始介绍linking的preparation阶段
| Type | Initial Value |
|---|---|
int |
0 |
long |
0L |
short |
(short) 0 |
char |
'\u0000' |
byte |
(byte) 0 |
boolean |
false |
reference |
null |
float |
0.0f |
double |
0.0d |
Table 7-1. Default initial values for the primitive and reference types
Although the boolean
type appears in Table 7-1, the Java virtual machine itself has very little support for boolean
s.
Internally, boolean
is usually implemented as an int
, which gets set to zero (boolean false
) by default.
Therefore, boolean
class variables, even if they are implemented internally as int
s, are initialized to false
.
这里对boolean类型进行特殊说明
During the preparation phase, Java virtual machine implementations may also allocate memory for data structures
that are intended to improve the performance of the running program.
An example of such a data structure is a method table,
which contains a pointer to the data for every method in a class, including those inherited from its superclasses.
A method table enables an inherited method to be invoked on an object without a search of superclasses at the point of invocation.
Method tables are described in more detail in Chapter 8, "The Linking Model."
在preparation阶段，还会为method table分配内存空间。
Resolution
After a type has been through the first two phases of linking: verification and preparation,
it is ready for the third and final phase of linking: resolution.
Resolution is the process of locating classes, interfaces, fields, and methods referenced symbolically from a type's constant pool,
and replacing those symbolic references with direct references.
As mentioned above, this phase of linking is optional
until (and unless) each symbolic reference is first used by the program.
Resolution is described in detail in Chapter 8, "The Linking Model."
这里讲linking中的resolution阶段
Initialization
The final step required to ready a class or interface for its first active use is initialization,
the process of setting class variables to their proper initial values.
As used here, a "proper" initial value is the programmer's desired starting value for a class variable.
A proper initial value contrasts with the default initial value given to class variables during preparation.
As described above, the virtual machine assigns default values based only on each variable's type.
Proper initial values, by contrast, are based on some master plan known only to the programmer.
开始介绍initialization，重点说了default initial value和proper initial value的区别。
In Java code, a proper initial value is specified via a class variable initializer or static initializer.
A class variable initializer is an equals sign and expression next to a class variable declaration, as in:
// On CD-ROM in file classlife/ex1/Example1a.java class Example1a { // "= 3 * (int) (Math.random() * 5.0)" is the class variable initializer static int size = 3 * (int) (Math.random() * 5.0); }
A static initializer is a block of code introduced by the static
keyword, as in:
// On CD-ROM in file classlife/ex1/Example1b.java class Example1b { static int size; // This is the static initializer static { size = 3 * (int) (Math.random() * 5.0); } }
All the class variable initializers and static initializers of a type are collected by the Java compiler and placed into one special method.
For classes, this method is called the class initialization method;
for interfaces, the interface initialization method.
In Java class files for both classes and interfaces, this method is named "<clinit>
".
Regular methods of a Java application cannot invoke a <clinit>
method.
This kind of method can only be invoked by the Java virtual machine,
which invokes it to set a type's static variables to their proper initial values.
这里介绍class initialization method。
Initialization of a class consists of two steps:
- Initializing the class's direct superclass (if any), if the direct superclass hasn't already been initialized
- Executing the class's class initialization method, if it has one
When initializing a class's direct superclass, the same two steps listed above must be followed.
As a result, the first class that will be initialized will always be Object
,
then all the classes on down the inheritance hierarchy to the class being actively used.
Superclasses will be initialized before subclasses.
父类要比子类先进行initialization。
Initialization of an interface does not require initialization of its superinterfaces.
Initialization of an interface consists of only one step:
这里讲接口的initialization
- Executing the interface's interface initialization method, if it has one
The code of a <clinit>()
method does not explicitly invoke a superclass's <clinit>()
method.
Before a Java virtual machine invokes the <clinit>()
method of a class, therefore,
it must make certain the <clinit>()
methods of superclasses have been executed.
由JVM来调用<clinit>()方法。
Java virtual machines must also make sure the initialization process is properly synchronized.
If multiple threads need to initialize a class, only one thread should be allowed to perform the initialization while the other threads wait.
After the active thread completes the initialization process, it must notify any waiting threads.
See Chapter 20, "Thread Synchronization," for information about synchronization, wait and notify.
这里讲只能有一个thread来进行initialization操作。
The <clinit>() Method
As mentioned above, Java compilers place the code for class variable initializers and static initializers into
the <clinit>()
method of the class file in the order
in which they appear in the class or interface declaration.
For example, given this class:
<clinit>()方法里instruction出现的顺序与写代码的顺序密切相关。
// On CD-ROM in file classlife/ex1/Example1c.java class Example1c { static int width; static int height = (int) (Math.random() * 2.0); // This is the static initializer static { width = 3 * (int) (Math.random() * 5.0); } }
The Java compiler generates the following <clinit>()
method:
// The code for height's class variable initializer begins here // Invoke Math.random(), which will push // a double return value 0 invokestatic #6 <Method double random()> 3 ldc2_w #8 <Double 2.0> // Push double constant 2.0 6 dmul // Pop two doubles, multiply, push result 7 d2i // Pop double, convert to int, push int // Pop int, store into class variable // height 8 putstatic #5 <Field int height> // The code for the static initializer begins here 11 iconst_3 // Push int constant 3 // Invoke Math.random(), which will push // a double return value 12 invokestatic #6 <Method double random()> 15 ldc2_w #10 <Double 5.0> // Push double constant 5.0 18 dmul // Pop two doubles, multiply, push result 19 d2i // Pop double, convert to int, push int 20 imul // Pop two ints, multiply, push int result // Pop int, store into class variable // width 21 putstatic #7 <Field int width> 24 return // Return void from <clinit> method
This <clinit>()
method first executes the code for Example1c
's only class variable initializer,
which initializes height
, then executes the code for the static initializer, which initializes width
.
The initialization is done in this order because the class variable initializer appears textually before the static initializer in the source code of the Example1c
class.
Not all classes will necessarily have a <clinit>()
method in their class file.
If a class declares no class variables or static initializers, it won't have a <clinit>()
method.第1种情况，不生成
If a class declares class variables, but doesn't explicitly initialize them with class variable initializers or static initializers,
it won't have a <clinit>()
method.第2种情况，不生成
If a class contains only class variable initializers for static final variables,
and those class variable initializers use compile-time constant expressions,
that class won't have a <clinit>()
method.第3种情况，不生成
Only those classes that actually require Java code to be executed to initialize class variables to proper initial values will have a class initialization method.
这里讲生成<clinit>()方法的情况。
Here's an example of a class that won't be awarded a <clinit>()
method by the Java compiler:
// On CD-ROM in file classlife/ex1/Example1d.java class Example1d { static final int angle = 35; static final int length = angle * 2; }
Class Example1d
declares two constants, angle
and length
,
and initializes them with expressions that are compile-time constants.
The compiler knows that angle
represents the value 35 and length
represents the value 70.
When the Example1d
class is loaded by a Java virtual machine,
angle
and length
are not stored as class variables in the method area.不在method area中占用内存空间。
As a result, no <clinit>()
method is needed to initialize them.
The angle
and length
fields are not class variables,
they are constants, which are treated specially by the Java compiler.
Instead of treating Example1d
's angle
and length
fields as class variables,
the Java compiler places the constant int
values they represent into
the constant pool or bytecode streams of any class that uses them.本段重点
For example, if a class uses Example1d
's angle
field,
that class will not have in its constant pool a symbolic reference to the angle
field of class Example1d
.
Instead, the class will have operands embedded in its bytecode streams that have the value 35.
If the constant value of angle
were outside the range of a short
(-32,768 to 32,767), say 35,000,
the class would have a CONSTANT_Integer_info
entry in its constant pool with the value of 35,000.
Here's a class that uses both a constant and a class variable from other classes:
// On CD-ROM in file classlife/ex1/Example1e.java class Example1e { // The class variable initializer for symbolicRef uses a symbolic // reference to the size class variable of class Example1a static int symbolicRef = Example1a.size; // The class variable initializer for localConst doesn't use a // symbolic reference to the length field of class Example1d. // Instead, it just uses a copy of the constant value 70. static int localConst = Example1d.length * (int) (Math.random() * 3.0); }
The Java compiler generates the following <clinit>()
method for class Example1e:
// The code for symbolicRef's class variable initializer begins here: // Push int value from Example1a.size. // This getstatic instruction refers to a // symbolic reference to Example1a.size. 0 getstatic #9 <Field int size> // Pop int, store into class variable // symbolicRef 3 putstatic #10 <Field int symbolicRef> // The code for localConst's class variable intializer begins here: // Expand byte operand to int, push int // result. This is the local copy of 6 bipush 70 // Example1d's length constant, 70. // Invoke Math.random(), which will push // a double return value 8 invokestatic #8 <Method double random()> 11 ldc2_w #11 <Double 3.0> // Push double constant 3.0 14 dmul // Pop two doubles, multiply, push result 15 d2i // Pop double, convert to int, push int 16 imul // Pop two ints, multiply, push int result // Pop int, store into class variable // localConst 17 putstatic #7 <Field int localConst> 20 return // Return void from <clinit> method
The getstatic
instruction at offset 0 uses a symbolic reference (in constant pool entry 9) to the size
field of class Example1a
.
The bipush
instruction at offset 6 is followed by a byte that contains the constant value represented by Example1d.length
.
Example1e
's constant pool contains no symbolic reference to anything in class Example1d
.
Interfaces may also be awarded a <clinit>()
method in the class file.
All fields declared in an interface are implicitly public, static, and final and must be initialized with a field initializer.
If an interface has any field initializers that don't resolve at compile-time to a constant,
that interface will have a <clinit>()
method. Here's an example:
这里讲接口当中的<clinit>()方法。
// On CD-ROM in file classlife/ex1/Example1f.java interface Example1f { int ketchup = 5; int mustard = (int) (Math.random() * 5.0); }
The Java compiler generates the following <clinit>()
method for interface Example1f
:
// The code for mustard's class variable initializer begins here // Invoke Math.random(), which will push // a double return value 0 invokestatic #6 <Method double random()> 3 ldc2_w #7 <Double 5.0> // Push double constant 2.0 6 dmul // Pop two doubles, multiply, push result 7 d2i // Pop double, convert to int, push int // Pop int, store into class variable // mustard 8 putstatic #5 <Field int mustard> 11 return // Return void from <clinit> method
Note that only the mustard
field is initialized by this <clinit>()
method.
Because the ketchup
field is initialized to a compile-time constant, it is treated specially by the compiler.
Although types that use Example1f.mustard
will contain a symbolic reference to the field,
types that use Example1f.ketchup
will contain a local copy of ketchup
's constant value, 5.
Active versus Passive Use
As mentioned previously, the Java virtual machine initializes types on their first active use.
Only six activities constitute an active use:
creating a new instance of a class,
invoking a static method declared in a class,
accessing a non-constant static field declared in a class or interface,
the invocation of certain reflective methods in the Java API,
the initialization of a subclass of a class,
and the designation of a class as the initial class when a Java virtual machine starts up.
这里讲active use的6种情况。
A use of a non-constant static field is an active use of only the class or interface that actually declares the field.
For example, a field declared in a class may be referred to via a subclass.
A field declared in an interface may be referred to via a subinterface or class that implements the interface.
These are passive uses of the subclass, subinterface, or class that implements the interface--uses that won't trigger their initialization.
They are an active use only of the class or interface in which the field is actually declared.
Here's an example that illustrates this principle:
// On CD-ROM in file classlife/ex2/NewParent.java class NewParent { static int hoursOfSleep = (int) (Math.random() * 3.0); static { System.out.println("NewParent was initialized."); } } // On CD-ROM in file classlife/ex2/NewbornBaby.java class NewbornBaby extends NewParent { static int hoursOfCrying = 6 + (int) (Math.random() * 2.0); static { System.out.println("NewbornBaby was initialized."); } } // On CD-ROM in file classlife/ex2/Example2.java class Example2 { // Invoking main() is an active use of Example2 public static void main(String[] args) { // Using hoursOfSleep is an active use of NewParent, // but a passive use of NewbornBaby int hours = NewbornBaby.hoursOfSleep; System.out.println(hours); } static { System.out.println("Example2 was initialized."); } }
In the above example, executing main()
of Example2
causes only Example2
and NewParent
to be initialized.
NewbornBaby
is not initialized and need not be loaded.
The following text is printed to the standard output:
Example2 was initialized. NewParent was initialized. 2
A use of a field that is both static
and final
, and initialized by a compile-time constant expression,
is not an active use of the type that declares the field.如果是常量，则不表示active use
As mentioned above, the Java compiler resolves references to such fields to a local copy of the constant value
that resides either in the referring class's constant pool, in its bytecode streams, or both.
Here's an example that illustrates this special treatment of static final fields:
// On CD-ROM in file classlife/ex3/Angry.java interface Angry { String greeting = "Grrrr!"; int angerLevel = Dog.getAngerLevel(); } // On CD-ROM in file classlife/ex3/Dog.java class Dog { static final String greeting = "Woof, woof, world!"; static { System.out.println("Dog was initialized."); } static int getAngerLevel() { System.out.println("Angry was initialized"); return 1; } } // On CD-ROM in file classlife/ex3/Example3.java class Example3 { // Invoking main() is an active use of Example3 public static void main(String[] args) { // Using Angry.greeting is a passive use of Angry System.out.println(Angry.greeting); // Using Dog.greeting is a passive use of Dog System.out.println(Dog.greeting); } static { System.out.println("Example3 was initialized."); } }
Running the Example3
application yields the following output:
Example3 was initialized. Grrrr! Woof, woof, world!
Had Angry
been initialized, the string "Angry was initialized."
would have been written to the standard output.
Likewise, had Dog
been initialized,
the string "Dog was initialized."
would have been written to the standard output.
As you can see from the above output, neither interface Angry
or class Dog
were ever initialized
during the execution of the Example3
application.
解释上面的输出结果
For more information about this special treatment of static final variables, see Chapter 8, "The Linking Model."
The Lifetime of an Object
Once a class has been loaded, linked, and initialized, it is ready for use.
The program can access its static fields, invoke its static methods, or create instances of it.
This section describes class instantiation and initialization, activities that take place at the beginning of an object's lifetime,
and garbage collection and finalization, activities that mark the end of an object's lifetime.
Class Instantiation
In Java programs, classes can be instantiated explicitly or implicitly.
The four ways a class can be instantiated explicitly are with the new
operator,第1种
by invoking newInstance()
on a Class
or java.lang.reflect.Constructor
object,第2种
by invoking clone()
on any existing object,第3种
or by deserializing an object via the getObject()
method of classjava.io.ObjectInputStream
.第4种
Here is an example showing three ways to create a new class instance:
实例化的4种方式。
// On CD-ROM in file classlife/ex4/Example4.java class Example4 implements Cloneable { Example4() { System.out.println("Created by invoking newInstance()"); } Example4(String msg) { System.out.println(msg); } public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, CloneNotSupportedException { // Create a new Example4 object with the new operator Example4 obj1 = new Example4("Created with new."); // Get a reference to the Class instance for Example4, then // invoke newInstance() on it to create a new Example4 object Class myClass = Class.forName("Example4"); Example4 obj2 = (Example4) myClass.newInstance(); // Make an identical copy of the the second Example4 object Example4 obj3 = (Example4) obj2.clone(); } }
When executed, the Example4
application prints this output:
Created with new. Created by invoking newInstance()
Besides the four ways listed previously to explicitly instantiate objects in Java source code,
there are several situations in which objects will be instantiated implicitly--
without an explicit new
, newInstance()
, clone()
, or
ObjectInputStream.readObject()
appearing in the source.
Possibly the first implicitly instantiated objects of any Java application are
the String
objects that hold the command line arguments.
References to these objects, one for each command-line argument,
are delivered in the String
array passed as the sole parameter to the main()
method of every application.
从command line输入的参数，会自动生成String对象。
Two other ways a class can be instantiated implicitly involve the process of class loading.
First, for every type a Java virtual machine loads, it implicitly instantiates a new Class
object to represent that type.第1点，生成Class对象
Second, when the Java virtual machine loads a class that contains CONSTANT_String_info
entries in its constant pool,第2点，生成String对象
it may instantiate new String
objects to represent those constant string literals.
The process of transforming a CONSTANT_String_info
entry in the method area to a String
instance on the heap
is part of the process of constant pool resolution.
This process is described in detail in Chapter 8, "The Linking Model."
这里讲了class loading过程中，生成Class和String类型的对象。
Another way objects can be created implicitly is through the process of evaluating an expression
that involves the string concatenation operator.
If such an expression is not a compile-time constant,
intermediate String
and StringBuffer
objects
will be created in the process of evaluating the expression.
Here's an example:
字符串拼接的过程中，会生成StringBuilder对象。
// On CD-ROM in file classlife/ex5/Example5.java class Example5 { public static void main(String[] args) { if (args.length < 2) { System.out.println("Must enter any two args."); return; } System.out.println(args[0] + args[1]); } }
javac generates these bytecodes for Example5
's main()
method:
0 aload_0 // Push the objref from loc var 0 (args) 1 arraylength // Pop arrayref, calc array length, push int length 2 iconst_2 // Push int constant 2 // Pop 2 ints, compare, branch if (length >= 2) to 3 if_icmpge 15 // offset 15. // Push objref from System.out 6 getstatic #11 <Field java.io.PrintStream out> // Push objref of string literal 9 ldc #1 <String "Must enter any two args."> // Pop objref to String param, objref to System.out, // invoke println() 11 invokevirtual #12 <Method void println(java.lang.String)> 14 return // Return void from main() // Push objref from System.out 15 getstatic #11 <Field java.io.PrintStream out> // The string concatenation operation begins here // Allocate mem for new StringBuffer object, and // initialize mem to default initial values, push // objref to new object 18 new #6 <Class java.lang.StringBuffer> 21 dup // Duplicate objref to StringBuffer object 22 aload_0 // Push ref from loc var 0 (args) 23 iconst_0 // Push int constant 0 // Pop int, arrayref, push String at arrayref[int], 24 aaload // which is args[0] // Pop objref, invoke String's class method // valueOf(), passing it the objref to the args[0] // String object. valueOf() calls toString() on the // ref, and returns (and pushes) the result, which // happens to be the original args[0] String. In this // case, the stack will look precisely the same // before and after this instruction is executed. // Thus here, the 1.1 javac compiler has // over-enthusiastically generated an unnecessary // instruction. 25 invokestatic #14 <Method java.lang.String valueOf(java.lang.Object)> // Pop objref to args[0] String, objref of the // StringBuffer object, invoke <init>() method on the // StringBuffer object passing the args[0] objref as // the only parameter. 28 invokespecial #9 <Method java.lang.StringBuffer(java.lang.String)> 31 aload_0 // Push objref from loc var 0 (args) 32 iconst_1 // Push int constant 1 // Pop int, arrayref, push String at arrayref[int], 33 aaload // which is args[1] // Pop objref to args[1] String, objref of the // StringBuffer object (there's still another objref // to this same object on the stack because of the // dup instruction above), invoke append() method on // StringBuffer object, passing args[1] as the only // parameter. append() will return an objref to this // StringBuffer object, which will be pushed back // onto the stack. 34 invokevirtual #10 <Method java.lang.StringBuffer append(java.lang.String)> // Pop objref to StringBuffer (pushed by append()), // invoke toString() on it, which returns the value // of the StringBuffer as a String object. Push // objref of String object. 37 invokevirtual #13 <Method java.lang.String toString()> // The string concatenation operation is now complete // Pop objref of concatenated String, objref of // System.out that was pushed by the getstatic // instruction at offset 15. Invoke println() on // System.out, passing the concatenated String as // the only parameter. 40 invokevirtual #12 <Method void println(java.lang.String)> 43 return // Return void from main()
The bytecodes for Example5
's main()
method contain
three implicitly generated String
objects and one implicitly generated StringBuffer
object.
References to two of the String
objects appear as arguments passed to main()
in the args
array,
which are pushed onto the stack by the aaload
instructions at offset 24 and 33.
The StringBuffer
is created with the new
instruction at offset 18
and initialized with the invokespecial
instruction at offset 28.
The final String
,
which represents the concatenation of args[0]
and args[1]
,
is created by calling toString()
on the StringBuffer
object
via the invokevirtual
instruction at offset 37.
对上面的bytecode进行解释
When the Java virtual machine creates a new instance of a class, either implicitly or explicitly,
it first allocates memory on the heap to hold the object's instance variables.
Memory is allocated for all variables declared in the object's class and in all its superclasses, including instance variables that are hidden.
As described in Chapter 5, "The Java Virtual Machine,"
memory for other implementation-dependent components of an object's image on the heap,
such as a pointer to class data in the method area,
are also likely allocated at this point.
As soon as the virtual machine has set aside the heap memory for a new object,
it immediately initializes the instance variables to default initial values.
These are the same values shown above in Table 7-1 as default initial values for class variables.
这里开始讲在创建对象实例时，heap上的内存是如何分配的。
Once the virtual machine has allocated memory for the new object and
initialized the instance variables to default values,
it is ready to give the instance variables their proper initial values.
The Java virtual machine uses one of three techniques to do this, depending upon how the object is being created.有3种情况
If the object is being created because of a clone()
invocation,第1种情况
the virtual machine copies the values of the instance variables of the object being cloned into the new object.
If the object is being deserialized via a readObject()
invocation on an ObjectInputStream
,第2种情况
the virtual machine initializes non-transient instance variables of the object from values read from the input stream.
Otherwise, the virtual machine invokes an instance initialization method on the object.第3种情况
The instance initialization method initializes the object's instance variables to their proper initial values.
这段值得一读，主要是讲如何让各个字段获得proper initial value
The Java compiler generates at least one instance initialization method for every class it compiles.
In the Java class file, the instance initialization method is named "<init>
."
For each constructor in the source code of a class,
the Java compiler generates one <init>()
method.
If the class declares no constructors explicitly,
the compiler generates a default no-arg constructor that just invokes the superclass's no-arg constructor.
As with any other constructor, the compiler creates an <init>()
method in the class file that corresponds to this default constructor.
这里主要是围绕着<init>()方法展开。
An <init>()
method can contain three kinds of code:三种类型的代码
an invocation of another <init>()
method,调用另外一个构造方法
code that implements any instance variable initializers,初始化字段
and code for the body of the constructor.其它代码
If a constructor begins with an explicit invocation of another constructor in the same class
(a this()
invocation)
its corresponding <init>()
method will be composed of two parts:
这里对<init>()里面的代码进行分类
-
an invocation of the same-class
<init>()
method - the bytecodes that implement the body of the corresponding constructor
If a constructor does not begin with a this()
invocation and the class is not Object
,
the <init>()
method will have three components:
-
an invocation of a superclass
<init>()
method - the bytecodes for any instance variable initializers
- the bytecodes that implement the body of the corresponding constructor
If a constructor does not begin with a this()
invocation and the class is Object
,
the first component in the above list is missing.
Because Object
has no superclass,
its <init>()
method's can't begin with a superclass <init>()
method invocation.
这里讲的是java.lang.Object的情况。
If a constructor begins with an explicit invocation of a superclass constructor (a super()
invocation),
its <init>()
method will invoke the corresponding superclass <init>()
method.
For example, if a constructor begins with an explicit invocation of the "super(int, String)
constructor,"
the corresponding <init>()
method will begin by invoking the superclass's "<init>(int, String)
" method.
If a constructor does not begin with an explicit this()
or super()
invocation,
the corresponding <init>()
method will invoke the superclass's no-arg <init>()
method by default.
子类的构造方法，调用父类的构造方法。
Here's an example with three constructors, numbered one through three:
// On CD-ROM in file classlife/ex6/Example6.java class Example6 { private int width = 3; // Constructor one: // This constructor begins with a this() constructor invocation, // which gets compiled to a same-class <init>() method invocation. Example6() { this(1); System.out.println("Example6(), width = " + width); } // Constructor two: // This constructor begins with no explicit invocation of another // constructor, so it will get compiled to an <init>() method // that begins with an invocation of the superclass's no-arg <init>() method. Example6(int width) { this.width = width; System.out.println("Example6(int), width = " + width); } // Constructor three: // This constructor begins with super(), an explicit invocation // of the superclass's no-arg constructor. Its <init>() method // will begin with an invocation of the superclass's no-arg <init>() method. Example6(String msg) { super(); System.out.println("Example6(String), width = " + width); System.out.println(msg); } public static void main(String[] args) { String msg = "The Agapanthus is also known as Lily of the Nile."; Example6 one = new Example6(); Example6 two = new Example6(2); Example6 three = new Example6(msg); } }
When executed, the Example6
application prints this output:
Example6(int), width = 1 Example6(), width = 1 Example6(int), width = 2 Example6(String), width = 3 The Agapanthus is also known as Lily of the Nile.
The bytecodes for Example6
's no-arg <init>()
method
(the <init>()
method that corresponds to constructor one) are:
// The first component, the same-class <init>() invocation, begins // here: 0 aload_0 // Push the objref from loc var 0 (this) 1 iconst_1 // Push int constant 1 // Pop int and objref, invoke <init>() method on // objref (this), passing the int (a 1) as the // only parameter. 2 invokespecial #12 <Method Example6(int)> // The second component, the body of the constructor, begins // here: // Push objref from System.out 5 getstatic #16 <Field java.io.PrintStream out> // Allocate mem for new StringBuffer object, and // initialize mem to default initial values, push // objref to new object 8 new #8 <Class java.lang.StringBuffer> 11 dup // Duplicate objref to StringBuffer object // Push objref to String literal from constant pool 12 ldc #1 <String "Example6(), width = "> // Pop objref to literal String, pop objref of the // StringBuffer object, invoke <init>() method on the // StringBuffer object passing the args[0] objref as // the only parameter. 14 invokespecial #14 <Method java.lang.StringBuffer(java.lang.String)> 17 aload_0 // Push objref from loc var 0 (this) // Pop this reference, Push int value of width field 18 getfield #19 <Field int width> // Pop int (width), pop objref (StringBuffer object), // invoke append() on StringBuffer object passing the // width int as the only parameter. append() will add // the string representation of the int to the end of // the buffer, and return an objref to the same // StringBuffer object. 21 invokevirtual #15 <Method java.lang.StringBuffer append(int)> // Pop objref to StringBuffer (pushed by append()), // invoke toString() on it, which returns the value // of the StringBuffer as a String object. Push // objref of String object. 24 invokevirtual #18 <Method java.lang.String toString()> // Pop objref of String, pop objref of System.out // that was pushed by the getstatic instruction at // offset 5. Invoke println() on System.out, // passing the String as the only parameter: // System.out.println("Example6(), width = " // + width); 27 invokevirtual #17 <Method void println(java.lang.String)> 30 return // Return void from <init>()
Note that the <init>()
method for constructor one begins with an invocation of a same-class <init>()
method,
then executes the body of the corresponding constructor.
Because the constructor begins with a this()
invocation,
its corresponding <init>()
method doesn't contain bytecodes for the instance variable initializer.
对上面的bytecode进行解释
The bytecodes for Example6
's <init>()
method that takes an int
parameter
(the <init>()
method that corresponds to constructor two) is:
// The first component, the superclass <init>() invocation, begins // here: 0 aload_0 // Push the objref from loc var 0 (this) // Pop objref (this), invoke the superclass's // no-arg<init>() method on objref. 1 invokespecial #11 <Method java.lang.Object()> // The second component, the instance variable initializers, begins // here: 4 aload_0 // Push the objref from loc var 0 (this) 5 iconst_3 // Push int constant 3 // Pop int (3), pop objref (this), store 3 into // width instance variable of this object 6 putfield #19 <Field int width> // The third component, the body of the constructor, begins // here: 9 aload_0 // Push the objref from loc var 0 (this) 10 iload_1 // Push int from loc var 1 (int param width) // Pop int (param width), pop objref (this), store // int param value into width field of this object: // this.width = width 11 putfield #19 <Field int width> // Push objref from System.out 14 getstatic #16 <Field java.io.PrintStream out> // Allocate mem for new StringBuffer object, and // initialize mem to default initial values, push // objref to new object 17 new #8 <Class java.lang.StringBuffer> 20 dup // Duplicate objref to StringBuffer object // Push objref to String literal from constant pool 21 ldc #3 <String "Example6(int), width = "> // Pop objref to literal String, pop objref of the // StringBuffer object, invoke <init>() method on the // StringBuffer object passing the args[0] objref as // the only parameter. 23 invokespecial #14 <Method java.lang.StringBuffer(java.lang.String)> 26 iload_1 // Push int from loc var 1 (int param width) // Pop int (width), pop objref (StringBuffer object), // invoke append() on StringBuffer object passing the // width int as the only parameter. append() will add // the string representation of the int to the end of // the buffer, and return an objref to the same // StringBuffer object. 27 invokevirtual #15 <Method java.lang.StringBuffer append(int)> // Pop objref to StringBuffer (pushed by append()), // invoke toString() on it, which returns the value // of the StringBuffer as a String object. Push // objref of String object. 30 invokevirtual #18 <Method java.lang.String toString()> // Pop objref of String, pop objref of System.out // that was pushed by the getstatic instruction at // offset 14. Invoke println() on System.out, // passing the String as the only parameter: // System.out.println("Example6(int), width = " // + width); 33 invokevirtual #17 <Method void println(java.lang.String)> 36 return // Return void from <init>()
The <init>()
method for constructor two has three components.
First it has an invocation of the superclass's (Object
's) no-arg <init>()
method.
The compiler generated this invocation by default,
because no explicit super()
invocation appears as the first statement in the body of constructor two.
Following the superclass <init>()
invocation is the second component:
the bytecodes for width's instance variable initializer.
Third, the <init>()
method contains the bytecodes for the body of constructor two.
对上面的代码进行解释。
The bytecodes for Example6
's <init>()
method that takes a String
parameter
(the <init>()
method that corresponds to constructor three) are:
// The first component, the superclass <init>() invocation, begins // here: 0 aload_0 // Push the objref from loc var 0 (this) // Pop objref (this), invoke the superclass's // no-arg<init>() method on objref. 1 invokespecial #11 <Method java.lang.Object()> // The second component, the instance variable initializers, begins // here: 4 aload_0 // Push the objref from loc var 0 (this) 5 iconst_3 // Push int constant 3 // Pop int (3), pop objref (this), store 3 into // width instance variable of this object 6 putfield #19 <Field int width> // The third component, the body of the constructor, begins // here: // Push objref from System.out 9 getstatic #16 <Field java.io.PrintStream out> // Allocate mem for new StringBuffer object, and // initialize mem to default initial values, push // objref to new object 12 new #8 <Class java.lang.StringBuffer> 15 dup // Duplicate objref to StringBuffer object // Push objref to String literal from constant pool 16 ldc #2 <String "Example6(String), width = "> // Pop objref to literal String, pop objref of the // StringBuffer object, invoke <init>() method on the // StringBuffer object passing the args[0] objref as // the only parameter. 18 invokespecial #14 <Method java.lang.StringBuffer(java.lang.String)> 21 aload_0 // Push objref from loc var 0 (this) // Pop this reference, Push int value of width field 22 getfield #19 <Field int width> // Pop int (width), pop objref (StringBuffer object), // invoke append() on StringBuffer object passing the // width int as the only parameter. append() will add // the string representation of the int to the end of // the buffer, and return an objref to the same // StringBuffer object. 25 invokevirtual #15 <Method java.lang.StringBuffer append(int)> // Pop objref to StringBuffer (pushed by append()), // invoke toString() on it, which returns the value // of the StringBuffer as a String object. Push // objref of String object. 28 invokevirtual #18 <Method java.lang.String toString()> // Pop objref of String, pop objref of System.out // that was pushed by the getstatic instruction at // offset 9. Invoke println() on System.out, // passing the String as the only parameter: // System.out.println("Example6(String), width = " // + width); 31 invokevirtual #17 <Method void println(java.lang.String)> // Push objref from System.out 34 getstatic #16 <Field java.io.PrintStream out> 37 aload_1 // Push objref from loc var 1 (param msg) // Pop objref of String, pop objref of System.out // that was pushed by the getstatic instruction at // offset 37. Invoke println() on System.out, // passing the String as the only parameter: // System.out.println(msg); 38 invokevirtual #17 <Method void println(java.lang.String)> 41 return // Return void from <init>()
The <init>()
method for constructor three has the same three components as the <init>()
method for constructor two:
a superclass <init>()
invocation,
the bytecodes for width
's initializer,
and the bytecodes for the constructor body.
One difference between constructor two and three is that
constructor two does not begin with an explicit this()
or super()
invocation.
As a result, the compiler places an invocation of the superclass's no-arg <init>()
method in constructor two's <init>()
method.
By contrast, constructor three begins with an explicit super()
invocation,
which the compiler converts into the corresponding superclass <init>()
invocation in constructor three's <init>()
method.
对上面的代码进行解释
For every class except Object
,
an <init>()
method must begin with an invocation of another <init>()
method
belonging either to the same class or to the direct superclass.
<init>()
methods are not allowed to catch exceptions thrown by the <init>()
method they invoke.
If a subclass <init>()
method invokes a superclass <init>()
method that completes abruptly,
for example, the subclass <init>()
method must also complete abruptly.
这里讲了构造方法中的异常。
Garbage Collection and Finalization of Objects
As mentioned in earlier chapters,
implementations of the Java virtual machine must have some kind of automatic storage management strategy for the heap,
most likely a garbage collector.
Applications can allocate memory for objects via the explicit and implicit ways described earlier in this chapter,
but cannot explicitly free that memory.不能主动释放object占用的内存
When an object becomes unreferenced by the application, the virtual machine may reclaim (garbage collect) that memory.

Java virtual machine implementations are not required to free memory occupied by unreferenced objects.
前面的内容是讲如何在heap为object分配内存空间，现在开始讲如何回收heap上不再使用的内存空间。
If a class declares a method named finalize()
that returns void
,
the garbage collector will execute that method (called a "finalizer") once on an instance of that class,
before it frees the memory space occupied by that instance.
Here's an example of a class that declares a finalizer:
这里介绍finalize()方法。
// On CD-ROM in file classlife/ex7/Finale.java class Finale { protected void finalize() { System.out.println("A Finale object was finalized."); //... } //... }
Because a finalizer is a regular Java method, it may be invoked directly by the application.
Such a direct invocation will not affect the automatic invocation of the finalizer by the garbage collector.
The garbage collector may invoke an object's finalizer at most once,只能执行一次finalize()方法
sometime after the object becomes unreferenced and before the memory it occupies is reused.
If the object becomes referenced again (resurrected) as a result of executing the finalizer code,
and then becomes unreferenced again later,
the garbage collector must not automatically invoke the finalizer a second time.
finalize()方法只能被GC调用一次。
Unloading of Types
In many ways, the lifetime of a class in the Java virtual machine is similar to the lifetime of an object.
The virtual machine creates and initializes objects, allows the program to use the objects,这里是讲object
and optionally garbage collects the objects after they are no longer referenced by the program.
Similarly, the virtual machine loads, links, and initializes classes, allows the program to use the classes,这里是讲class
and optionally unloads the classes after they are no longer referenced by the program.
开始讲class的unload
Garbage collection and unloading of classes is important in the Java virtual machine
because Java programs can be dynamically extended at runtime by loading types through user-defined class loaders.
All loaded types occupy memory space in the method area.
If a Java application continuously loads types through user-defined class loaders, the memory footprint of the method area will continuously grow.
If some of the dynamically loaded types are needed only temporarily,
the memory space occupied by those types can be freed by unloading the types after they are no longer needed.
这里讲对于class进行garbage collection和unload是有必要的。
The way in which a Java virtual machine can tell whether a dynamically loaded type is still needed by the application
is similar to the way it tells whether an object is still needed by the program.
If the application has no references to the type, then the type can't affect the future course of computation.
The type is unreachable and can be garbage collected.
这里讲loaded type可以被unload的判断标准。
Types loaded through the bootstrap class loader will always be reachable and never be unloaded.
Only types loaded through user-defined class loaders can become unreachable and be unloaded by the virtual machine.
A type is unreachable if its Class
instance is found to be unreachable through the normal process of garbage collecting the heap.
从class loader的角度上，来看待loaded type如何被unload。
There are two ways a Class
instance of a dynamically loaded type can be reachable through the normal process of garbage collection.有两种情况
First and most obviously, a Class
instance will be reachable if the application holds an explicit reference to it.第1种情况
Second, a Class
instance will be reachable if there is a reachable object on the heap第2种情况
whose type data in the method area refers to the Class
instance.
As mentioned in Chapter 5, "The Java Virtual Machine,"
implementations must be able to locate the type data in the method area for an object's class, given only a reference to the object.
For this reason, the image of an object on the heap likely includes some kind of pointer to its type data in the method area.
From the type data, the virtual machine must be able to locate the Class
instances for the object's class,
all its superclasses, and all its superinterfaces.
See Figure 7-2 for a graphical depiction of this way of "reaching" Class
instances.
这里讲了判断Class是“reachable”状态的两种方法。
Figure 7-2. Reaching Class instances through a reachable object.
Figure 7-2 shows the paths a garbage collector must
traverse from a reachable object of class MyThread
through the type data in the method area to
find reachable Class
instances.
In this figure, objects on the heap are shown as clear circles;
type data in the method area is shown as gray rectangles.
The MyThread
class has the following declaration:
// On CD-ROM in file classlife/ex8/MyThread.java class MyThread extends Thread implements Cloneable { }
From the reachable MyThread
object (shown in the bottom right hand corner of the figure),
the garbage collector follows a pointer to MyThread
's type data, where it finds:
-
A reference to
MyThread
'sClass
instance on the heap -
A pointer to the type data for
MyThread
's direct superinterface,Cloneable
-
A pointer to the type data for
MyThread
's direct superclass,Thread
From the type data for Cloneable
, the garbage collector finds:
-
A reference to
Cloneable
'sClass
instance on the heap
From the type data for Thread
, the garbage collector finds:
-
A reference to
Thread
'sClass
instance on the heap -
A pointer to the type data for
Thread
's direct superinterface,Runnable
-
A pointer to the type data for
Thread
's direct superclass,Object
From the type data for Runnable
, the garbage collector finds:
-
A reference to
Runnable
'sClass
instance on the heap
From the type data for Object
, the garbage collector finds:
-
A reference to
Objects
'sClass
instance on the heap
Thus, given only a reference to a reachable instance of class MyThread
,
the garbage collector is able to "reach" the Class
instances for MyThread
and
all its supertypes: Cloneable
, Thread
, Runnable
, and Object
.
An example of dynamically loaded classes becoming unreachable and available for unloading is given at the end of Chapter 8, "The Linking Model."
On the CD-ROM
The CD-ROM contains the source code examples from this chapter in the classlife
directory.
The Resources Page
For more information about the material presented in this chapter, visit the resources page:
http://www.artima.com/insidejvm/resources/


Thieves make off with treasure worth up to €1 billion from museum in Germany
“It’s not just the State Art Collections that was robbed, but us Saxons,” the governor of Saxony said.
by Press AssociationTHIEVES HAVE CARRIED out a heist at Dresden’s Green Vault, one of the world’s oldest museum containing priceless treasures and jewels, German officials said.
The treasury of Augustus the Strong of Saxony was established in 1723 and today contains around 4,000 objects of gold, precious stones and other materials on display in the historic palace.
German media reported the losses from the early-morning burglary could run into the high hundreds of millions of euros, or potentially even into the billions.
Police said it was too early to estimate the value of the items stolen but planned to provide further information over the course of the day.
The governor of Saxony, where Dresden is located, said the vault contained items collected over many hundreds of years.
“It’s not just the State Art Collections that was robbed, but us Saxons,” Michael Kretschmer tweeted.
“One can’t understand the history of Saxony without the Green Vault.”
Exhibition rooms at the museum include a focus on treasures featuring jewels, ivory, silver and amber among other objects.
One of its most famous and precious treasures, the Dresden Green Diamond, is currently on loan with other valuable pieces to the Metropolitan Museum of Art in New York for an exhibit.
The 41-carat green diamond was acquired by Augustus III, the son of Augustus the Strong, in 1742, according to the museum.
The museum did not put a current value on the piece, but said at the time of its purchase it cost 400,000 thalers, compared to the 288,000 thalers it cost to build Dresden’s lavish Frauenkirche church at around the same time.
Interior Minister Roland Woeller told reporters: “This is a bitter day for the cultural heritage of Saxony.”
He said police had already set up a special team of investigators to pursue the case.
“We will do everything in our power not only to bring the cultural treasures back, but to capture the perpetrators,” he said.


\ref{key}
The \ref command produces the number of the sectional unit, equation number, ... of the corresponding \label command.
Bibliographic references using the \thebibliography mechanism obtain their number or label using \cite.
The \ref command is fragile.
See also Cross References
Return to LaTeX Table of Contents


Tateyama Wakashio Marathon
Tateyama JPN
Race Winners
(37 runnings)
27 Jan
2008
28 Jan
2007
29 Jan
2006
30 Jan
2005
25 Jan
2004
26 Jan
2003
2002
Jan
2001
Jan
2000
1999
25 Jan
1998
26 Jan
1997
28 Jan
1996
1995
30 Jan
1994
1993
1992
1991
28 Jan
1990
29 Jan
1989
1988
1987
1986
1985
1984
1983
1982
1981
Notes: 1981 is believed to have been the inaugural year.
29 Jan
2017
2:28:54
Yasuo Ito-3
2:58:53
Hitomi Mamiya
(JPN)
31 Jan
2016
2:26:44
Yasuo Ito-2
3:00:09
Kazumi Kawamoto
(JPN)
25 Jan
2015
2:23:20
Shinichi Koyama (JPN)
3:00:06
Sachi Takeuchi
(JPN)
26 Jan
2014
2:26:52
Koji Takahashi--3
2:54:58
Kimiko Yamaguchi-2
27 Jan
2013
2:33:18
Koji Takahashi-2
2:56:16
Kimiko Yamaguchi
(JPN)
29 Jan
2012
2:30:51
Koji Takahashi (JPN)
2:57:00
Yuko Ito-3
30 Jan
2011
2:29:29
Yasuo Ito (JPN)
3:02:40
Yuko Ito-2
31 Jan
2010
2:33:47
Hiromi Kawasaki (JPN)
2:54:31
Yuko Ito (JPN)
25 Jan
2009
2:31:15
Megumi Takemura (JPN)
2:51:12
Makiko Shimamura (JPN)
2:30:38
Hiroyuki Jingu-2
3:02:15
Miyuki Masuda (JPN)
2:30:59
Hiroyuki Kamimiya (JPN)
3:10:27
Rui Goto (JPN)
2:32:15
Hiroyuki Jingu (JPN)
2:59:05
Megumi Suzuki (JPN)
2:33:13
Hiroaki Fujisawa (JPN)
2:45:48
Masako Kusakaya (JPN)
2:29:03
Manabu Otaki (JPN)
2:54:40
Megumi Iwamoto (JPN)
2:23:01
Satoshi Fujiwara-2
2:56:57
Mika Negishi (JPN)
---
n/a
---
n/a
---
Satoshi Fujiwara (JPN)
---
n/a
2:35:06
Hiroyuki Miyazaki (JPN)
2:55:46
Aiko Ikegami-2
---
n/a
---
n/a
2:30:33
Kazuhiro Koike (JPN)
2:57:19
Aiko Ikegami (JPN)
2:26:12
Kyohei Yasuda (JPN)
3:05:41
Ayako Suzuki (JPN)
2:31:22
Fujio Aoki (JPN)
2:45:54
Naomi Yoshizawa (JPN)
---
n/a
---
n/a
2:30:24
Tatsuo Furusako (JPN)
3:06:28
Masako Kaneko (JPN)
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
2:28:38
Kazuhito Furusako (JPN)
3:03:12
Saeko Matsue (JPN)
2:25:21
Itsuo Suzuki (JPN)
3:00:13
Hiroko Kubota (JPN)
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
---
n/a
Most Wins
(1981/date)
Men
3
Koji Takahashi (JPN)
2012-14
Yasuo Ito (JPN)
2011,2016-17
Women
3
Yuko Ito (JPN)
2010-12
Prize Money
(ADR qualified runners)
No information on prize money has been reported for this race.
Race Time Bias
(sec/km)
Insufficient data to calculate the race time bias.
Competitive Level
(1990-date)
Insufficient data to calculate the competitive level.
Quality Performances
Men <2:12 2 Women <2:46 2 <2:48 2 <2:50 2
Last Updated on 30 Jan 2017
Contributors: Kanji Kono, Shigenobu Ota (50), Brett Larner (20), Klaas Loonstra (10)


CB Barcode ReGen provides 2 functions, barcode generator and barcode reader. The generator module supports only QR code for now. The reader module supports UPC-A, UPC-E, EAN-8, EAN-13, CODE-39, CODE-128, ITF and QR code.
Where the barcode is saved?
All saved barcodes are saved in /sdcard/data/com.cbsb.barcodegen
by the name in UUID style. This directory is created automatically on first use with ".nomedia" file to prevent MediaScaner
to scan this directory. Since version 1.2, these barcodes are inserted to MediaStorage
so you can access them through Gallery. The saved barcodes in this directory are necessary to prevent duplicate insertion in case you save or share the same barcode more than once.


Hallo!
Who ever reads this is
Awesome!
You even tried this one?!
Who ever reads this is nosy ;-)
yeah another popup!


| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| abstract.js | 76% | 38/50 | 59.38% | 19/32 | 55.56% | 5/9 | 75% | 36/48 | |
| collect.js | 12.77% | 6/47 | 0% | 0/16 | 0% | 0/9 | 15% | 6/40 | |
| dir-reader.js | 11.49% | 17/148 | 0% | 0/79 | 0% | 0/19 | 12.41% | 17/137 | |
| dir-writer.js | 15.91% | 14/88 | 0% | 0/43 | 0% | 0/11 | 16.87% | 14/83 | |
| file-reader.js | 50.6% | 42/83 | 42% | 21/50 | 66.67% | 6/9 | 53.16% | 42/79 | |
| file-writer.js | 16.92% | 11/65 | 0% | 0/34 | 0% | 0/10 | 18.97% | 11/58 | |
| get-type.js | 100% | 17/17 | 100% | 10/10 | 100% | 1/1 | 100% | 16/16 | |
| link-reader.js | 28.57% | 8/28 | 0% | 0/14 | 0% | 0/4 | 30.77% | 8/26 | |
| link-writer.js | 23.64% | 13/55 | 0% | 0/40 | 0% | 0/10 | 26% | 13/50 | |
| proxy-reader.js | 87.23% | 41/47 | 42.86% | 6/14 | 66.67% | 6/9 | 87.23% | 41/47 | |
| proxy-writer.js | 22.03% | 13/59 | 0% | 0/18 | 0% | 0/9 | 22.41% | 13/58 | |
| reader.js | 60.29% | 82/136 | 46.88% | 45/96 | 45.45% | 5/11 | 62.31% | 81/130 | |
| writer.js | 14.94% | 36/241 | 0.62% | 1/162 | 0% | 0/29 | 16.98% | 36/212 |


Create App Cookie Stickiness Policy Request. More...
Public Member Functions | |
| (id) | - init |
| Default constructor for a new CreateAppCookieStickinessPolicyRequest object. | |
| (id) | - initWithLoadBalancerName:andPolicyName:andCookieName: |
| Constructs a new CreateAppCookieStickinessPolicyRequest object. | |
| (NSString *) | - description |
| Returns a string representation of this object; useful for testing and debugging. | |
Properties | |
| NSString * | loadBalancerName |
| The name associated with the LoadBalancer. | |
| NSString * | policyName |
| The name of the policy being created. | |
| NSString * | cookieName |
| Name of the application cookie used for stickiness. |
Create App Cookie Stickiness Policy Request.
| - (NSString * ElasticLoadBalancingCreateAppCookieStickinessPolicyRequest.)description |
Returns a string representation of this object; useful for testing and debugging.
| - (id ElasticLoadBalancingCreateAppCookieStickinessPolicyRequest.)init |
Default constructor for a new CreateAppCookieStickinessPolicyRequest object.
Callers should use the property methods to initialize this object after creating it.
| - (id ElasticLoadBalancingCreateAppCookieStickinessPolicyRequest.)initWithLoadBalancerName: | (NSString *) | theLoadBalancerName | ||
| andPolicyName: | (NSString *) | thePolicyName | ||
| andCookieName: | (NSString *) | theCookieName | ||
Constructs a new CreateAppCookieStickinessPolicyRequest object.
Callers should use properties to initialize any additional object members.
| theLoadBalancerName | The name associated with the LoadBalancer. The name must be unique within the client AWS account. | |
| thePolicyName | The name of the policy being created. The name must be unique within the set of policies for this Load Balancer. | |
| theCookieName | Name of the application cookie used for stickiness. |
- (NSString *) loadBalancerName [read, write, retain] |
The name associated with the LoadBalancer.
The name must be unique within the client AWS account.
- (NSString *) policyName [read, write, retain] |
The name of the policy being created.
The name must be unique within the set of policies for this Load Balancer.


Morning Glory & H.B. Woodrose
I began with a ton of research on LSA containing seeds; I wanted to ensure a positive, enriching experience. I decided on the tried and true water extraction method. After grinding the seeds as thoroughly as possible in a coffee grinder, I mixed it all in 2 1/2 cups of cold water, shook vigorously, and put it in the fridge. For the next two days I shook it when I thought of it, and prepared mentally and spiritually for my voyage. This included discussing the whole matter with my psychiatrist, who is unbelievably cool with whatever I throw at her.
2:00 pm
It is time to embark, and so I FILTER the concoction. The key is to not ingest the seed matter. Eating the seed matter is completely unnecessary because the LSA compounds have all been transferred to the water. After filtering it with cheesecloth to remove the big pieces, I then used a very fine sieve to get the smaller bits out. The resulting tea was dark brown, clean, and smooth. I drank it down, and smoked a bit of cannabis to get rid of the taste, which was not exactly bad, but a far cry from good.
2:30
Already feeling the effects. My scalp is tingling, and I am giddy and giggly.
3:00
Feeling nauseous. It is time to take an OTC anti-nauseate: Emetrol. This is a liquidy syrupy stuff. Read the instructions carefully. What worked well for me was to take 2 teaspoons every twenty minutes for a total of 3 doses. And voila! Just some burping, but I'm feeling great. Burping is good.
3:45
No cramping, no blurry vision, no nausea. No pain at all, in fact. Feeling good. Listening to some good tunes.
4:30
I am starting to realize that this is going to be a very intense trip. I underestimated the power of these seeds. I should say that I have not had any hallucinogen other than cannabis for 5 years I am very excited that I have found such an amazing legal, safe way to have a psychedelic experience. It is time to take my dog for a walk. (Should I say, it was time for my dog to take me for a walk).
6:45
Wow.  The gardens were so beautiful. It's spring time here in California and the flowers are so fragant and colorful. My dog was wonderful. She was, and is, my guide through this part of my trip. She charged ahead, and I gripped the leash and flew behind her like a kite.
7:00
I'm tripping hard. This has far surpassed my expectations. I'm no longer one with my ego. My ego has made a nosedive for the window and a lot of emotions that I've been surpressing and stuffing are coming up strong and fast.
The problem is, I'm feeling very alone. My partner is gone for the weekend and so it's just me and the dog, and the three cats. I really want to call my therapist, but will that be way too wierd? I'm very afraid. I don't want her to reject me. I don't want her to say no, she can't talk to me if I'm tripping.
My mind is blown right now. I'm crying. It's all right to cry. Just feel it. Let it flow through me like waves. I want to risk everything and call my therapist.
7:30
After an agonizing stuggle over whether to call my therapist, I pick up the phone and dial, leave a message.  I'm coming down now after a very emotional couple of hours. My therapist called me back and we spoke for half and hour and I told her all the things I've been trying to tell her for so long now. It just felt so right, the time was right to open up to her. I'm feeling ecstatic right now. This has been my crowning psychedelic experience. No naptha or gritty seed meal required. For that matter, no shady drug deal, no racing heart. No puking. A lot of peeing, but no puking.
My advice to potential MG and/or HBWR seed experimenters is to do everything you can to prepare yourself physically, emotionally, and spiritually. I was wise to chose a time of peace and beauty to drink the tea. With a little planning, I am on a spectacular journey. For me it worked well to go into my trip with a few issues I wanted to work through. Combining the seeds was a powerful experience, not to be undertaken by someone who is unprepared.
10:00
I'm a seed convert. I'll never do acid, mushrooms, or X again. All of the hallucinogenic/shamanistic experiences that I need are contained within these seeds.
Not a ton of hallucinations or visuals with the seeds. This is an inner high. I remained 100% coherent throughout the entire thing. During the peak of 7pm to 8pm it was pretty hard. But I broke through it and here I am on the other side.
Good luck! For me it was 10 years of therapy summed up in a matter of hours. I never imagined that I would ever talk to my shrink while tripping. This has truly been a remarkable experience. I look forward to the future!
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.