Skip to content

Tiny typos in Date Time articles ( https://dev.java/learn/date-time/ ) and Reflection articles ( https://dev.java/learn/reflection ) #191

@willy-b

Description

@willy-b

Thanks for the excellent content!

Just sharing a few small typos I found in case the team wants to clean them up in the next version.


The following code, **efines** the departure time for a flight from San Francisco to Tokyo as a [ZonedDateTime](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/ZonedDateTime.html) in the America/Los Angeles time zone.

efines should be defines .

Image
Image

has a typo, "refence" instead of "reference."

Image

there are a few issues.

First, a small typo in:

Note that there are restrictions on the members you can make accessible, if there are in other modules. You can check the page [Reflective Access with Open Modules and Open Packages](https://dev.java/learn/modules/opening-for-reflection/) for more information.

That is, "if there are in other modules", "there" should be "they." (see screenshot below, shared with one more example).

Image

Then for: "This codes makes the field nameField accessible, despite being private."
It seems it should be "This code makes" instead of "This codes makes" (with an extra "s" on "codes") (see screenshot above).

Finally, in two code snippets, the "toString()" method for the User class is overridden, and both of them have a typo in the String returned.
That is, in two places:

    public String toString() {
        return "User[name='" + name + "]"; // missing single quote before square bracket on right side of name
    }

should be:

    public String toString() {
        return "User[name='" + name + "']"; // single quote added before square bracket on right side of name
    }

A side note, in the example, it is not mentioned that,
for

Field nameField = userClass.getDeclaredField("name");

NoSuchFieldException must be caught or declared to be thrown,
and

nameField.set(maria, "Mary");

IllegalAccessException must be caught or declared to be thrown, which might also be worth mentioning.

Image

In

You can still get access to such a method and invoke it, by first calling [method.setAccessible(true)](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/reflect/Method.html#setAccessible(boolean)) on it. 
This call may fail in case you are trying to invoke a method from a class in another module, 
due to the restrictions on the class members a module. You can check the page [Reflective Access with Open Modules and Open Packages](https://dev.java/learn/modules/opening-for-reflection/) for more information.

Not sure what wording exactly was intended to be written for "due to the restrictions on the class members a module," which is not grammatically correct. It may be missing a preposition before "a module" or might be a leftover fragment that should simply be removed. Perhaps the rest of the sentence prior is fine by itself, e.g. "This call may fail in case you are trying to invoke a method from a class in another module," because the package containing the class of interest may not be opened or exported by the other module, which is already explained by the link given in the next sentence.

Image

Also "But by doing so you loose the type safety of calling the method directly."
"loose" should be "lose" in this case.

Image

Thanks so much for the all the content!

Bit hesitant to bother you with the reports of the typos and other little issues, but if I were hosting this I would want these reported (and they are very easy to clean up), so letting you know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions