Skip to content

Commit a5e6f6d

Browse files
committed
Replace "javax" with javaxOrJakarta()
This is just a find-replace of `"javax` with `javaxOrJakarta() + "`.
1 parent 149f3ed commit a5e6f6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+370
-218
lines changed

java/ql/lib/experimental/quantum/JCA.qll

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ module JCAModel {
295295

296296
class CipherGetInstanceCall extends MethodCall {
297297
CipherGetInstanceCall() {
298-
this.getCallee().hasQualifiedName("javax.crypto", "Cipher", "getInstance")
298+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "Cipher", "getInstance")
299299
}
300300

301301
Expr getAlgorithmArg() { result = this.getArgument(0) }
@@ -307,7 +307,8 @@ module JCAModel {
307307
private class CipherOperationCall extends MethodCall {
308308
CipherOperationCall() {
309309
this.getMethod()
310-
.hasQualifiedName("javax.crypto", "Cipher", ["update", "doFinal", "wrap", "unwrap"])
310+
.hasQualifiedName(javaxOrJakarta() + ".crypto", "Cipher",
311+
["update", "doFinal", "wrap", "unwrap"])
311312
}
312313

313314
predicate isIntermediate() { this.getMethod().getName() = "update" }
@@ -474,7 +475,9 @@ module JCAModel {
474475
* An access to the `javax.crypto.Cipher` class.
475476
*/
476477
private class CipherAccess extends TypeAccess {
477-
CipherAccess() { this.getType().(Class).hasQualifiedName("javax.crypto", "Cipher") }
478+
CipherAccess() {
479+
this.getType().(Class).hasQualifiedName(javaxOrJakarta() + ".crypto", "Cipher")
480+
}
478481
}
479482

480483
/**
@@ -708,7 +711,9 @@ module JCAModel {
708711
// and through setter methods
709712
class IvParameterSpecInstance extends NonceParameterInstantiation {
710713
IvParameterSpecInstance() {
711-
super.getConstructedType().hasQualifiedName("javax.crypto.spec", "IvParameterSpec")
714+
super
715+
.getConstructedType()
716+
.hasQualifiedName(javaxOrJakarta() + ".crypto.spec", "IvParameterSpec")
712717
}
713718

714719
override DataFlow::Node getInputNode() { result.asExpr() = super.getArgument(0) }
@@ -717,15 +722,18 @@ module JCAModel {
717722
// TODO: this also specifies the tag length for GCM
718723
class GCMParameterSpecInstance extends NonceParameterInstantiation {
719724
GCMParameterSpecInstance() {
720-
super.getConstructedType().hasQualifiedName("javax.crypto.spec", "GCMParameterSpec")
725+
super
726+
.getConstructedType()
727+
.hasQualifiedName(javaxOrJakarta() + ".crypto.spec", "GCMParameterSpec")
721728
}
722729

723730
override DataFlow::Node getInputNode() { result.asExpr() = super.getArgument(1) }
724731
}
725732

726733
class IvParameterSpecGetIvCall extends MethodCall {
727734
IvParameterSpecGetIvCall() {
728-
this.getMethod().hasQualifiedName("javax.crypto.spec", "IvParameterSpec", "getIV")
735+
this.getMethod()
736+
.hasQualifiedName(javaxOrJakarta() + ".crypto.spec", "IvParameterSpec", "getIV")
729737
}
730738
}
731739

@@ -797,7 +805,9 @@ module JCAModel {
797805
}
798806

799807
class CipherInitCall extends MethodCall {
800-
CipherInitCall() { this.getCallee().hasQualifiedName("javax.crypto", "Cipher", "init") }
808+
CipherInitCall() {
809+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "Cipher", "init")
810+
}
801811

802812
/**
803813
* Returns the mode argument to the `init` method
@@ -966,7 +976,9 @@ module JCAModel {
966976

967977
class DHGenParameterSpecInstance extends KeyGeneratorParameterSpecClassInstanceExpr {
968978
DHGenParameterSpecInstance() {
969-
super.getConstructedType().hasQualifiedName("javax.crypto.spec", "DHGenParameterSpec")
979+
super
980+
.getConstructedType()
981+
.hasQualifiedName(javaxOrJakarta() + ".crypto.spec", "DHGenParameterSpec")
970982
}
971983

972984
Expr getPrimeSizeArg() { result = this.getArgument(0) }
@@ -1067,7 +1079,7 @@ module JCAModel {
10671079
//TODO: Link getAlgorithm from KeyPairGenerator to algorithm instances or AVCs? High priority.
10681080
class KeyGeneratorGetInstanceCall extends MethodCall {
10691081
KeyGeneratorGetInstanceCall() {
1070-
this.getCallee().hasQualifiedName("javax.crypto", "KeyGenerator", "getInstance")
1082+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "KeyGenerator", "getInstance")
10711083
or
10721084
this.getCallee().hasQualifiedName("java.security", "KeyPairGenerator", "getInstance")
10731085
}
@@ -1082,7 +1094,8 @@ module JCAModel {
10821094
this.getCallee().hasQualifiedName("java.security", "KeyPairGenerator", "initialize") and
10831095
keyType = Crypto::TAsymmetricKeyType()
10841096
or
1085-
this.getCallee().hasQualifiedName("javax.crypto", "KeyGenerator", ["init", "initialize"]) and
1097+
this.getCallee()
1098+
.hasQualifiedName(javaxOrJakarta() + ".crypto", "KeyGenerator", ["init", "initialize"]) and
10861099
keyType = Crypto::TSymmetricKeyType()
10871100
}
10881101

@@ -1111,7 +1124,7 @@ module JCAModel {
11111124
Crypto::KeyArtifactType type;
11121125

11131126
KeyGeneratorGenerateCall() {
1114-
this.getCallee().hasQualifiedName("javax.crypto", "KeyGenerator", "generateKey") and
1127+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "KeyGenerator", "generateKey") and
11151128
type instanceof Crypto::TSymmetricKeyType
11161129
or
11171130
this.getCallee()
@@ -1176,7 +1189,7 @@ module JCAModel {
11761189
class KeySpecInstantiation extends ClassInstanceExpr {
11771190
KeySpecInstantiation() {
11781191
this.getConstructedType()
1179-
.hasQualifiedName("javax.crypto.spec",
1192+
.hasQualifiedName(javaxOrJakarta() + ".crypto.spec",
11801193
["PBEKeySpec", "SecretKeySpec", "PBEKeySpec", "DESedeKeySpec"])
11811194
}
11821195

@@ -1227,15 +1240,17 @@ module JCAModel {
12271240

12281241
class SecretKeyFactoryGetInstanceCall extends MethodCall {
12291242
SecretKeyFactoryGetInstanceCall() {
1230-
this.getCallee().hasQualifiedName("javax.crypto", "SecretKeyFactory", "getInstance")
1243+
this.getCallee()
1244+
.hasQualifiedName(javaxOrJakarta() + ".crypto", "SecretKeyFactory", "getInstance")
12311245
}
12321246

12331247
Expr getAlgorithmArg() { result = this.getArgument(0) }
12341248
}
12351249

12361250
class SecretKeyFactoryGenerateSecretCall extends MethodCall {
12371251
SecretKeyFactoryGenerateSecretCall() {
1238-
this.getCallee().hasQualifiedName("javax.crypto", "SecretKeyFactory", "generateSecret")
1252+
this.getCallee()
1253+
.hasQualifiedName(javaxOrJakarta() + ".crypto", "SecretKeyFactory", "generateSecret")
12391254
}
12401255

12411256
Expr getKeySpecArg() { result = this.getArgument(0) }
@@ -1430,15 +1445,15 @@ module JCAModel {
14301445

14311446
class KeyAgreementInitCall extends MethodCall {
14321447
KeyAgreementInitCall() {
1433-
this.getCallee().hasQualifiedName("javax.crypto", "KeyAgreement", "init")
1448+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "KeyAgreement", "init")
14341449
}
14351450

14361451
Expr getServerKeyArg() { result = this.getArgument(0) }
14371452
}
14381453

14391454
class KeyAgreementGetInstanceCall extends MethodCall {
14401455
KeyAgreementGetInstanceCall() {
1441-
this.getCallee().hasQualifiedName("javax.crypto", "KeyAgreement", "getInstance")
1456+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "KeyAgreement", "getInstance")
14421457
}
14431458

14441459
Expr getAlgorithmArg() { result = super.getArgument(0) }
@@ -1482,7 +1497,8 @@ module JCAModel {
14821497
class KeyAgreementCall extends MethodCall {
14831498
KeyAgreementCall() {
14841499
this.getCallee()
1485-
.hasQualifiedName("javax.crypto", "KeyAgreement", ["generateSecret", "doPhase"])
1500+
.hasQualifiedName(javaxOrJakarta() + ".crypto", "KeyAgreement",
1501+
["generateSecret", "doPhase"])
14861502
}
14871503

14881504
predicate isIntermediate() { this.getCallee().getName() = "doPhase" }
@@ -1647,7 +1663,9 @@ module JCAModel {
16471663
}
16481664

16491665
class MacGetInstanceCall extends MethodCall {
1650-
MacGetInstanceCall() { this.getCallee().hasQualifiedName("javax.crypto", "Mac", "getInstance") }
1666+
MacGetInstanceCall() {
1667+
this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "Mac", "getInstance")
1668+
}
16511669

16521670
Expr getAlgorithmArg() { result = this.getArgument(0) }
16531671

@@ -1663,7 +1681,7 @@ module JCAModel {
16631681
}
16641682

16651683
class MacInitCall extends MethodCall {
1666-
MacInitCall() { this.getCallee().hasQualifiedName("javax.crypto", "Mac", "init") }
1684+
MacInitCall() { this.getCallee().hasQualifiedName(javaxOrJakarta() + ".crypto", "Mac", "init") }
16671685

16681686
Expr getKeyArg() {
16691687
result = this.getArgument(0) and this.getMethod().getParameterType(0).hasName("Key")
@@ -1691,7 +1709,7 @@ module JCAModel {
16911709
Expr output;
16921710

16931711
MacOperationCall() {
1694-
super.getMethod().getDeclaringType().hasQualifiedName("javax.crypto", "Mac") and
1712+
super.getMethod().getDeclaringType().hasQualifiedName(javaxOrJakarta() + ".crypto", "Mac") and
16951713
(
16961714
super.getMethod().hasStringSignature(["doFinal()", "doFinal(byte[])"]) and this = output
16971715
or

java/ql/lib/semmle/code/java/J2EE.qll

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,61 @@ import Type
99
/** An entity bean. */
1010
class EntityBean extends Class {
1111
EntityBean() {
12-
exists(Interface i | i.hasQualifiedName("javax.ejb", "EntityBean") | this.hasSupertype+(i))
12+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "EntityBean") |
13+
this.hasSupertype+(i)
14+
)
1315
}
1416
}
1517

1618
/** An enterprise bean. */
1719
class EnterpriseBean extends RefType {
1820
EnterpriseBean() {
19-
exists(Interface i | i.hasQualifiedName("javax.ejb", "EnterpriseBean") | this.hasSupertype+(i))
21+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "EnterpriseBean") |
22+
this.hasSupertype+(i)
23+
)
2024
}
2125
}
2226

