Questions tagged [jls]

The Java Language Specification is the definitive technical reference of the Java programming language.

The Java Language Specification is the definitive technical reference of the Java programming language. It describes the language in full detail and is usually the final source of answers for questions about Java.

Questions with this tag often expect an answer that is based on the JLS and is not specific to any compiler or implementation. If possible, the relevant section of the JLS should be provided.

369 questions
0
votes
0 answers

What is the type of an intersection type according to the Java Language Specification?

During my question I refer to the Java Language Specification in the third edition. According to the specification of the intersection type (§ 4.9) the intersection type int[] (or int[] & int[]) would have the same members as a class type with an…
Daniel
  • 1
  • 3
0
votes
3 answers

Lock implemention on "Class" class object for synchronization

I was going through this link . According to this : Class locks are actually implemented as object locks. When the JVM loads a class file, it creates an instance of class java.lang.Class. When you lock a class, you are actually locking that…
mohit
  • 1,087
  • 1
  • 9
  • 18
-1
votes
1 answer

Why I don't have a clashing name conflict when two classes with same names are available?

Let's say I have a: package org.something.a; public class String { ... } and package org.something.a; public class Main { public static void main(String[] args) { String a = new String(); //IDE shows that this is a…
Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
-1
votes
1 answer

Why Variable-Parameterized variant of (cast) operator in Java is flagged as unchecked warning and not error?

Consider the following snippet: class MyClass{ ... public void checkType(Object o){ if(o instanceof List){ //this gives compilation error List list = (List)o; //this gives unchecked warning } } ... } Here, the instanceof will give…
theutonium.18
  • 483
  • 2
  • 7
-1
votes
1 answer

Why is instanceof a keyword?

If Java allowed "instanceof" as a name for variables (and fields, type names, package names), it appears, at a first glance, that the language would still remain unambiguous. In most or all of the productions in Java where an Identifier can appear,…
Nicholas Wilson
  • 9,435
  • 1
  • 41
  • 80
-1
votes
2 answers

Static field initializer is being invoked after static method execution

I've got a class with only static members, designed like that: public class Clazz { public static final Foo foo = FooFactory.createFoo(); private static Bar bar; public static void prepare() { bar = new Bar(foo); } } When…
basme
  • 81
  • 9
-1
votes
2 answers

What is a Line Terminator and how does it apply to comments?

I'm reading into the Java Language Specifications (se8), and I came across this.. Lines are terminated by the ASCII characters CR, or LF, or CR LF. The two characters CR immediately followed by LF are counted as one line terminator, not two. A line…
Vince
  • 14,470
  • 7
  • 39
  • 84
-2
votes
1 answer

Java language specification (jls) - annotations

I easily found many articles on usage of annotations via Web search, however, when I tried to find annotations description in Java language specifications, Web search gave link to only chapter about…
Child Detektiv
  • 237
  • 1
  • 12
-2
votes
2 answers

Is it a good practise to remove a function instead of making it stay there with a deprecated annotation

So i had this long argument with some guys and they kept fighting over their self made code conventions. According to which , they said if there is a method that you while coding the stuff you thought it should be deprecated.You simply remove…
cafebabe1991
  • 4,928
  • 2
  • 34
  • 42
1 2 3
24
25