Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe3b96a

Browse filesBrowse files
committed
2
1 parent 7743777 commit fe3b96a
Copy full SHA for fe3b96a

File tree

Expand file treeCollapse file tree

154 files changed

+3000
-448
lines changed
Open diff view settings
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

154 files changed

+3000
-448
lines changed
Open diff view settings
Collapse file

‎Main.java‎

Copy file name to clipboardExpand all lines: Main.java
+430-94Lines changed: 430 additions & 94 deletions
Large diffs are not rendered by default.
Collapse file

‎Makefile‎

Copy file name to clipboard
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
OUT_DIR ?= ./target/
1+
ARGS ?=
2+
OUT_DIR ?= .
3+
OUT_EXT ?= .class
24
RUN ?= Main
35

4-
.PHONY: all clean mkdir run
6+
-include Makefile_params
57

6-
all: mkdir $(OUTS)
8+
.PHONY: all clean mkdir run
79

8-
# TODO add: -source 1.7.
9-
# Problem: gives warning on Java 8.
10-
all:
10+
# TODO add: -source 1.7 -bootclasspath /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar
11+
# Without `bootclasspath`, gives warning on Java 8.
12+
all: mkdir
1113
javac -d '$(OUT_DIR)' *.java
1214

1315
clean:
14-
rm -rf $(OUT_DIR)
16+
if [ '$(OUT_DIR)' = '.' ]; then rm -f *$(OUT_EXT); else rm -rf $(OUT_DIR); fi
1517

1618
mkdir:
1719
mkdir -p $(OUT_DIR)
1820

1921
run: all
20-
cd $(OUT_DIR) && java -ea -D'custom.property=value' $(RUN) arg0 arg1
22+
cd $(OUT_DIR) && java -ea -D'custom.property=value' $(RUN) $(ARGS)
Collapse file

‎Makefile_params‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ARGS := arg0 arg1
2+
OUT_DIR := ./target/
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+23-34Lines changed: 23 additions & 34 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,25 @@ Java information and cheatsheets.
1010
- [Maven](maven/)
1111
- [java utility](java-utility.md)
1212
- [JVM](jvm.md)
13+
- [Bytecode](bytecode/)
1314
- [Javadoc](javadoc/)
15+
- [update-java-alternatives](update-java-alternatives.md)
1416
- [JAR](jar.md)
1517
- [javac](javac/)
1618
- [Tomcat](tomcat.md)
1719
- [JNI](jni/)
1820

1921
WIP:
2022

21-
- [Bytecode](bytecode.md)
23+
- [Spring](spring/)
24+
- [JDB](jdb.md)
2225
- [Jasmin](jasmin/)
2326
- [javap](javap.md)
24-
- [JDB](jdb.md)
27+
- [Mockito](mockito/)
2528
- [Java 8](java8/)
26-
- [Spring](spring/)
27-
- [Mockito](jasmin/)
29+
- [WatchService](watch-service/)
2830
- [Ant](ant.md)
31+
- [JMX](jmx.md)
2932

3033
Requirements for most directories:
3134

@@ -297,23 +300,6 @@ Started in Appeal and BEA Systems, which Oracle bought.
297300

298301
Java comes with several CLI utilities.
299302

300-
### update-java-alternatives
301-
302-
If you are maintaining two Java version on a single Linux machine, you can run `update-alternatives` for executables in one go.
303-
304-
List available alternatives:
305-
306-
update-java-alternatives -l
307-
308-
Sample output:
309-
310-
java-7-oracle 1 /usr/lib/jvm/java-7-oracle
311-
java-8-oracle 2 /usr/lib/jvm/java-8-oracle
312-
313-
Choose one of the alternatives:
314-
315-
sudo update-java-alternatives -s java-7-oracle
316-
317303
### java_vm
318304

319305
TODO
@@ -336,19 +322,7 @@ TODO vs the `jconsole`?
336322

337323
## JAVA_HOME
338324

339-
TODO what is it? Is it necessary even if the Java executable is already selected? <http://stackoverflow.com/questions/5102022/what-does-the-java-home-environment-variable-do>
340-
341-
If:
342-
343-
readlink -f `which java`
344-
345-
says:
346-
347-
/usr/lib/jvm/java-7-oracle/jre/bin/java
348-
349-
then you could set:
350-
351-
export JAVA_HOME='/usr/lib/jvm/java-7-oracle'
325+
TODO what is it? <http://stackoverflow.com/questions/5102022/what-does-the-java-home-environment-variable-do> Setting it does not change whih `java` utility is found, that depends only on the `PATH`.
352326

353327
## Classpath
354328

@@ -368,6 +342,21 @@ Environment variable:
368342

369343
- <https://google-styleguide.googlecode.com/svn/trunk/javaguide.html>
370344

345+
### Lint tools
346+
347+
<http://stackoverflow.com/questions/14691926/is-there-a-simple-cli-java-linter>
348+
349+
- FindBugs
350+
351+
### Formal verification
352+
353+
JML is the most popular verification input format as part of comments.
354+
355+
Tools that verify it include:
356+
357+
- some JML project tools: <http://www.eecs.ucf.edu/~leavens/JML/download.shtml>
358+
- <http://www.key-project.org/>
359+
371360
## Sources
372361

373362
- <http://tutorials.jenkov.com/>. Every tutorial is to the point, and filled with examples. My type of tutorial.
Collapse file

‎bytecode.md‎

Copy file name to clipboardExpand all lines: bytecode.md
-17Lines changed: 0 additions & 17 deletions
This file was deleted.
Collapse file

‎bytecode/LocalsOverflow.j‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; What happens when we use more locals than we declare:
2+
;
3+
; Illigal local variable number
4+
5+
.class public LocalsOverflow
6+
.super java/lang/Object
7+
8+
.method public static main([Ljava/lang/String;)V
9+
.limit locals 1
10+
aload_1
11+
return
12+
.end method
Collapse file

‎bytecode/Main.j‎

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; Main Java bytecode cheatsheet in Jasmin.
2+
;
3+
; We will use other tools for stuff that Jasmin cannot do.
4+
;
5+
; This will not discuss the Jasmin syntax itself.
6+
7+
.class public Main
8+
.super java/lang/Object
9+
10+
.method public <init>()V
11+
aload_0
12+
invokenonvirtual java/lang/Object/<init>()V
13+
return
14+
.end method
15+
16+
.method public static main([Ljava/lang/String;)V
17+
.limit stack 1024
18+
19+
; # new
20+
21+
; # invokespecial
22+
23+
; Must initialize before usage, or `VerifyError`:
24+
; https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.10.2.4
25+
26+
getstatic java/lang/System/out Ljava/io/PrintStream;
27+
new java/lang/Integer
28+
dup
29+
iconst_1
30+
invokespecial java/lang/Integer/<init>(I)V
31+
invokevirtual java/io/PrintStream/println(Ljava/lang/Object;)V
32+
33+
getstatic java/lang/System/out Ljava/io/PrintStream;
34+
ldc "ALL ASSERTS PASSED"
35+
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
36+
return
37+
.end method
Collapse file

‎bytecode/Makefile‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../jasmin.makefile
Collapse file

‎bytecode/NewInvokespecialTwice.j‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; VerifyError Expecting to find unitialized object on stack
2+
; https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.10.2.4
3+
4+
.class public NewInvokespecialTwice
5+
.super java/lang/Object
6+
7+
.method public static main([Ljava/lang/String;)V
8+
.limit stack 5
9+
getstatic java/lang/System/out Ljava/io/PrintStream;
10+
new java/lang/Integer
11+
dup
12+
dup
13+
iconst_1
14+
invokespecial java/lang/Integer/<init>(I)V
15+
iconst_1
16+
invokespecial java/lang/Integer/<init>(I)V
17+
return
18+
.end method
Collapse file

‎bytecode/NewWithoutInvokespecial.j‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; VerifyError Expecting to find object/array on stack
2+
; https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.10.2.4
3+
4+
.class public NewWithoutInvokespecial
5+
.super java/lang/Object
6+
7+
.method public static main([Ljava/lang/String;)V
8+
.limit stack 4
9+
getstatic java/lang/System/out Ljava/io/PrintStream;
10+
new java/lang/Integer
11+
; dup
12+
; iconst_1
13+
; invokespecial java/lang/Integer/<init>(I)V
14+
invokevirtual java/io/PrintStream/println(Ljava/lang/Object;)V
15+
return
16+
.end method

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.