2327
/** A local EJB home interface. */
2428
class LocalEjbHomeInterface extends Interface {
2529
LocalEjbHomeInterface() {
26-
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBLocalHome") | this.hasSupertype+(i))
30+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "EJBLocalHome") |
31+
this.hasSupertype+(i)
32+
)
2733
}
2834
}
2935

3036
/** A remote EJB home interface. */
3137
class RemoteEjbHomeInterface extends Interface {
3238
RemoteEjbHomeInterface() {
33-
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBHome") | this.hasSupertype+(i))
39+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "EJBHome") |
40+
this.hasSupertype+(i)
41+
)
3442
}
3543
}
3644

3745
/** A local EJB interface. */
3846
class LocalEjbInterface extends Interface {
3947
LocalEjbInterface() {
40-
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBLocalObject") | this.hasSupertype+(i))
48+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "EJBLocalObject") |
49+
this.hasSupertype+(i)
50+
)
4151
}
4252
}
4353

4454
/** A remote EJB interface. */
4555
class RemoteEjbInterface extends Interface {
4656
RemoteEjbInterface() {
47-
exists(Interface i | i.hasQualifiedName("javax.ejb", "EJBObject") | this.hasSupertype+(i))
57+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "EJBObject") |
58+
this.hasSupertype+(i)
59+
)
4860
}
4961
}
5062

