0% found this document useful (0 votes)
44 views

Pro Java 8 Programming 3rd Edition Terrill Brett Spell - Read the ebook online or download it for a complete experience

The document promotes various eBooks available for download at ebookname.com, including titles on Java programming and other subjects. It highlights the benefits of instant digital products in multiple formats and provides links to specific eBooks. Additionally, it includes an introduction to Java programming, discussing its architecture, the Java Virtual Machine (JVM), and the importance of platform independence.

Uploaded by

areiasmadn82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Pro Java 8 Programming 3rd Edition Terrill Brett Spell - Read the ebook online or download it for a complete experience

The document promotes various eBooks available for download at ebookname.com, including titles on Java programming and other subjects. It highlights the benefits of instant digital products in multiple formats and provides links to specific eBooks. Additionally, it includes an introduction to Java programming, discussing its architecture, the Java Virtual Machine (JVM), and the importance of platform independence.

Uploaded by

areiasmadn82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Endless Ebook, One Click Away – Start Downloading at ebookname.

com

Pro Java 8 Programming 3rd Edition Terrill Brett


Spell

https://ebookname.com/product/pro-java-8-programming-3rd-
edition-terrill-brett-spell/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://ebookname.com


Click here to visit ebookname.com and download ebook now
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Learning Reactive Programming with Java 8 1st Edition


Nickolay Tsvetinov

https://ebookname.com/product/learning-reactive-programming-with-
java-8-1st-edition-nickolay-tsvetinov/

Java 8 in Action Lambdas Streams and functional style


programming 1st Edition Raoul-Gabriel Urma

https://ebookname.com/product/java-8-in-action-lambdas-streams-
and-functional-style-programming-1st-edition-raoul-gabriel-urma/

Java programming comprehensive concepts and techniques


3rd Edition Gary B. Shelly

https://ebookname.com/product/java-programming-comprehensive-
concepts-and-techniques-3rd-edition-gary-b-shelly/

Music Language and the Brain Aniruddh D. Patel

https://ebookname.com/product/music-language-and-the-brain-
aniruddh-d-patel/
Understanding and Treating Obsessive Compulsive
Disorder A Cognitive Behavioral Approach 1st Edition
Jonathan S. Abramowitz

https://ebookname.com/product/understanding-and-treating-
obsessive-compulsive-disorder-a-cognitive-behavioral-
approach-1st-edition-jonathan-s-abramowitz/

The Gulag after Stalin Redefining Punishment in


Khrushchev s Soviet Union 1953 1964 1st Edition Jeffrey
S. Hardy

https://ebookname.com/product/the-gulag-after-stalin-redefining-
punishment-in-khrushchev-s-soviet-union-1953-1964-1st-edition-
jeffrey-s-hardy/

ICD 10 CM and ICD 10 PCS Coding Handbook with Answers


2019 Rev Ed Nelly Leon-Chisen

https://ebookname.com/product/icd-10-cm-and-icd-10-pcs-coding-
handbook-with-answers-2019-rev-ed-nelly-leon-chisen/

Russian Lawyers and the Soviet State The Origins and


Development of the Soviet Bar 1917 1939 Eugene Huskey

https://ebookname.com/product/russian-lawyers-and-the-soviet-
state-the-origins-and-development-of-the-soviet-
bar-1917-1939-eugene-huskey/

Counting the Dead The Culture and Politics of Human


Rights Activism in Colombia California Series in Public
Anthropology 1st Edition Winifred Tate

https://ebookname.com/product/counting-the-dead-the-culture-and-
politics-of-human-rights-activism-in-colombia-california-series-
in-public-anthropology-1st-edition-winifred-tate/
Men s body sculpting 2nd Edition Nick Evans

https://ebookname.com/product/men-s-body-sculpting-2nd-edition-
nick-evans/
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance

About the Author��������������������������������������������������������������������������������������������������xxiii


About the Technical Reviewer�������������������������������������������������������������������������������xxv
Acknowledgments�����������������������������������������������������������������������������������������������xxvii
Introduction����������������������������������������������������������������������������������������������������������xxix

■■Chapter 1: Going Inside Java��������������������������������������������������������������������������������� 1


■■Chapter 2: Designing Libraries, Classes, and Methods��������������������������������������� 19
■■Chapter 3: Lambdas and Other Java 8 Features�������������������������������������������������� 81
■■Chapter 4: Using Threads in Your Applications������������������������������������������������� 105
■■Chapter 5: Using Stream APIs and Collections�������������������������������������������������� 163
■■Chapter 6: Using Layout Managers�������������������������������������������������������������������� 207
■■Chapter 7: Using Swing’s JTable����������������������������������������������������������������������� 281
■■Chapter 8: Using Swing’s JTree������������������������������������������������������������������������� 327
■■Chapter 9: Adding Cut-and-Paste Functionality������������������������������������������������������ 379
■■Chapter 10: Adding Drag-and-Drop Functionality��������������������������������������������� 403
■■Chapter 11: Printing������������������������������������������������������������������������������������������ 449
■■Chapter 12: Introducing JDBC��������������������������������������������������������������������������� 479
■■Chapter 13: Internationalizing Your Applications���������������������������������������������� 529
■■Chapter 14: Using XML�������������������������������������������������������������������������������������� 587
■■Chapter 15: Adding Annotations������������������������������������������������������������������������ 637

Index��������������������������������������������������������������������������������������������������������������������� 663

v
Introduction

It’s been a while since I last revised this material and even longer than that since the first edition was
published. In that time the technologies that Java programmers use have changed quite a bit and there’s no
doubt that if I were writing this book for the first time I would do some things differently. For example, I’d
place more of an emphasis on technologies related to web development to reflect the dominance that it has
in the industry today. Even so, it’s a little surprising to find out how relevant most of the original material
still is, and I hope that you’ll find both the principles and specific technology topics covered here useful in
learning how to program in Java.

xxix
Chapter 1

Going Inside Java

Java has been described as “a simple, robust, object-oriented, platform-independent, multithreaded,


dynamic, general-purpose programming environment.” Living up to this definition allowed Java to grow
and expand into so many niches that it’s almost unrecognizable from its earliest days. Today you can find
Java just about anywhere you can find a microprocessor. It’s used in the largest of enterprises to the smallest
of devices, and it’s used in devices from cell phones to supercooled mainframes. For Java to support such a
wide range of environments, an almost bewildering array of application programming interfaces (APIs) and
versions have been developed, though they’re built around a common set of core classes.
In order to become a good Java programmer, it’s important to be able to do the basics well. Being
able to produce a highly complex user interface is all very well, but if your code is bloated, memory
hungry, and inefficient, your users won’t be happy. This book isn’t about the huge array of development
options available to you as a Java developer but about how to do the common tasks that as a Java
developer you’ll encounter again and again. Over the course of the book, we’ll examine some of the core
language features, such as threading and memory management, that can really make the difference in a
professional-quality Java application.
At the core of Java’s adaptability, and hence popularity, is that it’s platform-independent. Its “write
once, run anywhere” (WORA) capability stems from the way Java itself operates and in particular from
the use of an abstract execution environment that allows Java code to be separated from the underlying
operating system. Whereas the rest of this book will be about exploring the programming language and APIs
of Java, in this chapter we’ll look at the foundations of how Java really operates under the hood, with the Java
Virtual Machine (JVM). Understanding the inner workings of Java will give you as a programmer a better
understanding of the language, which should make you a better programmer.
In this chapter, we’ll cover the following:
• The various components of the Java platform
• How the JVM allows Java to be platform-independent
• What happens when you run a Java program
• What a Java class file really contains
• The key tools needed to work with a JVM
First, then, let’s look at what Java actually is.

1
Chapter 1 ■ Going Inside Java

Java’s Architecture
It’s easy to think of Java as merely the programming language with which you develop your applications—writing
source files and compiling them into bytecode. However, Java as a programming language is just one
component of Java, and it’s the underlying architecture that gives Java many of its advantages, including
platform independence.
The complete Java architecture is actually the combination of four components:
• The Java programming language
• The Java class file format
• The Java APIs
• The JVM
So, when you develop in Java, you’re writing with the Java programming language, which is then
compiled into Java class files, and those in turn are executed in the JVM. In fact, these days the Java language
is just one of the options available if you want to use the rest of the Java platform. Scala, for example, has
generated a great deal of interest as an alternative to the Java language and is only one of many different
languages that use Java technology without also using the Java language.
The combination of the JVM and the core classes form the Java platform, also known as the Java
Runtime Environment (JRE), sits on whatever operating system is being used. Figure 1-1 shows how different
aspects of Java function relative to one another, to your application, and to the operating system.

