This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Getting started with Java programming language and have Ashish Sarin & J Sharma on-line!
See this thread for details.
Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Books by Douglas Dunn  RSS feed

 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently I have come across some sample chapters of two very interesting (though slightly dated) books written by Douglas Dunn that take a very unique perspective on the Java language: Java Rules (volume 1, published) and Java Rules, Volume 2: Mastering the Fundamentals of the Java Programming Language (only in ebook format). The author seems to have posted to this forum as "Doug Dunn" ages ago. I would very much like to read his books but they seem to have gone out of print and pdfs are nowhere to be found on the internet.
Also he seems to have had two websites: javarules.com and javaspec.org (that seems to have at some time bundled the two books as a Wiki book named "Raw Java"), but both are down and archive.org can't help me recover any of the books he wrote.

Does anyone still have one or more of these books and can share them with me or know how to get in contact with Douglas?
I would be very delighted!
Rens
 
Liutauras Vilda
Marshal
Posts: 3669
163
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked ebay.co.uk? I can see at least one of those on sale (second hand).

Could you tell us a bit more in details what is so unique there what couldn't be found in other popular nowadays books?

 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:Have you checked ebay.co.uk? I can see at least one of those on sale (second hand).

Could you tell us a bit more in details what is so unique there what couldn't be found in other popular nowadays books?



Hi Liutauras,

Thanks for replying so quickly.

