1 /*
2 * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.javac.code;
27
28 import java.lang.annotation.Annotation;
29 import java.lang.annotation.Inherited;
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.EnumSet;
33 import java.util.HashMap;
34 import java.util.Map;
35 import java.util.Set;
36 import java.util.concurrent.Callable;
37 import java.util.function.Supplier;
38 import java.util.function.Predicate;
39
40 import javax.lang.model.element.Element;
41 import javax.lang.model.element.ElementKind;
42 import javax.lang.model.element.ElementVisitor;
43 import javax.lang.model.element.ExecutableElement;
44 import javax.lang.model.element.Modifier;
45 import javax.lang.model.element.ModuleElement;
46 import javax.lang.model.element.NestingKind;
47 import javax.lang.model.element.PackageElement;
48 import javax.lang.model.element.RecordComponentElement;
49 import javax.lang.model.element.TypeElement;
50 import javax.lang.model.element.TypeParameterElement;
51 import javax.lang.model.element.VariableElement;
52 import javax.tools.JavaFileManager;
53 import javax.tools.JavaFileObject;
387 public boolean isDeprecatableViaAnnotation() {
388 switch (getKind()) {
389 case LOCAL_VARIABLE:
390 case PACKAGE:
391 case PARAMETER:
392 case RESOURCE_VARIABLE:
393 case EXCEPTION_PARAMETER:
394 return false;
395 default:
396 return true;
397 }
398 }
399
400 public boolean isStatic() {
401 return
402 (flags() & STATIC) != 0 ||
403 (owner.flags() & INTERFACE) != 0 && kind != MTH &&
404 name != name.table.names._this;
405 }
406
407 public boolean isInterface() {
408 return (flags() & INTERFACE) != 0;
409 }
410
411 public boolean isAbstract() {
412 return (flags_field & ABSTRACT) != 0;
413 }
414
415 public boolean isPrivate() {
416 return (flags_field & Flags.AccessFlags) == PRIVATE;
417 }
418
419 public boolean isPublic() {
420 return (flags_field & Flags.AccessFlags) == PUBLIC;
421 }
422
423 public boolean isEnum() {
424 return (flags() & ENUM) != 0;
425 }
426
427 public boolean isSealed() {
428 return (flags_field & SEALED) != 0;
429 }
430
431 public boolean isNonSealed() {
432 return (flags_field & NON_SEALED) != 0;
433 }
434
435 public boolean isFinal() {
436 return (flags_field & FINAL) != 0;
437 }
438
|
1 /*
2 * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.javac.code;
27
28 import java.lang.annotation.Annotation;
29 import java.lang.annotation.Inherited;
30 import java.util.ArrayList;
31 import java.util.Collections;
32 import java.util.EnumSet;
33 import java.util.Map;
34 import java.util.Set;
35 import java.util.concurrent.Callable;
36 import java.util.function.Supplier;
37 import java.util.function.Predicate;
38
39 import javax.lang.model.element.Element;
40 import javax.lang.model.element.ElementKind;
41 import javax.lang.model.element.ElementVisitor;
42 import javax.lang.model.element.ExecutableElement;
43 import javax.lang.model.element.Modifier;
44 import javax.lang.model.element.ModuleElement;
45 import javax.lang.model.element.NestingKind;
46 import javax.lang.model.element.PackageElement;
47 import javax.lang.model.element.RecordComponentElement;
48 import javax.lang.model.element.TypeElement;
49 import javax.lang.model.element.TypeParameterElement;
50 import javax.lang.model.element.VariableElement;
51 import javax.tools.JavaFileManager;
52 import javax.tools.JavaFileObject;
386 public boolean isDeprecatableViaAnnotation() {
387 switch (getKind()) {
388 case LOCAL_VARIABLE:
389 case PACKAGE:
390 case PARAMETER:
391 case RESOURCE_VARIABLE:
392 case EXCEPTION_PARAMETER:
393 return false;
394 default:
395 return true;
396 }
397 }
398
399 public boolean isStatic() {
400 return
401 (flags() & STATIC) != 0 ||
402 (owner.flags() & INTERFACE) != 0 && kind != MTH &&
403 name != name.table.names._this;
404 }
405
406 public boolean isStrict() {
407 return (flags() & STRICT) != 0;
408 }
409
410 public boolean isSynthetic() {
411 return (flags() & SYNTHETIC) != 0;
412 }
413
414 public boolean isStrictInstance() {
415 return (flags() & STRICT) != 0 && (flags() & STATIC) == 0;
416 }
417
418 public boolean isInterface() {
419 return (flags_field & INTERFACE) != 0;
420 }
421
422 public boolean isAbstract() {
423 return (flags_field & ABSTRACT) != 0;
424 }
425
426 public boolean isPrivate() {
427 return (flags_field & Flags.AccessFlags) == PRIVATE;
428 }
429
430 public boolean isValueClass() {
431 return (flags_field & VALUE_CLASS) != 0;
432 }
433
434 public boolean isIdentityClass() {
435 return !isInterface() && (flags_field & IDENTITY_TYPE) != 0;
436 }
437
438 public boolean isPublic() {
439 return (flags_field & Flags.AccessFlags) == PUBLIC;
440 }
441
442 public boolean isEnum() {
443 return (flags() & ENUM) != 0;
444 }
445
446 public boolean isSealed() {
447 return (flags_field & SEALED) != 0;
448 }
449
450 public boolean isNonSealed() {
451 return (flags_field & NON_SEALED) != 0;
452 }
453
454 public boolean isFinal() {
455 return (flags_field & FINAL) != 0;
456 }
457
|