Figure 1-1. An overview of Java’s role

2
Chapter 1 ■ Going Inside Java

The Java API is prewritten code organized into packages of similar topics. The Java API is divided into
three main platforms:
• Java Platform, Standard Edition (Java SE): This platform contains the core Java
classes and the graphical user interface (GUI) classes.
• Java Platform, Enterprise Edition (Java EE): This platform contains the classes
and interfaces for developing more complex “enterprise” applications; it contains
servlets, JavaServer Pages, and Enterprise JavaBeans, among others.
• Java Platform, Micro Edition (Java ME): In this platform, Java goes back to its
roots. It provides an optimized runtime environment for consumer products such as
Blu-ray disc players, cell phones, and various other types of hardware such as smart
appliances.

The Java Virtual Machine


Before we cover the various aspects of writing powerful Java applications, in this section we’ll spend some
time examining the engine that makes this possible. That engine is the JVM, which is an abstract computing
machine that interprets compiled Java programs.
With other programming languages such as C or C++, a compiler, which is specific to the processor
and often also the operating system, compiles the source code into an executable. This executable is then
self-sufficient and can be run on the machine.
One drawback of this is the lack of portability: code compiled under one operating system can’t be
run on another operating system but must be recompiled on every different system on which it is to run.
In addition, because of vendor-specific compiler features, code compiled under a certain operating system
for a certain processor family (for example, Intel x86, SPARC) may not run on a different type of processor,
even if that processor supports the same operating system.
This problem occurred particularly when people began writing applications for the Internet.
Their applications were intended for users running many different operating systems on various different
platforms through different browsers. The only way to resolve this problem was to develop a
platform-independent language.
In the early 1990s, developers at Sun Microsystems were working on a platform-independent language
for use in consumer electronic devices, which unfortunately was somewhat ahead of its time and was
therefore shelved. With the advent of the Internet, these developers saw a much greater potential for the
language they had created and therefore Java was born.
The key to the portability of the Java language is that the output of the Java compiler isn’t standard
executable code. Instead, the Java compiler generates an optimized set of instructions called a bytecode
program. Bytecodes are sequences of bytes that follow a documented pattern, and we’ll cover them in
more detail later. The bytecode program is interpreted by the runtime system, otherwise known as the
JVM, and a bytecode program generated on one platform can be run on any other platform that has a
JVM installed.
This is generally true even though some specifics of the JVM may differ from platform to platform.
In other words, a Java program that’s compiled on a Linux workstation can be run on a PC or a Mac.
The source code is written in a standard way in the Java language and compiled into a bytecode program,
and each JVM interprets the bytecode into native calls specific to its platform (that is, into a language the
specific processor can understand). This abstraction is the way various operating systems achieve such
operations as printing, accessing files, and handling hardware in a consistent manner across platforms.

3
Chapter 1 ■ Going Inside Java

One feature (and some would say disadvantage) of bytecode is that it’s not executed directly by the
processor of the machine on which it’s run. The bytecode program is run through the JVM, which interprets
the bytecode, and that’s why Java is referred to as an interpreted language. In reality, Java’s days of being
a purely interpreted language are long gone, and the current architecture of most JVM implementations
is a mixture of interpretation and compilation. Interpretation is a relatively slow process compared to
compilation, and it was during the days of purely interpreted Java that it gained a reputation for being slower
than other languages. However, the newer interpreted/compiled hybrid model has largely eliminated the
speed difference in Java programs and those of other programming languages, making it appropriate for all
but the most resource-intensive applications.
Table 1-1 lists compiled versus interpreted languages.

Table 1-1. Compiled vs. Interpreted Languages

Language Compiled or Interpreted? Portable Code? Minimal Execution Overhead?


C++ Compiled No Yes
Java Interpreted Yes No

It’s also worth noting that Java includes an API for interfacing with native applications (those written in
non-Java languages such as C and C++). This API is the Java Native Interface (JNI) API and allows developers
to call code written in a non-Java language from Java code, and vice versa. JNI accomplishes two things, one
of which is to allow your application to take advantage of operating system–specific features that wouldn’t
be available directly through Java. More to the point, JNI allows you to use a compiled language such as C
or C++ for functions used by your Java application where performance is critical. Using JNI does, however,
negate some of the platform independence of Java, as the native code is generally platform-specific, and
therefore the Java code will be tied to the target platform as well if it relies on the native code for some
functionality.
For machine portability to work, the JVM must be fairly tightly defined, and that’s achieved by the JVM
specification. That specification dictates the format of the bytecode recognized by the JVM as well as features
and functionality that must be implemented by the JVM. The JVM specification is what ensures the platform
independence of the Java language; you can find it on the Oracle web site.
In this context, referring to a “JVM” can mean any one of three different things:
• An abstract specification, such as the specification for Java 8.
• A concrete implementation of the specification.
• A runtime execution environment.

Different JVM Implementations


Sun Microsystems, the original company that developed Java, initially provided its own implementations of
various Java technologies, including the JVM, and these were referred to as the reference implementations.
However, Sun (and now Oracle, which acquired Sun in 2010) has also granted licenses that allow other
organizations to create their own implementations. Although the reference implementations of the JVM and
other Java technologies have always been widely used, they’re far from the only implementations available
and licensees include IBM, Apple, Hewlett-Packard, and many other organizations. Following the standards
defined in the JVM specification means that Java code will behave the same in one-on-one implementation
as it does in any other.

4
Chapter 1 ■ Going Inside Java

In 2006, Sun began transitioning Java from its original proprietary model—where Sun tightly controlled
the standards and reference implementation—to an open model. That transition resulted in changes in
how Java was managed, including the following:
• The full source code was made publicly available, or at least as much of it as Sun
could legally publish given associated licensing restrictions.
• Future changes and additions to Java have been handled through the Java
Community Process (JCP) instead of internally within Sun. The JCP is an open and
collaborative process for making decisions about the future of Java, though Sun
(and now Oracle) continued to play a prominent role in the decision-making process.
• The reference implementation of Java is now produced using an open source model
and is referred to as the Open Java Development Kit (OpenJDK).
Many JVM implementations still exist, but the OpenJDK remains the most commonly used implementation.
Why do different versions of the JVM exist? Remember, the JVM specification sets down the required
functionality for a JVM but doesn’t mandate how that functionality should be implemented. In an attempt
to maximize the use of Java, some flexibility to be creative with the platform was given. The important thing
is that whatever the implementation, a JVM must adhere to the guidelines defined by the Java specification.
In terms of platform independence, this means a JVM must be able to interpret bytecode that’s correctly
generated on any other platform.

The JVM As a Runtime Execution Environment


Every time you run a Java application, you’re in fact running your application within an instance of the JVM,
and each separate application you run will have its own JVM instance. So far you’ve seen that Java uses an
interpreted form of source code called bytecode, but how do the instructions you code in the Java programming
language get translated into instructions that the underlying operating system (OS) can understand?
The JVM specification defines an abstract internal architecture for this process. You’ll learn about the
components of this internal architecture in a moment, but at a high level, class files (compiled Java files have
a .class extension and are referred to as class files) are loaded into the JVM where they’re then executed
by an execution engine. When executing the bytecodes, the JVM interacts with the underlying OS through
means of native methods, and it’s the implementation of those native methods that tie a particular JVM
implementation to a particular platform (see Figure 1-2).

Figure 1-2. Role of the JVM

5
Chapter 1 ■ Going Inside Java

In addition to the previous components, a JVM also needs memory in order to store temporary data
related to code execution, such as local variables, which method is executing, and so on. That data is stored
within the runtime data areas of the JVM, as explained next.

The Runtime Data Areas of the JVM


Although the individual implementations may differ slightly from platform to platform, every JVM must
supply the runtime components shown in Figure 1-3.

Figure 1-3. Runtime data area