I was searching for some material on the static keyword and found it rather difficult understanding why it cannot be applied to top-level classes as applying it to an inner class makes it a "top-level entity". Reading the an excerpt (https://www.pearsonhighered.com/samplechapter/0201709163.pdf) helped me a lot and got me interested into this book (which I am indeed going to try to order 2nd hand!) but also made me wonder about the other volume and the 2-in-1 volume (which might contain a more recent volume 1?).

I have not found any book yet that clearly explains the rules of the java programming language other than the JLS (which is perhaps a bit too technical), the Java tutorial (which is a tutorial), and Sybex OCA/OCP course books (which are more than incomplete considering the rules set and contain many many errors). Dunn's book seems to be really aimed at the understanding and explaining the ruleset of the language, so that's what got me interested..
 
Campbell Ritchie
Sheriff
Posts: 53595
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rens van Bilthoven wrote:. . . I was searching for some material on the static keyword and found it rather difficult understanding why it cannot be applied to top-level classes as applying it to an inner class makes it a "top-level entity". . . . .
Where did you find that? Making a nested class static doesn't make it top level.

And welcome to the Ranch
 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Rens van Bilthoven wrote:. . . I was searching for some material on the static keyword and found it rather difficult understanding why it cannot be applied to top-level classes as applying it to an inner class makes it a "top-level entity". . . . .
Where did you find that? Making a nested class static doesn't make it top level.

And welcome to the Ranch


Hi Campbell,

Thanks! I found it over here: https://jcp.org/aboutJava/communityprocess/maintenance/JLS/innerclasses.pdf See the first paragraph under the header "Members that can be marked static". This is exactly where the table that is listed in the sample chapter from Dunn's book comes in handy since it lists entities that can be declared static (making them top-level entities). As I understand it however, there is a distinction between a top-level class and a class that is a top-level entity. Classes that are top-level entities include top-level classes but not vice versa. Maybe this is not universally agreed upon but for me it seemed enough of an explanation to understand the phrase from the Inner Classes specification. Also https://blogs.oracle.com/darcy/entry/nested_inner_member_and_top is very insightful.
Additionally note that declaring an *inner* class static should make it a top-level entity while declaring a local inner class or an anonymous class in a static context does not do so.
 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rens van Bilthoven wrote:Hi Campbell, ...

Actually, I felt still a bit unsure about my answer so I looked through the inner classes specification and found this at the beginning: "In addition, the programmer can define a class as a static member of any top-level class. Classes which are static class members and classes which are package members are both called top-level classes.". So please forget about the distinction between top-level entities and top-level classes which I suggested before. Looking through the JLS i found this: "7.6 Top Level Type Declarations .... It is a compile-time error if a top level type declaration contains any one of the following access modifiers: protected, private, or static.". So maybe we should see the distinction beteen "top level type declarations" and "top level classes"? Or maybe the notion of what constitutes a top-level entity has changed over the years? In any case I think it will still be safe to consider a static inner class as being similar to a top-level class in that it does not hold references to enclosing instances..
 
Campbell Ritchie
Sheriff
Posts: 53595
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name has changed. That link you gave is for Java1.1 and is dated 1997. The current version of the Java® Language Specification says,
Class declarations define new reference types and describe how they are implemented (§8.1).

A top level class is a class that is not a nested class.

A nested class is any class whose declaration occurs within the body of another class or interface.
So a static nested class is no longer called top‑level. A class is a kind of type; type includes classes, enumerated types, interfaces and annotated types, so the prohibition of using private protected or static applies to all those types.
 
Campbell Ritchie
Sheriff
Posts: 53595
127
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rens van Bilthoven wrote:. . . In any case I think it will still be safe to consider a static inner class as being similar to a top-level class in that it does not hold references to enclosing instances..
I am afraid that is incorrect. Find the chapter in Joshua Bloch's Effective Java™ called Favour static nested classes over non-static or similar. There you will find that public static nested types can easily be used outwith their declaring type whereas inner classes (=not static) are only easy to use inside their containing object. So inner classes are often marked private. You will find the same sort of thing in Thinking in Java by Bruce Eckel. That does not mean a static nested class is a top‑level type, however. It retains a reference to its enclosing type; like anything static it belongs to its enclosing type. You can see that if you use the javap tool in the /jre/lib directory of your installation location:-
[critchie@campbellsComputer lib]$ javap -c -cp ./rt.jar java.util.Map.Entry
Compiled from "Map.java"
public interface java.util.Map$Entry<K, V> {
  public abstract K getKey();

  public abstract V getValue();

  public abstract V setValue(V);

  public abstract boolean equals(java.lang.Object);

  public abstract int hashCode();

  public static <K extends java.lang.Comparable<? super K>, V> java.util.Comparator<java.util.Map$Entry<K, V>> comparingByKey();
    Code:
       0: invokedynamic #1,  0              // InvokeDynamic #0:compare:()Ljava/util/Comparator;
       5: checkcast     #2                  // class java/io/Serializable
       8: checkcast     #3                  // class java/util/Comparator
      11: areturn

  public static <K, V extends java.lang.Comparable<? super V>> java.util.Comparator<java.util.Map$Entry<K, V>> comparingByValue();
    Code:
       0: invokedynamic #4,  0              // InvokeDynamic #1:compare:()Ljava/util/Comparator;
       5: checkcast     #2                  // class java/io/Serializable
       8: checkcast     #3                  // class java/util/Comparator
      11: areturn

  public static <K, V> java.util.Comparator<java.util.Map$Entry<K, V>> comparingByKey(java.util.Comparator<? super K>);
    Code:
       0: aload_0
       1: invokestatic  #5                  // Method java/util/Objects.requireNonNull:(Ljava/lang/Object;)Ljava/lang/Object;
       4: pop
       5: aload_0
       6: invokedynamic #6,  0              // InvokeDynamic #2:compare:(Ljava/util/Comparator;)Ljava/util/Comparator;
      11: checkcast     #2                  // class java/io/Serializable
      14: checkcast     #3                  // class java/util/Comparator
      17: areturn

  public static <K, V> java.util.Comparator<java.util.Map$Entry<K, V>> comparingByValue(java.util.Comparator<? super V>);
    Code:
       0: aload_0
       1: invokestatic  #5                  // Method java/util/Objects.requireNonNull:(Ljava/lang/Object;)Ljava/lang/Object;
       4: pop
       5: aload_0
       6: invokedynamic #7,  0              // InvokeDynamic #3:compare:(Ljava/util/Comparator;)Ljava/util/Comparator;
      11: checkcast     #2                  // class java/io/Serializable
      14: checkcast     #3                  // class java/util/Comparator
}
Note there is no mention of a class called Entry, nor a file called Entry.java. It says compiled from Map.java and always calls the interface Map$Entry. So you can't call it top level.

I think the discussion has gone beyond books, so I shall duplicate it in another forum.
 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aah, thanks for sorting that out! I guess that is always the risk of using old documents..

Still I think the old inner classes specification is very insightful to read (holding this in mind) since it groups together much authorative information on one subject in a readable manner (unlike the modern language specification).
Of course if anyone can point me to similar modern resources I (a bit less technical than the JLS) would greatly appreciate it!
 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ritchie, thanks for the extensive explanation!

Rens van Bilthoven wrote:. . . In any case I think it will still be safe to consider a static inner class as being similar to a top-level class in that it does not hold references to enclosing instances..


I was indeed not careful here, I should have written static nested class as you indicated.

Campbell Ritchie wrote:
Rens van Bilthoven wrote:. . . In any case I think it will still be safe to consider a static inner class as being similar to a top-level class in that it does not hold references to enclosing instances..
I am afraid that is incorrect. Find the chapter in Joshua Bloch's Effective Java™ called Favour static nested classes over non-static or similar. There you will find that public static nested types can easily be used outwith their declaring type whereas inner classes (=not static) are only easy to use inside their containing object. So inner classes are often marked private. You will find the same sort of thing in Thinking in Java by Bruce Eckel. That does not mean a static nested class is a top‑level type, however. It retains a reference to its enclosing type; like anything static it belongs to its enclosing type. You can see that if you use the javap tool in the /jre/lib directory of your installation location:-
...


I cannot yet understand the JVM instructions you have posted but I'll take your word that there is some sort of reference in there. I assume that this is not a reference to any enclosing instance right? Is it some sort of reference to a static entity, here being the enclosing class? (I know only of references to static methods)
 
Rens van Bilthoven
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rens van Bilthoven wrote:
I cannot yet understand the JVM instructions you have posted but I'll take your word that there is some sort of reference in there. I assume that this is not a reference to any enclosing instance right? Is it some sort of reference to a static entity, here being the enclosing class? (I know only of references to static methods)


Maybe there is a bit of a misunderstanding here, at least from my side: I was thinking when using the term "reference" of a this reference in an inner class like Outer.this while you are aiming at the reference to the outer class in the static nested class's name and the namespace that is used for accessing the nested class.
 
Campbell Ritchie
Sheriff
Posts: 53595
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is what I was thinking of. That is why you rarely see public inner classes and often see public static nested classes. The static variety is easier to use outside its enclosing type.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!