-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(1) Introduced some Java 17 syntax, (2) included the jar and the Java…
… 17 example class, (3) reformat the code I added to comply with Google Java Style Guide
- Loading branch information
Showing
4 changed files
with
89 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
lang-java-reach-wala/src/test/resources/ExamplesJdk17.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* This file is part of Eclipse Steady. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Copyright (c) 2018-2020 SAP SE or an SAP affiliate company and Eclipse Steady contributors | ||
*/ | ||
package org.example; | ||
|
||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
sealed abstract class Animal implements Comparable<Animal> permits Cat, Dog, Fish { | ||
|
||
public abstract void saySomething(); | ||
|
||
public int compareTo(Animal _a) { | ||
return getClass().getName().compareTo(_a.getClass().getName()); | ||
} | ||
} | ||
|
||
final class Cat extends Animal { | ||
public void saySomething() { | ||
System.out.println("purr"); | ||
} | ||
} | ||
|
||
final class Dog extends Animal { | ||
public void saySomething() { | ||
System.out.println("woof"); | ||
} | ||
} | ||
|
||
final class Fish extends Animal { | ||
public void saySomething() { | ||
System.out.println("..."); | ||
} | ||
} | ||
|
||
class Car { | ||
public void saySomething() { | ||
System.out.println("honk!"); | ||
} | ||
} | ||
|
||
public class ExamplesJdk17 { | ||
static SortedSet<Animal> animals = new TreeSet<>(); | ||
|
||
private static Animal createFish() { | ||
return new Fish(); | ||
} | ||
|
||
private static Animal createCat() { | ||
Animal cat = new Cat(); | ||
animals.add(cat); | ||
return cat; | ||
} | ||
|
||
public static void main(String[] args) { | ||
Animal animal; | ||
if (args.length == 0) { | ||
animal = createCat(); | ||
animal.saySomething(); | ||
} else { | ||
animal = createFish(); | ||
animal.saySomething(); | ||
} | ||
} | ||
} |
Binary file modified
BIN
+158 Bytes
(100%)
lang-java-reach-wala/src/test/resources/examplesJdk17.jar
Binary file not shown.