The Heap
The heap is a region of free memory that’s often used for dynamic or temporary memory allocation. The
heap is the runtime data area that provides memory for class and array objects. When class or array objects
are created in Java, the memory they require is allocated from the heap, which is created when the JVM
starts. Heap memory is reclaimed when references to an object or array no longer exist by an automatic
storage management system known as the garbage collection, which you’ll learn more about later.
The JVM specification doesn’t dictate how the heap is implemented; that’s left up to the creativity of
the individual implementations of the JVM. The size of the heap may be constant, or it may be allowed
to grow as needed or shrink if the current size is unnecessarily large. The programmer may be allowed
to specify the initial size of the heap; for example, on the Win32 and Solaris reference implementations,
you can do this with the –mx command-line option. Heap memory doesn’t need to be contiguous. If the
heap runs out of memory and additional memory can’t be allocated to it, the system will generate an
OutOfMemoryError exception.

The Stack
A Java stack frame stores the state of method invocations. The stack frame stores data and partial results
and includes the method’s execution environment, any local variables used for the method invocation, and
the method’s operand stack. The operand stack stores the parameters and return values for most bytecode
instructions. The execution environment contains pointers to various aspects of the method invocation.

6
Chapter 1 ■ Going Inside Java

Frames are the components that make up the JVM stack. They store partial results, data, and return
values for methods. They also perform dynamic linking and issue runtime exceptions. A frame is created
when a method is invoked and destroyed when the method exits for any reason. A frame consists of an
array of local variables, an operand stack, and a reference to the runtime constant pool of the class of the
current method.
When the JVM runs Java code, only one frame, corresponding to the currently executing method,
is active at any one time. This is referred to as the current frame. The method it represents is the current
method, and the class that includes that method is the current class. When a thread invokes a method
(each thread has its own stack), the JVM creates a new frame, which becomes the current frame, and pushes
it onto the stack for that thread.
As with the heap, the JVM specification leaves it up to the specific implementation of the JVM how
the stack frames are implemented. The stacks either can be of fixed size or can expand or contract in size
as needed. The programmer may be given control over the initial size of the stack and its maximum and
minimum sizes. Again, on Win32 and Solaris, this is possible through the command-line options –ss and
–oss. If a computation requires a larger stack than is possible, a StackOverflowError exception is generated.

Method Area
The method area is a common storage area shared among all JVM threads. It’s used to store such things as
the runtime constant pool, method data, field data, and bytecode for methods and constructors. The JVM
specification details only the general features of the method area but doesn’t mandate the location of the
area or dictate how the area is implemented. The method area may be a fixed size, or it may be allowed to
grow or shrink. The programmer may be allowed to specify the initial size of the method area, and the area
doesn’t need to be contiguous.

Registers
The registers maintained by the JVM are similar to registers on other computer systems. They reflect the
current state of the machine and are updated as bytecode is executed. The primary register is the program
counter (the pc register) that indicates the address of the JVM instruction that’s currently being executed.
If the method currently being executed is native (written in a language other than Java), the value of the
pc register is undefined. Other registers in the JVM include a pointer to the execution environment of the
current method, a pointer to the first local variable of the currently executing method, and a pointer to the
top of the operand stack.

Runtime Constant Pool


The runtime constant pool is similar to a symbol table used in other programming languages. As the name
suggests, it contains constants including numeric literals and field constants. The memory for each runtime
constant pool is allocated from the method area, and the runtime constant pool is constructed when the
JVM loads the class file for a class or interface.

The Garbage Collector


Older languages such as C require the programmer to explicitly allocate and release memory. Memory is
allocated when needed and released when no longer needed by the application.

7
Chapter 1 ■ Going Inside Java

Unfortunately, this approach often causes “memory leaks,” where memory is allocated and for one
reason or another never released. When that takes place repeatedly, the application will eventually run
out of memory and terminate abnormally or at least no longer be able to function. In contrast, Java never
requires the programmer to explicitly allocate or release memory, preventing many of the problems that
can occur. Instead, Java automatically allocates memory when you create an object, and Java will release the
memory when references to the object no longer exist.
Java uses what’s known as a garbage collector to monitor a Java program while it runs and automatically
releases memory used by objects that are no longer in use. Java uses a series of soft pointers to keep track of
object references and an object table to map those soft pointers to the object references. The soft pointers
are so named because they don’t point directly to the object but instead point to the object references
themselves. Using soft pointers allows Java’s garbage collector to run in the background using a separate
thread, and it can examine one object at a time. The garbage collector can mark, remove, move, or examine
objects by changing the object table entries.
The garbage collector runs on its own, and explicit garbage collector requests are generally not
necessary. The garbage collector performs its checking of object references sporadically during the
execution of a program, and when no references to an object exist, the memory allocated to that object
can be reclaimed. You can request that the garbage collector run by invoking the static gc() method in the
System class, though this represents a request that may or may not be honored and there’s no guarantee that
an object will be garbage collected at any given time.

The JVM: Loading, Linking, and Initializing


For the JVM to interpret a Java bytecode, it must perform three steps for the required classes and interfaces:
1. Loading: When the JVM loads a class, it finds a binary representation of a class
or interface and creates a Class object from that binary representation (usually
a class file created by a Java compiler). A Class object encapsulates the runtime
state of a class or interface.
2. Linking: Linking is the process of taking the loaded class or interface and
combining it with the runtime of the JVM, preparing it for execution.
3. Initializing: Initialization occurs when the JVM invokes the class or interface
initialization method.

The First Step


The first thing the JVM does when a stand-alone Java application starts is create a Class object representing
the Java class that contains the public static void main(String[] args) method. The JVM links and
initializes this class and invokes the main() method, and that method drives the loading, linking, and
initializing of any additional classes and interfaces that are referenced.

Loading
The loading process itself is carried out by a class loader, which is an object that’s a subclass of ClassLoader;
the class loader will do some of its own verification checks on the class or interface it’s loading. An
exception is thrown if the binary data representing the compiled class or interface is malformed, if the
class or interface uses an unsupported version of the class file format, if the class loader couldn’t find the
definition of the class or interface, or if circularity exists. Class circularity occurs if a class or interface
would be its own superclass.

8
Chapter 1 ■ Going Inside Java

Two general types of class loader exist: the one supplied by the JVM, which is called the bootstrap
class loader, and user-defined class loaders. User-defined class loaders are always subclasses of Java’s
ClassLoader class and can be used to create Class objects from nonstandard, user-defined sources. For
instance, the Class object could be extracted from an encrypted file. A loader may delegate part or all of the
loading process to another loader, but the loader that ultimately creates the Class object is referred to as the
defining loader. The loader that begins the loading process is known as the initiating loader.
The loading process using the default bootstrap loader is as follows: The loader first determines if it has
already been recorded as the initiating loader of a class corresponding to the desired class file. If it has, the
Class object already exists, and the loader stops. (You should note here that loading a class isn’t the same as
creating an instance of it; this step merely makes the class available to the JVM.) If it’s not already loaded, the
loader searches for the class file and, if found, will create the Class object from that file. If the class file isn’t
found, a NoClassDefFoundError exception is generated.
When a user-defined class loader is used, the process is somewhat different. As with the bootstrap
loader, the user-defined loader first determines if it has already been recorded as the initiating loader of a
class file corresponding to the desired class file. If it has, the Class object already exists and the loader stops,
but if it doesn’t already exist, the user-defined loader invokes the loadClass() method. The return value of
that method is the desired class file, and the loadClass() method assembles the array of bytes representing
the class into a ClassFile structure. It then calls the defineClass() method, which creates a Class object
from the ClassFile structure; alternatively, the loadClass() method can simply delegate the loading to
another class loader.

Linking
The first step in the linking process is verifying the class files to be linked.

Java Class File Verification


Because the JVM is completely separate from the Java compiler, the JVM, which interprets the class file,
has no guarantee that the class file is properly formed or that it was even generated by a Java compiler.
Another problem arises with inheritance and class compatibility. If a given class file represents a class that
inherits from a superclass represented by another class file, the JVM must make sure the subclass class file is
compatible with the superclass class file.
The JVM verifies that each class file satisfies the constraints placed on it by the Java language
specification, although the Java class verifier is independent of the Java language. Programs written in
certain other languages can also be compiled into the class file format and (if everything has been done
correctly) pass the verification process.
The verification process itself happens in four steps:
1. In the first step, the class file is loaded by the JVM and checked to make sure
it adheres to the basic format of a class file. The class file must be the correct
length. The magic number (which identifies a class file as really being a class) is
checked. The constant pool must not contain any unrecognizable information,
and the length of each attribute is checked to be sure it’s the correct length.
2. The second step in the verification process occurs when the file is linked.
The actions performed in this step include ensuring that the final keyword
constraint is respected. This means final classes can’t be subclassed and final
methods can’t be overridden. The constant pool is checked to make sure the
elements don’t violate any language constraints. All field and method references
in the constant pool are validated, and every class except the Object class is
checked to see if it has a direct superclass.

9
Chapter 1 ■ Going Inside Java

3. The third verification step also occurs during the linking phase. Every method
referenced in the class file is checked to ensure it adheres to the constraints
placed on methods by the Java language. The methods must be invoked with the
correct number and type of arguments. The operand stack must always be the
same size and contain the same types of values. Local variables must contain an
appropriate value before they’re accessed. Fields must be assigned values of the
proper type only.
4. The final step in the verification looks at events that occur the first time a method
is invoked and ensures that everything happens according to the specification.
The checks include ensuring that a referenced field or method exists in a given
class, verifying that the referenced field or method has the proper descriptor,
and ensuring that a method has access to the referenced method or field
when it executes.

Preparation
Once the class file has been verified, the JVM prepares the class for initialization by allocating memory space
for the class variables and also sets them to the default initial values. These are the standard default values,
such as 0 for int, false for Boolean, and so on. These values will be set to their program-dependent defaults
during the initialization phase.

Resolution
At this (optional) step, the JVM resolves the symbolic references in the runtime constant pool into
concrete values.

Initialization
Once the linking process is complete, any static fields and static initializers are invoked. Static fields have
values that are accessible even when there are no instances of the class; static initializers provide for static
initialization that can’t be expressed in a single expression. All these initializers for a type are collected by
the JVM into a special method. For example, the collected initializers for a class become the initialization
method <clinit>.
However, when initializing a class, not only must the class initialization method be invoked by the JVM
(only the JVM can call it) but in addition any superclasses must also be initialized (which also involves the
invocation of <clinit> for those classes). As a result, the first class that will always be initialized is Object.
The class containing the main() method for an application will always be initialized.

Bytecode Execution
The bytecode from a class file consists of a series of 1-byte opcode instructions specifying an operation
to be performed. Each opcode is followed by zero or more operands, which supply arguments or data
used by that operation. The JVM interpreter essentially uses a do...while loop that loads each opcode
and any associated operands and executes the action represented by the opcode. The bytecode is
translated into an action according to the JVM instruction set, which maps bytecode to operations
represented by the bytecode as specified by the JVM specifications. This process continues until all the
opcode has been interpreted.

10
Chapter 1 ■ Going Inside Java

The first set of instructions in the JVM instruction set involves basic operations performed on the
primitive data types and on objects. The nomenclature used is generally the data type followed by the
operation. For instance, the iload instruction (iload is merely a mnemonic representation of the actual
instruction) represents a local variable that’s an int being loaded onto the operand stack. The fload
instruction is for loading a local variable that’s a float onto the operand stack, and so on. There are a series
of instructions to store a value of a certain data type from the operand stack into a local variable, to load a
constant onto the operand stack, and to gain access to more than one local variable.
The second set in the instruction set concerns arithmetic operations, and the arithmetic operation
generally involves two values currently on the operand stack, with the result of the operation being pushed
onto the operand stack. The nomenclature is the same as before; for instance, the iadd operation is for
adding two integer values, and the dadd operation is for adding two double values.
Similarly, some operations represent basic mathematical functions (add, subtract, multiply, and
divide), some represent logical operations (bitwise OR, bitwise AND, and bitwise NOT), and some
specialized functions including remainder, negate, shift, increment, and comparison.
The JVM adheres to the IEEE 754 standards when it comes to things such as floating-point number
operations and rounding toward zero. Some integer operations—divide by zero, for instance—can throw
an ArithmeticException, while the floating-point operators don’t throw runtime exceptions but instead
will return a NaN (“Not a Number”—the result is an invalid mathematical operation) if an overflow
condition occurs.
The JVM instruction set includes operations for converting between different types. The JVM directly
supports widening conversions (for instance, float to double). The naming convention is the first type,
then 2, and then the second type. For example, the instruction i2l is for conversion of an int to a long.
The instruction set also includes some narrowing operations, the conversion of an int to a char, for
instance. The nomenclature for these operations is the same as for the widening operation.
Instructions exist for creating and manipulating class and array objects. The new command creates
a new class object, and the newarray, anewarray, and multilinearray instructions create array objects.
Instructions also exist to access the static and instance variables of classes, to load an array component onto
the operand stack, to store a value from the operand stack into an array component, to return the length of
an array, and to check certain properties of class objects or arrays.
The JVM instruction set provides the invokevirtual, invokeinterface, invokespecial, and
invokestatic instructions that are used to invoke methods, where invokevirtual is the normal method
dispatch mode. The other instructions are for methods implemented by an interface, methods requiring
special handling such as private or superclass methods, and static methods. Method return instructions are
also defined for each data type.
Another JVM instruction worth mentioning is invokedynamic, which was added to the JVM
specification for Java 7. Ironically, the instruction actually had little impact on the Java language in
that release, but it did provide the framework for a major change introduced in Java 8, namely, lambda
expressions which are covered in detail in Chapter 3. The older invocation instructions (invokevirtual,
invokeinterface, etc.) only supported what’s referred to as “static linking”; that is, the type of an object
that’s referenced is established at compile time. For example, when invokevirtual is used, the specific
method that’s called is known to exist because the type (class) of the object in which that method is defined
is known. That approach is referred to as static linking because it’s defined at compile time and can’t change
or be substituted later for a different type. In contrast to static linking, invokedynamic supports dynamic
linking, where the type of the object for which a method is invoked is determined at runtime, and any
type is valid as long as it meets certain criteria. Specifically, the method must accept parameters that are
consistent with what’s specified by the invocation, and any data type with a method satisfying that condition
is acceptable. Although invokedynamic didn’t really impact the Java language until Java 8, it did allow for
better implementations of other languages besides Java that use the JVM.
Finally, there’s a collection of miscellaneous instructions for doing various other operations, including
managing the operand stack, transferring control, throwing exceptions, implementing the finally keyword,
and synchronizing.

11
Other documents randomly have
different content
The sermon is simply a co-ordinate part of divine service, not its
governing feature to which all things else must be subordinated. The
early hymns should not be selected with reference to the theme of
the sermon; the last hymn should sum up not so much the ideas of
the sermon as its emotional values.

Unity Based on Purpose. 257

Among heathen people instruction must be the leading purpose of


any meeting held for their benefit; but among well-taught Christian
people, the chief purpose should be worship, to which the sermon
should be simply one of several aids. The hymns should be
emotional, worshipful, and not exclusively didactic, and should
harmonize with the sermon by being subordinated, with the sermon,
to the clearly-conceived worshipful purpose of the entire service. Dr.
Austin Phelps, more than three-fourths of a century ago, enunciated
the right policy: “It aims at unity of worship, not by sameness of
theme, but by resemblance of spirit. It would have a sermon
preceded and followed, not necessarily by a hymn on the identical
subject, but by a hymn on a kindred subject, pertaining to the same
group of thought, lying in the same perspective, and enkindling the
same class of emotions.” To announce the theme of the coming
sermon in the first hymn, to read a Scriptural passage as a basis for
it, to grope around that theme in the prayer, to emphasize another
phase in the second hymn, is a case of professional egotism so
flagrant that its only shocking mitigation is that it is the accepted
clerical estimate of the situation.

Now every service, of whatever form or character, is properly


intended to bring the soul into conscious relation with God. Every
phase of the soul’s activities is to be brought under the influence of
this dominating purpose. As it cannot comprehend God in His
completeness at any one moment, different attributes of His nature
and the varied relation of these several attributes to manifold human
needs furnish an endless abundance of worshipful themes. They will
appeal to the understanding through the truth, to the heart through
an emotional realization of that truth, and to the will by the choices
offered to the soul’s supreme tribunal. Here, then, in this clearly-
conceived phase of worshipful attitude, you find the basis for the
logical unity of the service—a living unity that moves heart and will
as well as reason.

There is in this no fetter to the intellectual activity of the 258


preacher, but rather a fresh stimulus and source of
suggestion. It brings to bear vital forces within the speaker’s own
soul that too often find little exercise, and changes the emotional
elements of the service, the prayer, and the music—now too often
mere haphazard, characterless excrescences—into definite sources
of power for the realization of the desired spiritual results.

A preacher whose heart is a barometer of the spiritual condition of


his people has no difficulty in finding subjects and texts for his
sermons. If the needs of his people press upon him, those needs
furnish an arc light that illuminates the Bible, and a suggestiveness
that brings him an embarrassment of homiletical riches. Given a
clear recognition of a definite immediate need and the consequent
definite purpose, it will not only make sermonizing easy but will
control the rest of the service. Not the theme of the sermon, but the
purpose of the service as a whole, will be the organizing vitality.

II. SUGGESTIVE SELECTIONS OF HYMNS


Here is an earnest pastor who is impressed with the growing
materialism, or worldliness, of his people. How shall be best dredge
the stagnant shallows of their souls? He decides, not upon a single
sermon, but upon a series of services with cumulative power, whose
whole outlook shall be upon the Person and Character of God as the
basis of his claims upon his creatures. There will be sermons upon
these high themes of course, but they will call for noble and elevated
co-ordinate co-operation in the rest of the service. Now these
sermons should all be peculiarly worshipful, but that worship will be
set to different keys.

Hymns for Service on God’s Omnipotence.

The sermon on the Divine Omnipotence calls for a noble enthusiasm.


The hymns should be majestic and joyful. After profoundly 259
worshipful preliminary exercises it will not be wise to sing
Watts’ hymn,

“Let all the earth their voices raise,


To sing the great Jehovah’s praise,
And bless His holy name,”

to the tune “Ariel” for the first hymn in spite of its appropriateness of
thought: first, because it is not sufficiently elevated, and secondly,
because the tune is too light. Watts’ more majestic hymn,

“Before Jehovah’s awful throne,


Ye nations bow with sacred joy,”

sung to “Old Hundredth,” would be more harmonious with the


general purpose of the service. By the time the second hymn is
reached there must be some exhilaration of spirit. It will not be
desirable therefore to select

“All people that on earth do dwell,


Sing to the Lord with cheerful voice”;

first, because it is in exactly the same key of feeling as the previous


hymn; second, because for that reason no tune is quite so fitting to
it as “Old Hundredth,” which is already provided for; and third,
because the presumable intensifying of feeling by this time calls for
a brighter text and more spirited music. But it must be a hymn of
worship, none the less; we choose, therefore,
“Oh, worship the King, all-glorious above;
Oh, gratefully sing His power and His love,”

the interrupted dactylic measure and triple time tune giving both
dignity and movement.

If the prelude was a joyfully majestic composition, the anthem one


of elevated praise—e.g., a “Venite” or a “Jubilate”—the responsive
reading and the choir responses reverent and worshipful, the long
prayer of the preacher exalted with genuine adoration 260
(forgetful of the routine catalogue of petty petitions), and the
Scripture passage noble with inspiring truth, the service might close
at this point as having already realized its prime object of worship.
There must have been something radically wrong in the spirit and
management of it, if the preacher does not find his people
responsive and himself inspiringly attuned to his noble theme. At the
close of his discourse on the Divine Omnipotence, his people will
presumably be ready to sing

“Let all on earth their voices raise,


To sing the great Jehovah’s praise,
And bless His holy name.”

to the exhilarating movement of the tune “Ariel.” The organist’s


postlude will be characterized by a joyful solemnity, some strong
maestoso movement.

Hymns for Service on God’s Love.

A service devoted to the worship of God, as manifested in His love,


offers a wider range of possibilities. Is it the love manifested in the
atonement? there may be the somber element of the crucifixion
combined with its nobly elevated aspects; is it the love manifested to
His children? there will be a chastened ecstasy in the hymns and
prayers; is it the love that consoles and comforts? there will be the
tender and sympathetic development of the theme—each will call for
its own selection of hymns. As the last is perhaps the most difficult,
let us see what program we should prepare for it.

a. Tender Service.

The organ prelude will be soft, sweet music, full of chromatic chords
that melt one into the other, or a tender, emotional melody with soft
accompaniment. The usual opening doxology will give way to an
introit, sung very gently by the choir, set to a text expressing divine
sympathy or a prayer for help. The invocation will be a plea for God’s
manifest presence among His needy people. The first hymn sung by
the congregation will sustain the feeling already established,

“Lord, we come before Thee now, 261


At Thy feet we humbly bow,”

sung to the tune “Aletta” or “Pleyel’s Hymn.” The responsive reading


may be the forty-second and forty-third Psalms. The choir, having
been advised in good time what was desired, sings some
sympathetic setting of the twenty-third Psalm, or of the forty-second
Psalm, or of the hymn “Just as I am.” If the preacher has kept step
in his heart with the emotional progress of his service, the long
prayer will be an expression of the need of the people and of a
tender appreciation of God’s loving sympathy, closing with an
ascription of praise to His limitless love. The people ought now to be
ready to sing

“Love divine, all loves excelling,


Joy of heaven, to earth come down.”

After the discourse, a hymn in direct didactic relation to it may be


sung in a bright and joyous spirit:

“God is love; His mercy brightens


All the path in which we rove.”

The postlude will be tenderly joyous and sympathetic in style.


There are many preachers whose nervous organizations would not
enable them to adjust themselves to so tender an emotional key in
developing the service. On the other hand, many congregations
would not follow it, but would be lulled to sleep by it.

b. Joyful Service.

They would be entirely right in selecting as the opening hymn one of


general praise and worship:

“Come, Thou Almighty King,


Help us Thy name to sing,
Help us to praise”;

or even the quietly majestic hymn,

“Holy, holy, holy, Lord God Almighty!


Early in the morning our song shall rise to Thee.”

The second hymn may be more prayerful and tender: 262

“Guide me, O Thou great Jehovah,


Pilgrim through this barren land,”

or

“When all Thy mercies, O my God,


My rising soul surveys.”

The final hymn may be more didactic:

“God is the refuge of His saints,


When storms of sharp distress invade”;

or the more stirring and forceful

“Give to the winds thy fears;


Hope, and be undismayed”;
or that wonderful paean of faith in the divine love and providence,

“How firm a foundation, ye saints of the Lord,


Is laid for your faith in His excellent word.”

In this case the postlude will be bright and joyous, preferably with
some soft and tender episodical passages.

Hymns for a Missionary Service.

The preacher plans a missionary discourse: what is his order of


service to be?

That means an aggressive, spiritual program whose purpose is


stimulation of enthusiasm, of courage, of conquering faith, of bold
decision.

The organist will be asked to play a bright prelude with pronounced


but dignified rhythm, and striking harmonic progressions. The
anthem by the choir may be based on some text of praise from the
Psalms with stirring, somewhat rhythmical music that will stimulate
the nerves of the people rather than soothe them. The responsive
reading should be a Psalm of triumph, say the ninety-sixth. The long
prayer for once may drop out of the omnibus conventionality and
lead the people in magnifying the irresistible power and the 263
conquering love of God, with enough reference to current
sorrows in the congregation to serve as a contrast, to make the
realization of the strong right arm of God more vivid.

The hymns should be in keeping with this joyous recognition of


God’s invincibility and assured triumph.

The first hymn may be Charles Wesley’s “Oh, for a thousand tongues
to sing.” This is worship—mingled with faith and with aggressive
purpose, it is true, but nevertheless distinctly worship.
An equally appropriate selection from Charles Wesley would be “Ye
servants of God, your Master proclaim.” Care should be taken that
the tune used for either is vigorous and well known. A dull tune for
either would be a stumble on the threshold of the service.

The point in the service has not yet been reached where a distinctly
missionary hymn is called for; aggressiveness in the Lord’s service is
still the mood to be created. There would be a choice between
Shurtleff’s vigorous “Lead on, O King Eternal,” with its specific
dedication of self to any forward movement of the Christian Church,
or Baring-Gould’s marching hymn with its American tune written by
an English composer, “Onward, Christian soldiers,” which can hardly
fail to stimulate the pulses of a presumably already stirred
congregation, unless it is sung in a drawling, unaccented way.

If by this time the congregation is not prepared to be thrilled by an


unexpected missionary sermon, eloquent with an appeal hardly to be
equaled by any other topic connected with the Church’s activities,
there has been something wrong with the preacher or his people.

