Win a copy of Rust Web Development this week in the Other Languages forum!

Daniel Fernandez Boada

Greenhorn
+ Follow
since Jan 21, 2016
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Fernandez Boada

Hi,
I am a bit puzzle with the next code derived from the sybex OCP study guide:



while addValues returns an undedictable result, addValues2 always returns a nice sorted list.
How come? Is addValues2 not executed in parallel? And if it is in parallel, what kind of sorcery is this that allows parallel operations ending in a sorted list?

Thanks in advance for any clarification
2 months ago
Hi Jessy,
I feel I'm so silly...
jdeps uses 1.8 while the java comand points to the 11, hence the confussion!
I had only checked the version of java assuming that all the other commands would also use the same version. Apparently not.

C:\Users\xxx>jdeps -version
1.8.0_221

C:\Users\xxx>java -version
java version "11.0.8" 2020-07-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)

Yes... -h is different in my PC:

C:\Users\danielfernandez>jdeps -h
Usage: jdeps <options> <classes...>
where <classes> can be a pathname to a .class file, a directory, a JAR file,
or a fully-qualified class name.  Possible options include:
 -dotoutput <dir>                   Destination directory for DOT file output
 -s           -summary              Print dependency summary only
 -v           -verbose              Print all class level dependencies
                                    Equivalent to -verbose:class -filter:none.
 -verbose:package                   Print package-level dependencies excluding
                                    dependencies within the same package by default
 -verbose:class                     Print class-level dependencies excluding
                                    dependencies within the same package by default
 -cp <path>   -classpath <path>     Specify where to find class files
 -p <pkgname> -package <pkgname>    Finds dependences matching the given package name
                                    (may be given multiple times)
 -e <regex>   -regex <regex>        Finds dependences matching the given pattern
                                    (-p and -e are exclusive)
 -f <regex>   -filter <regex>       Filter dependences matching the given pattern
                                    If given multiple times, the last one will be used.
 -filter:package                    Filter dependences within the same package (default)
 -filter:archive                    Filter dependences within the same archive
 -filter:none                       No -filter:package and -filter:archive filtering
                                    Filtering specified via the -filter option still applies.
 -include <regex>                   Restrict analysis to classes matching pattern
                                    This option filters the list of classes to
                                    be analyzed.  It can be used together with
                                    -p and -e which apply pattern to the dependences
 -P           -profile              Show profile or the file containing a package
 -apionly                           Restrict analysis to APIs i.e. dependences
                                    from the signature of public and protected
                                    members of public classes including field
                                    type, method parameter types, returned type,
                                    checked exception types etc
 -R           -recursive            Recursively traverse all dependencies.
                                    The -R option implies -filter:none.  If -p, -e, -f
                                    option is specified, only the matching dependences
                                    are analyzed.
 -jdkinternals                      Finds class-level dependences on JDK internal APIs.
                                    By default, it analyzes all classes on -classpath
                                    and input files unless -include option is specified.
                                    This option cannot be used with -p, -e and -s options.
                                    WARNING: JDK internal APIs may not be accessible in
                                    the next release.
 -version                           Version information
Hi all,
As I was going through the questions for the Modular applications I reached the #9 which I assume must be a typo error since in the answers appendix, it gives as valid the option 'C' "--internal-jdk", but this option was never mentioned before in the book. That's ok, I searched in the forum and see that other fellows spotted it.

Now I see that the book gives as valid options -jdkinternals or --jdk-internals, as it is described in the Oracle documentation:
https://docs.oracle.com/en/java/javase/15/docs/specs/man/jdeps.html

So I thought... let's give it a try. Well surprisingly only the -jdkinternals options goes through. --jdk-internals is unknown for jdeps. Even more, jdeps -h only gives as valid option -jdkinternals.
This is very strange and against the Oracle documentation itself!
Could someone try the "jdeps --jdk-internals"  and check if it's valid or not? I am using java 11.0.8
Now my next doubt is, what can I expect to be found in the exam? Since the Oracle documentation allows '--jdk-internals', this should be valid for the exam, but when you try to execute it, it fails because it's not a valid option!!!

Jesse Silverman wrote:

You cannot have more than one public interface in a .class file.



You can not have more than one class, interface or enum in a .class file, regardless of whether they are public, default, private static, etc. etc. etc. -- as each class or interface of any of those categories generates its own .class file.

You may not declare more than one public interface, class or enum in a .java source file is what you meant to say.

Preparing for these exams always makes me feel like I am defending myself in court because my court-appointed attorney showed up drunk and fell asleep...

I am probably just jealous that you caught an error I missed.  Again, good catch.



Hi Jesse,
Yes, you are right I was talking about .java files not .class.
I am not sure what are the rules here, should I edit my post?
Cheers,
Daniel.
Hi all,
I would say that question 11 for chapter 1 (Java fundamentals), page 50 of the book is wrong.

It presents a code having several public interfaces like:
1: public interface CanWalk {
...
4: }
5: public interface CanRun {
...
9: }
10: public interface  CanSprint {
...
16: }

For me, the right answer is 'F': "None of the above", since the code cannot compile: You cannot have more than one public interface in a .class file. I think that there shouldn't be the line numbers (that indicate that these are lines of the same file).

What do you think about it?
Page 685 says:

because a regular inner class cannot have static declarations of any kind.

This is not quite true. It is valid to define a static variable as long as it is final:
Is valid

Note that this is not valid for methods:
Is NOT valid