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
1 answer

Java specification, where does it say that sorting for Arrays should be stable?

Basically, I've just been reading javadoc for Arrays : https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html and it says: The documentation for the methods contained in this class includes briefs description of the implementations. Such…
dhblah
  • 9,751
  • 12
  • 56
  • 92
0
votes
0 answers

Why did the definers of the Java Language Specification decide not to allow a Java Thread to restart?

While I was reading a book by Kathy Sierra and Bert Bates, I found a passage that says Once a thread has been started, it can never be started again. (page 716) Why did the definers of the Java Language Specification decide not to allow a Java…
Ascendant
  • 827
  • 2
  • 16
  • 34
0
votes
1 answer

Type variable declared outside the static initialiser within the static initialiser

Could anyone give an concrete example as to what the following text in the JLS (§8.7) means? It is a compile-time error if [...] any type variable declared outside the static initializer, appears anywhere within a static initialiser. And what…
olovb
  • 2,164
  • 1
  • 17
  • 20
0
votes
1 answer

What is the name of conversion (parameterized type -> raw type)

According to JLS the conversion like (raw type -> parameterized type) named Unchecked Conversion . And what is the name of the reverse conversion (parameterized type -> raw type)? ArrayList arrStr = new ArrayList<>(); ArrayList rawArrList =…
Kliokli
  • 41
  • 4
0
votes
2 answers

Is 'program order' in Java allows reordering?

In one thread I have write a = 0 write a = 1 write volatile flag = 1 In 2nd thread I have read volatile flag // This always happens after I write volatile flag in thread 1 read a Can a reordering happen so I see read a returning 0 in the 2nd…
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
0
votes
1 answer

Implementation method Throws exception but interface method don't define as it throws exception

when implementing an interface, it's perfectly legal for the interface methods not to throw an exception, but the implementation class method can throw Exception. Interface definition public interface exceptionNotDefined { void…
Keerthi
  • 80
  • 2
  • 7
0
votes
2 answers

Members of a Intersection type

This question is related to : Lambda Intersection Type Question Please see the example: public class X { Object o = (I & J) () -> {}; } interface I { public void foo(); } interface J { public void foo(); public void bar(); } I am…
gudge
  • 1,053
  • 4
  • 18
  • 33
0
votes
1 answer

Memory visibility semantics of two related volatile variables

Consider the following program from the JLS section on volatile fields class Test { static volatile int i = 0, j = 0; static void one() { i++; j++; } static void two() { System.out.println("i=" + i + " j=" + j); } } Consider…
Geek
  • 26,489
  • 43
  • 149
  • 227
0
votes
2 answers

Why abstract does not work for interface implicit methods?

While reading JLS Specification for Interfaces I came across following phrase: If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method m with signature s, return type r, and throws…
Dangling Piyush
  • 3,658
  • 8
  • 37
  • 52
0
votes
1 answer

When can I use "==" operator?

I have found quote from jls: The equality operators may be used to compare two operands that are convertible (§5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
0
votes
2 answers

interface with in an abstract class

Is it possible to declare an interface inside an abstract class ?. I tried this and i was successfully able to do it without any compilation error?? In Practical usage is there any significance of this ?? Here is the code that i have wrote. public…
shoaib1992
  • 410
  • 1
  • 8
  • 26
0
votes
3 answers

Clarification on Java Language Specification

I read the following phrase in the Java language specification. It is a compile-time error for the character following the SingleCharacter or EscapeSequence to be other than a '.' I am not able to understand what is the meaning of above line.…
Ashish
  • 14,295
  • 21
  • 82
  • 127
0
votes
3 answers

Are all names identifiers?

In the Java Language Specification 6.2 Link Here is the following code example: class Test { public static void main(String[] args) { Class c = System.out.getClass(); System.out.println(c.toString().length() + …
Teletha
  • 603
  • 1
  • 11
  • 21
0
votes
2 answers

Working around superfirst

Here, AsciiChecker enables the matrix specification in the text form. abstract class AsciiChecker extends AlgoritmicChecker { String[] ascii; AsciiChecker(String title, final String ... ascii) { super(title, ascii[0].length(),…
Val
  • 1
  • 8
  • 40
  • 64
0
votes
2 answers

Spring @RequestMapping value explicit/implicit

In some cases I have seen two different ways to specify uri in @RequestMapping: @RequestMapping(value="/somepath") @RequestMapping("/somepath") The latter is often used at class level. So, is it always legal omitting the value attribute?
1 2 3
24
25