At the close of the sermon the hearts of the people will be glad to
express themselves either in Smith’s “The morning light is breaking,”
or in Watts’ noble Christianized version of the seventy-second Psalm,
“Jesus shall reign where’er the sun.” For once the organist can pull
out all his stops and play a brilliant but not flippant postlude 264
without disturbing the mind and nerves of thoughtful and
devout people.

In these suggested programs it has been evident that the unity is


one of feeling and not of logic. This gave room for the interest which
the unexpected supplies. There must be progress of feeling as well
as of thought. The long prayer or the music after it, be it organ or
choir or hymn, should be the climax of emotion. It should be allowed
to subside a little during the announcements and offering, in order
to rise to a still higher climax in the sermon and closing hymn.
In a tender, sympathetic service there is more danger of not taking
the audience with you. If the music and the feelings suggested by
the hymns are too quiet and depressing, there is danger of its acting
as a lullaby, putting the people to sleep. Many a preacher wonders
why some of his hearers are asleep before his text is fairly
announced. In nine cases out of ten, it is due to the depressing
character of the music used in the devotional part of the service.

III. IMPORTANCE OF THE TUNES


As has been incidentally suggested in the course of the illustrative
progress, no small importance is to be attached to the selection of
the tunes to be used with the hymns. The preacher cannot always
afford to trust the compiler of the hymnal which he uses. That
learned gentleman does not know what tune the preacher’s people
can sing with a given hymn to the best advantage. He has to meet
the difficulty of providing every hymn with an appropriate tune
without having well-known and effective tunes enough to go round;
he cannot repeat them over and over, but must use less popular
tunes. Who shall judge him harshly, therefore, if in this dilemma he
occasionally follows his own personal taste rather than the vaguely
conceived needs of miscellaneous congregations.

But the minister must study the tunes in his hymnal lest he 265
limit his song service to the small number he happens to
know well. To use a dozen or so tunes again and again will cut the
nerve of musical interest in his musical helpers and in his
congregation as well.

Hence, it is the minister’s task to re-edit the hymnal in part,


remating hymns and tunes in order to secure the greatest results
with his own people. Nor need he suffer with a sense of
presumption. The important consideration is the results of the
singing of hymns in an effective way, not loyalty to his church
hymnal at the expense of those results.

266
Chapter XXI
THE ANNOUNCEMENT AND TREATMENT OF
HYMNS

I. THE ANNOUNCEMENT OF HYMNS


It may seem quite superfluous to give any attention to the mere
announcement of hymns; but in many cases the spiritual success or
failure of the congregational song is determined there. It is generally
assumed that any one can announce a hymn and initiate its singing,
but probably the least successful work of ninety-nine out of a
hundred ministers is their management of the service of song in
their churches. The writer remembers one minister who would baldly
announce the number and then turn round and stare at the choir
and organist until they began to sing. The awkwardness and
helplessness of the man invariably produced a most unfortunate
effect upon the congregation. Many ministers announce the number
and read the first line. It makes no difference whether the first line is
complete in meaning or not; they have identified the hymn.

Like a great many others of their professional brethren, they used


the hymn perfunctorily as a traditionally necessary part of the
service, with which they really had little or nothing to do; that it has
any relation to the needs or the objects they have in view for the
service does not occur to them. The unpardonableness of an aimless
sermon need not be emphasized, but why should it be easier to
forgive a preacher for aimlessly selecting and announcing hymns?
Many churches have hymn boards and even bulletins, making 267
the mechanical interruption caused by the preacher’s
announcement of the numbers unnecessary. The people presumably
[1]
have found the hymn by the time the tune is played through.

Of course, if these devices for announcing the hymn are absent, the
preacher must announce the number. If he does so in a listless,
mechanical way, he will unconsciously give the congregation an
unfortunate emotional keynote, and, in turn, it will sing in a listless,
mechanical way. The psychical and emotional value of the singing of
the hymn is already discounted. If it has been announced in a
joyous, or, at least, in an interested spirit, with only a happy phrase
or two, giving a cue to the spirit in which it is to be sung, the
congregation will respond in kind. Twenty seconds of effective
introduction will make the difference between success and failure.

It should be emphasized that a live preacher will not allow the


regular order of service to prevent needed comment on the hymn as
it is needed. The order of service has advantages, but if it robs the
preacher of freedom and spontaneity, it becomes a curse. Too rigidly
followed it makes for dullness and boredom. The congregation
should not be allowed to feel that any departure from it is a doubtful
liberty on the part of the preacher. Opportunity should be made to
dispel any such idea.

If a hymn is curtly announced, or courteously suggested with a


“please” or a “kindly” (as if to sing it were a special favor to the
preacher), and if no hint is given as to the message to be conveyed,
or as to the feeling which is to be expressed, how can the minister
hope that the merely improvised singing of an unexpected hymn,
perhaps with an unknown tune, will have any stimulating, not to say
spiritual, value? If the hymn is well known, it is probably a great
hymn, and what gathering of saints can rise at a moment’s notice to
its spiritual altitude?
What intelligent minister would presume suddenly to ask a 268
trained elocutionist to read to his audience a poem he had
never before seen? Or what honest lawyer would ask a client to sign
a legal paper involving obligations without explanations or previous
reading? Yet, every Sunday, congregations are asked to sing hymns
they have never noticed, expressing they know not what sentiments,
promises, or consecrations, in the most solemn and exalted manner.
Is it ethical? Is it efficient?

II. THE TREATMENT OF HYMNS


If a congregation is to sing a hymn, not thoughtlessly and
mechanically, but intelligently and with feeling, it must be prepared
for the devout exercise. It is the minister’s task to tune his people up
for the individual hymn, and create the habit of finding meaning and
genuine feeling in all the hymns they sing. Stupid singing is a habit:
why not create a habit of singing thoughtfully and feelingly?

That may be done; but it cannot be done overnight. It will call for
persistent training, for a wealth of resources, and for an unbroken
attitude of genuineness of emotion on the part of the preacher. It is
no small undertaking to transform sleepy church members into sons
of praise.

We may add to the obligations involved still another. If the hymn to


be sung is not merely didactic or meditative, but distinctly emotional
in character, is it not the preacher’s duty to create in those who are
to sing at least the beginnings of the emotions he asks them to
voice?

A rapid sketch of blind Matheson’s experience before writing “O Love


that wilt not let me go” will set the heartstrings of the congregation
quivering in the emotional key of the hymn. A vivid picture of the
death of Christ on the cross in a dozen sentences will inspire a
preacher’s people to sing “Beneath the cross of Jesus” with genuine
emotion. Drawing a picture with rapid touches of the charge of the
Light Brigade as it went to its death at Balaklava, and quoting 269
a few lines of Tennyson’s poem, will stir the pulses for the
singing of “Lead on, O King Eternal.” “Prayer is the soul’s sincere
desire” may be introduced by a few tender sentences on the vital
necessity of prayer to a sincere Christian. A minute’s resume of the
influence of the cross of Christ on an individual life, or on the
upward sweep of the human race under its influence, will give the
people a clue to “In the cross of Christ I glory.” The tender aspect of
the atonement made by Christ for sin may be solemnly suggested
before singing “Alas, and did my Saviour bleed?”

Where a hymn has allusions not likely to be recognized by the


average singer, they ought to be made plain. How many of the
millions who have sung the well-known hymn, “Come, thou Fount of
every blessing,” knew what the word “Ebenezer” signified? Striking
phrases, packed with deep thought and feeling, like Matheson’s

“I lay in dust life’s glory dead,


And from the ground there blossoms red
Life that shall endless be,”

should have their treasures brought to light, lest the average


churchgoer should overlook them. In other words, there should be a
rapid exposition of unusual and also of over-familiar hymns, so that
the congregation may sing with its mind and heart.

The range of possible comment is so wide, and the opportunity of


using it is so limited, that only the most striking and impressive
illustrations should be considered for actual use. Rhetorical and
anecdotal illustrations should be used sparingly—only when they
promote an exalted and distinctly spiritual state of mind. They are
apt to be prolix, to distract the mind from spiritual contemplation.
They are permissible with joyous, aggressive, victorious hymns
rather than with those that are tender, emotional, subjective.
The inexorable limitations of time must always be borne in 270
mind. When a hymn is announced the people expect to sing,
not to listen to a hymnological dissertation or to a long-winded
anecdote. The simile or metaphor, or other oratorical comment, must
explode with a very short fuse of preliminary remark. The anecdote
must be compact, shorn of unessential preface or background, and
reach its peak of interest, or of appeal to feeling, with the
succinctness of an epigram. Better limit the illustrations and
comments to those that can gracefully and lucidly be uttered in one
or rarely two minutes.

Discussions and illustrations of hymns are often confined to the


hymns as hymns, which is rarely necessary. It is not the hymn that
needs emphasis, much less its writer: it is the message, the burden,
the feeling of the hymn that is to be enforced. An instance of the
saving of a “down and outer” from the Jerry McAuley mission in New
York, or the Pacific Garden mission in Chicago, will create more
responsiveness to “Rescue the Perishing” than biographical facts
about Fanny Crosby or about the composer, W. Howard Doane. The
anecdote of missionary success from the last missionary bulletin or
magazine will lead a Congregation to sing “Jesus shall reign where’er
the sun” more enthusiastically than an explanation of Watts’ having
metricized the seventy-second Psalm with a free hand, making the
Jew, David, sing like a Christian. Illustrating the sense rather than
the form of the hymn will be found very much more thrilling to the
people.

In evening services of song, or in midweek lectures, historical


backgrounds will be very helpful and interesting. A series of lectures
on the great hymns of the Church, or even a general survey of the
development of our Christian hymnody, will lay the foundations of a
more intelligent song.

In such services, anecdotal illustrations may have a large place.


They need not be emotional under such circumstances, just so they
add interest and understanding.
As an occasional variation in the introduction of the hymn, 271
why not have the congregation read it? “It is not done?” All
the more reason for doing it! They will get more actual values out of
the reading of the hymn and its subsequent singing than in any
other way; the very unusualness of the method will give additional
effectiveness. Single stanzas can be most impressively treated in this
manner. In singing Isaac Watts’ great hymn, “When I survey the
wondrous cross,” ask the people to read the third verse softly,

“See, from his head, his hands, his feet,


Sorrow and love flow mingled down!
Did e’er such love and sorrow meet,
Or thorns compose so rich a crown?”

and then sing it very softly and note the effect.

The same method may be used with Mrs. Alexander’s children’s


hymn, “There is a green hill far away,” which adults have adopted for
their own; have them read the last verse,

“Oh, dearly, dearly has He loved,


And we must love Him too,
And trust in His redeeming blood,
And try His works to do,”

and then sing it quite emotionally.

A great many people deprecate the minister’s reading of the hymns.


But that is because so few ministers are able to read hymns with any
degree of impressiveness or reality. Perhaps half the ministers who
read them leave no desirable impression whatever as the result, for
the reading has been without even a thoughtful sense of the
meaning of the hymn, much less of its emotional force. To allow
one’s voice to fall at the end of every line, or to make a habit of
having a rising inflection at the end of each first line and a falling at
the end of each second, without variation, is so vile, from an
elocutionary standpoint, that one cannot wonder that the general
congregation prefers its omission.

On the other hand, if the minister’s mind and heart are 272
profoundly awake to the thought and feeling of the hymn
that is to be used, if the minister has a definite purpose which he
wishes to realize through the singing of that hymn, if the whole song
service is thoroughly vital and earnest, he cannot help reading the
hymn in such a way as to impress and interest his people. One need
not be a well-trained elocutionist to do this. The genuine feeling will
develop a natural elocution and will even neutralize faulty habits and
mannerisms of reading that would otherwise make it unendurable.

The fact that the hymn is a familiar one may be only an additional
reason for reading it, instead of being an imperative reason for
omitting its reading. As coins long in circulation often lose their
superscription, these familiar words often lose their meaning and
reality by constant use, and these may be restored by intelligent and
emotional reading.

A mere habit of reading a hymn through is sheer mechanism, the


fatal enemy of interest. The situation, the purpose in view, the
character of the service and the time allotted to it, even the
preacher’s own passing mood—all are factors that need to be
considered.

At this point it is well to drop a word of warning against the


unintelligent omission of verses. Some ministers invariably restrict
the number to be sung to three or four. If there are five verses, they
invariably omit the fourth, or announce, “We will sing the first three
verses,” no matter what the development of thought may be. One of
the most painful manifestations of ministerial thoughtlessness and
indifference to the congregation’s share of the service, is this brutal
mutilation of the hymns. The preacher wishes a little more time for
his sermon, so he robs God and his people of some of their worship
by singing the pitiful remains of a hymn he has deprived of its unity,
its progress of thought, and perhaps of its best stanzas. Or he has
preached too long and closes with a single verse of some great
hymn, unwittingly losing the best climax his sermon could 273
have had. Because of the same egotism and his obsequious
regard for the tyranny of the dinner hour, he cuts out the reading
and proper introductions of his hymns throughout the service.

The irony of the situation is that by this neglect of his hymns the
preacher fails to create the enthusiasm and responsiveness of his
hearers essential to the larger success of his sermon. “There is that
withholdeth more than is meet, but it tendeth to poverty.” (Prov.
11:24.)

It may well be that some of the ministers who read this practical
section will throw up their hands at the idea of working out the
rather daunting array of suggestions for exploiting the hymn in their
church work. The pastor’s task is such a varied one, with such a
mass of details, all of seeming importance, that he is in danger of
wasting time on comparative trifles, of “puttering” around, feeling
very busy while accomplishing little. A common remark at the close
of the day is, “I’ve been busy as a nailer all day and can’t see that I
have accomplished anything!”

It is this time that is lost by lack of concentration which could quite


comfortably be devoted to hymnological studies. The difficulty in
most cases is not lack of time, but lack of interest, lack of realization
as to how great a contribution the hymn service can make to the
success of his work.

God has put into the throat of every member of this preacher’s
congregation a marvelous musical instrument with a wide range of
tones and of extremely appealing cadences, of great power to
express the emotions of the heart of the singer, and to suggest and
stimulate the feelings of the minds and hearts of the hearers: is the
minister justified in neglecting the opportunity it offers to arouse and
quicken the mental and spiritual natures of the people for whose
religious life he is responsible?

Is it not a crying piece of egotism, in view of the proven efficiency of


hymn singing, to depend exclusively on his own preaching for 274
the realization of the spiritual ends to which his life is
devoted? When ministers realize the positive power the hymn
service can exert, they will not begrudge the occasional hours for
studying and planning it which are necessary to its full success. That
success will create

A SINGING CHURCH

275
EPILOGUE

Let us hear the conclusion of the whole matter. Eccl. 12:7.

In traversing the long history of the human use of song in religious


services, rites, and ceremonies, we have found that

1. The hymn has been recognized in every age, in every generation,


by every race, whether savage or cultured, under every sky, as an
expression of religious emotion, and as the generator of such
emotion.

2. Religious emotions are of various types. It may be the


earnestness of strong conviction; it may be the hot indignation
against sin and evil, against neglect of the soul’s highest obligations.
It may be the depressing sense of conscious unworthiness, rising
into repentance for sin, into the tenderness of grateful recognition of
the divine love and forgiving grace, expressed in tears, joy over the
assurance of salvation expressed in beaming countenance or in
ejaculations of delight, or even in shouts of victory. The human heart
becomes an Æolian harp from which the winds of the Spirit of God
evoke an infinitude of melodies, grave and solemn, tender and
sweet, joyous and triumphant, or vigorous and inspiring,—a very
symphonic orchestra.

3. As an expression of religious emotion the hymn has been effective


in moving the human will, stubborn in its revolt against God, by
intensifying the mental and spiritual power of religious ideas.
4. The religious idea is primary, of course, but its emotional response
in the heart gives it vitality. It is the team of idea and its 276
normal emotion that exerts the power of the hymn. An
abstract idea, abstract because its emotional reflex has been
abstracted, has no motive power.

5. In the effective use of the hymn the clear apprehension of its


ideas must be enforced by the vital reproduction of the original
emotion of its writer which urged its composure. A dry hymn written
without vitalizing feeling has no power to inspire; it gives no sense
of reality. Dry sermons, not pollinated by emotional vigor, can bear
no fruit. The effectiveness of sermon or hymn will be determined by
the intensity of the feeling behind it.

6. The emotional appeal must be genuine, both writer and singer


must be sincere. Artificial emotion, the mere pretense of a feeling
that does not exist, has no power. It is not merely unappealing, it is
offensive.

7. But emotion necessarily implies an intelligence and a susceptibility


to be moved—in other words, a personality. It also implies that one
person’s feelings can call forth like emotions in other persons. The
merely outward expression may even create a like emotion among
others who do not fully apprehend the primary idea that set the
original emotion to vibrating, creating a very contagion of feeling.