5163
/** A message bean. */
5264
class MessageBean extends Class {
5365
MessageBean() {
54-
exists(Interface i | i.hasQualifiedName("javax.ejb", "MessageDrivenBean") |
66+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "MessageDrivenBean") |
5567
this.hasSupertype+(i)
5668
)
5769
}
@@ -60,6 +72,8 @@ class MessageBean extends Class {
6072
/** A session bean. */
6173
class SessionBean extends Class {
6274
SessionBean() {
63-
exists(Interface i | i.hasQualifiedName("javax.ejb", "SessionBean") | this.hasSupertype+(i))
75+
exists(Interface i | i.hasQualifiedName(javaxOrJakarta() + ".ejb", "SessionBean") |
76+
this.hasSupertype+(i)
77+
)
6478
}
6579
}

java/ql/lib/semmle/code/java/JMX.qll

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MBean extends ManagedBean {
1818
class MXBean extends ManagedBean {
1919
MXBean() {
2020
this.getQualifiedName().matches("%MXBean%") or
21-
this.getAnAnnotation().getType().hasQualifiedName("javax.management", "MXBean")
21+
this.getAnAnnotation().getType().hasQualifiedName(javaxOrJakarta() + ".management", "MXBean")
2222
}
2323
}
2424

@@ -61,7 +61,7 @@ class JmxRegistrationCall extends MethodCall {
6161
class JmxRegistrationMethod extends Method {
6262
JmxRegistrationMethod() {
6363
// A direct registration with the `MBeanServer`.
64-
this.getDeclaringType().hasQualifiedName("javax.management", "MBeanServer") and
64+
this.getDeclaringType().hasQualifiedName(javaxOrJakarta() + ".management", "MBeanServer") and
6565
this.getName() = "registerMBean"
6666
or
6767
// The `MBeanServer` is often wrapped by an application specific management class, so identify
@@ -78,7 +78,7 @@ class JmxRegistrationMethod extends Method {
7878
*/
7979
int getObjectPosition() {
8080
// Passed as the first argument to `registerMBean`.
81-
this.getDeclaringType().hasQualifiedName("javax.management", "MBeanServer") and
81+
this.getDeclaringType().hasQualifiedName(javaxOrJakarta() + ".management", "MBeanServer") and
8282
this.getName() = "registerMBean" and
8383
result = 0
8484
or
@@ -92,16 +92,20 @@ class JmxRegistrationMethod extends Method {
9292
/** The class `javax.management.remote.JMXConnectorFactory`. */
9393
class TypeJmxConnectorFactory extends Class {
9494
TypeJmxConnectorFactory() {
95-
this.hasQualifiedName("javax.management.remote", "JMXConnectorFactory")
95+
this.hasQualifiedName(javaxOrJakarta() + ".management.remote", "JMXConnectorFactory")
9696
}
9797
}
9898

9999
/** The class `javax.management.remote.JMXServiceURL`. */
100100
class TypeJmxServiceUrl extends Class {
101-
TypeJmxServiceUrl() { this.hasQualifiedName("javax.management.remote", "JMXServiceURL") }
101+
TypeJmxServiceUrl() {
102+
this.hasQualifiedName(javaxOrJakarta() + ".management.remote", "JMXServiceURL")
103+
}
102104
}
103105

104106
/** The class `javax.management.remote.rmi.RMIConnector`. */
105107
class TypeRmiConnector extends Class {
106-
TypeRmiConnector() { this.hasQualifiedName("javax.management.remote.rmi", "RMIConnector") }
108+
TypeRmiConnector() {
109+
this.hasQualifiedName(javaxOrJakarta() + ".management.remote.rmi", "RMIConnector")
110+
}
107111
}

java/ql/lib/semmle/code/java/deadcode/EntryPoints.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class FacesComponentReflectivelyConstructedClass extends ReflectivelyConstructed
316316
* Entry point for EJB home interfaces.
317317
*/
318318
class EjbHome extends Interface, EntryPoint {
319-
EjbHome() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBHome") }
319+
EjbHome() { this.getAnAncestor().hasQualifiedName(javaxOrJakarta() + ".ejb", "EJBHome") }
320320

321321
override Callable getALiveCallable() { result = this.getACallable() }
322322
}
@@ -325,7 +325,7 @@ class EjbHome extends Interface, EntryPoint {
325325
* Entry point for EJB object interfaces.
326326
*/
327327
class EjbObject extends Interface, EntryPoint {
328-
EjbObject() { this.getAnAncestor().hasQualifiedName("javax.ejb", "EJBObject") }
328+
EjbObject() { this.getAnAncestor().hasQualifiedName(javaxOrJakarta() + ".ejb", "EJBObject") }
329329

330330
override Callable getALiveCallable() { result = this.getACallable() }
331331
}
@@ -341,7 +341,9 @@ class GsonDeserializationEntryPoint extends ReflectivelyConstructedClass {
341341
class JaxbDeserializationEntryPoint extends ReflectivelyConstructedClass {
342342
JaxbDeserializationEntryPoint() {
343343
// A class can be deserialized by JAXB if it's an `XmlRootElement`...
344-
this.getAnAnnotation().getType().hasQualifiedName("javax.xml.bind.annotation", "XmlRootElement")
344+
this.getAnAnnotation()
345+
.getType()
346+
.hasQualifiedName(javaxOrJakarta() + ".xml.bind.annotation", "XmlRootElement")
345347
or
346348
// ... or the type of an `XmlElement` field.
347349
exists(Field elementField |

java/ql/lib/semmle/code/java/deadcode/WebEntryPoints.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ServletListenerClass extends ReflectivelyConstructedClass {
4545
*/
4646
class ServletFilterClass extends ReflectivelyConstructedClass {
4747
ServletFilterClass() {
48-
this.getAnAncestor().hasQualifiedName("javax.servlet", "Filter") and
48+
this.getAnAncestor().hasQualifiedName(javaxOrJakarta() + ".servlet", "Filter") and
4949
// If we have seen any `web.xml` files, this filter will be considered to be live only if it is
5050
// referred to as a filter-class in at least one. If no `web.xml` files are found, we assume
5151
// that XML extraction was not enabled, and therefore consider all filter classes as live.

java/ql/lib/semmle/code/java/frameworks/JAXB.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import semmle.code.java.Type
66

77
class JaxbElement extends Class {
88
JaxbElement() {
9-
this.getAnAncestor().hasQualifiedName("javax.xml.bind", "JAXBElement") or
9+
this.getAnAncestor().hasQualifiedName(javaxOrJakarta() + ".xml.bind", "JAXBElement") or
1010
this.getAnAnnotation().getType().getName() = "XmlRootElement"
1111
}
1212
}
1313

1414
class JaxbMarshalMethod extends Method {
1515
JaxbMarshalMethod() {
16-
this.getDeclaringType().hasQualifiedName("javax.xml.bind", "Marshaller") and
16+
this.getDeclaringType().hasQualifiedName(javaxOrJakarta() + ".xml.bind", "Marshaller") and
1717
this.getName() = "marshal"
1818
}
1919
}
2020

2121
class JaxbAnnotationType extends AnnotationType {
22-
JaxbAnnotationType() { this.getPackage().getName() = "javax.xml.bind.annotation" }
22+
JaxbAnnotationType() { this.getPackage().getName() = javaxOrJakarta() + ".xml.bind.annotation" }
2323
}
2424

2525
class JaxbAnnotated extends Annotatable {

0 commit comments

Comments
 (0)