8. It follows that in actual aggressive work, largely depending on


emotional transmission, the minister or the leader must supply the
initiating impulse. If the minister has a dry mind—there are ministers
who desiccate every topic they discuss—religious ideas suffer a
blight of aridity, killing all sense of reality, this sense of reality being
the sine qua non of all spiritual effectiveness. If he is fortunate in
having a vivid imagination and a heart responsive to religious truth,
he can multiply his mental gifts twentyfold by intensifying the truths
he expresses.
9. Treated in this way, the hymn becomes the peer of the sermon in
influencing power, and assures the minister eager for spiritual results
a large harvest of souls, saved and spiritualized.

277
REFERENCES AND NOTES

INTRODUCTION
[1]
Genesis 4:21, 23.

[2]
Genesis 31:27.

[3]
Exodus 15:1-21.

[4]
Numbers 21:16, 17.

[5]
Psalm 90.

[6]
Joshua 6:16.

[7]
Judges 5:1-31.

[8]
I Samuel 2:1-16.

[9]
I Samuel 10:5.
[10]
I Chronicles 9:22; 11:4, 11:5.

[11]
Mark 14:26.

[12]
Acts 16:25.

[13]
Colossians 3:16.

[14]
James 5:13.

[15]
Revelation 5:9; 7:9-12; 11:15-18; 14:2,3; 15:3,4; 19:1-7.

CHAPTER I
[1]
Dr. Phelps goes on to say, “Yet the greatest of these, that grace
which above all else vitalizes a true hymn, is that which makes it
true—its fidelity to the realities of religious experience.”

[2]
“A hymn must have a beginning, middle, and end. There should
be a manifest graduation in the thoughts, and their mutual
dependence should be so perceptible that they could not be
transposed without injuring the unity of the piece; every line
carrying forward the connection, and every verse adding a well-
proportioned limb to a symmetrical body. The reader should
know when the strain is complete, and be satisfied, as at the
close of an air in music.” (James Montgomery.)
[3]
Dr. Parks, back in 1857, remarks: “That is not always the best
church song which sparkles most with rhetorical gems. There are
spangled hymns which will never excite devotional feeling.”

[4]
Sung at President McKinley’s funeral.

[5]
Greece never had a sacred book, she never had any symbols, any
sacerdotal caste organized for the preservation of dogmas. Her
poets and her artists were her true theologians. (Renan, in
Studies in Religious History.)
278
[6]
“Even when deeds and events of an innocent and pure
character are thus sung, there is nothing more of spiritual
worship in it than in the recitation of an epic poem. The singer
confesses no need, asks no blessing, reveals no yearning,
expects no response. There is no communion of thought and
feeling, no aspiration for purity, no laying hold of moral strength.”
(Rev. G. O. Newport, a missionary in India, quoted in The Hymn
Lover.)

CHAPTER II
[1]
The instinct to use song in worship was recognized so long ago as
1695 by Dr. Hickman: “There never was any land so barbarous,
or any people so polite, but have always approached their gods
with the solemnity of music and have expressed their devotions
with a song.” (Quoted by Dr. A. S. Hoyt in his Public Worship for
Non-Liturgical Churches.)
[2]
“Our hymns spring out of religious experience at its best, and they
tend to lift experience to its highest levels. The very cream of
truth and of soul life is gathered into them. They contain the
refined riches, the precious essences, the cut and polished jewels
of Christianity in all ages. They are truly prophetic, the records of
the insight and intuition and rapture of the seer and the saint.”
(Dr. Waldo S. Pratt, in Musical Ministries. [New York: Revell Co.,
1915.] Used by permission.)

[3]
Henry Ward Beecher placed a high value on the song service of
the church: “I have never loved men under any circumstances as
I have loved them while singing with them; never at any other
time have I been so near heaven with you, as in those hours
when our songs were wafted thitherward.”

[4]
“In all great religious movements the people have been inspired
with a passion for singing. They have sung their creed: it seems
the freest and most natural way of declaring their triumphant
belief in great Christian truths, forgotten or denied in previous
times of spiritual depression and now restored to their rightful
place in the thought and life of the Church. Song has expressed
and intensified their enthusiasm, their new faith, their new joy,
their new determination to do the will of God.” (Dr. W. R. Dale.)

[5]
Pratt, Musical Ministries.

[6]
Ephesians 5: 18-20.

[7]
Colossians 3: 16.
[8]
I Corinthians 14: 15.

[9]
Over three-quarters of a century ago, this lament was made by a
prominent New England minister: “Many a man, who carefully
interrogates his own experience, will confess that, while the voice
of public prayer readily engages his attention and carries with it
his devout desires, it is not so with the act of praise; that he very
seldom finds his affections rising upon its notes to heaven—very
seldom can he say at its close that he has worshiped God. The
song has been wafted near him as a vehicle for conveying
upward the sweet odor of a spiritual service, but the offering has
been withheld, and the song ascends as empty of divine honors
as a sounding brass or a tinkling cymbal.” (Rev. Daniel L. Furber,
in Hymns and Choirs.)

CHAPTER III
[1]
“To get behind the hymnbook to the men and women who wrote
its contents, and to the events, whether personal or public, out
of which it sprang and which it so graciously mirrors, is to enter a
world palpitating with human interest. For a hymnbook is a
transcript of real life, a poetical accompaniment to real events
and real experiences. Like all literature that counts, it rises
directly out of life.” (Frederick J. Gillman, in The Evolution of the
English Hymn. [New York: The Macmillan Co., 1927.] Used by
permission.)
279
[2]
J. Balcom Reeves, The Hymn in History and Literature.
(New York: D. Appleton-Century Co., 1924). Used by permission.
[3]
“There is an inclination to fence in what are called ‘literary lyrics,’
as if to fence out singing lyrics! Now there is, of course, a
distinction between poems meant to be sung and poems written
in the pattern of lyrical poetry, but never meant to be sung; but
the terminology which classes one kind as literary, thereby
implying that the other kind is not of the realm of literature, is
inaccurate and unhappy.” Ibid.

[4]
“In his volume, The English Lyric, Professor Felix E. Schelling
virtually disposes of the hymn with the remark that ‘we may or
may not “accept” certain hymns, but we do not have to read
them.’ That is readily granted—unless, of course, one wishes to
know them or to write just criticism about them.” Ibid.

[5]
“Frequently a hymn is a prayer; and it is a rule for the structure of
prayers that they exclude all those recondite figures, dazzling
comparisons, flashing metaphors, which, while grateful to certain
minds of poetic excitability, are offensive to more sober and staid
natures, and are not congenial with the lowly spirit of a suppliant
at the throne of grace. A simile may be shining, but it may not be
exactly chaste; and a hymn prefers pure beauty to bedizening
ornament.” (Dr. Edwards A. Park, in Hymns and Choirs.)

[6]
These numbers, of course, refer to the number of syllables in a
line.

CHAPTER IV
[1]
The vagaries of credit for writing given hymns is illustrated in the
appearance of the intensely Calvinistic Toplady’s name as the
writer of Charles Wesley’s intensely Arminian “Blow ye the
trumpet, blow.”

[2]
Those who care to make a fuller study of the revision of hymns
than the following discussion affords are referred to the full
treatment of the subject, and to the abundant cases cited, by
Professor Edwards A. Park, D.D., of Andover Theological
Seminary, in Hymns and Choirs, issued in 1860 by Drs. Austin
Phelps, Edwards A. Park, and Daniel L. Furber. The lapse of years
has in no way diminished the value of this volume. It is
unfortunately out of print and inaccessible to the average pastor,
outside of public libraries.

CHAPTER V
[1]
“But the emotional life, strongest, no doubt, in youth, remains a
lifelong element of personality and especially of the religious
personality. Feeling is not merely an integral part of religious
experience, it is central, vital, its inmost core. William James
speaks of it as the deeper source of religion, and says that
‘philosophical and theological formulas come below it in
importance. It is the dynamic factor in the religious life. When it
is absent, religion degenerates into mere formalism or barren
intellectualism.’” (Gillman, in The Evolution of the English Hymn.)

[2]
Rev. Louis F. Benson, D.D., in The Hymnody of the Christian
Church. (New York: Harper and Bros., 1927.) Used by permission.
280

CHAPTER VII
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like