From c977d7a4a62a8cf11fdad202bfdc7cbf9e2e10da Mon Sep 17 00:00:00 2001 From: tijanavg Date: Tue, 26 Nov 2024 14:44:50 +0000 Subject: [PATCH 1/3] Added Automatic-Module-Name to published jars. Context: https://b.corp.google.com/issues/308334884 --- java/carrier/pom.xml | 26 +++++++++++++++--------- java/geocoder/pom.xml | 32 ++++++++++++++++++++---------- java/internal/prefixmapper/pom.xml | 28 +++++++++++++++++--------- java/libphonenumber/pom.xml | 26 ++++++++++++++++++------ java/pom.xml | 25 +++++++++++++++-------- 5 files changed, 94 insertions(+), 43 deletions(-) diff --git a/java/carrier/pom.xml b/java/carrier/pom.xml index 1e47cc5e0c..8e660b08b0 100644 --- a/java/carrier/pom.xml +++ b/java/carrier/pom.xml @@ -1,7 +1,8 @@ - + 4.0.0 - com.googlecode.libphonenumber carrier 1.235-SNAPSHOT jar @@ -24,8 +25,10 @@ - test/com/google/i18n/phonenumbers/carrier/testing_data - com/google/i18n/phonenumbers/carrier/testing_data + test/com/google/i18n/phonenumbers/carrier/testing_data + + com/google/i18n/phonenumbers/carrier/testing_data + @@ -35,24 +38,29 @@ 5.1.9 - com.googlecode.libphonenumber + com.googlecode.libphonenumber maven-jar-plugin - 3.3.0 default-jar - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + com.google.i18n.phonenumbers.carrier + + - - + + org.codehaus.mojo animal-sniffer-maven-plugin diff --git a/java/geocoder/pom.xml b/java/geocoder/pom.xml index 40a015754a..450a5fb175 100644 --- a/java/geocoder/pom.xml +++ b/java/geocoder/pom.xml @@ -1,7 +1,8 @@ - + 4.0.0 - com.googlecode.libphonenumber geocoder 2.245-SNAPSHOT jar @@ -28,12 +29,16 @@ - test/com/google/i18n/phonenumbers/geocoding/testing_data - com/google/i18n/phonenumbers/geocoding/testing_data + test/com/google/i18n/phonenumbers/geocoding/testing_data + + com/google/i18n/phonenumbers/geocoding/testing_data + - test/com/google/i18n/phonenumbers/timezones/testing_data - com/google/i18n/phonenumbers/timezones/testing_data + test/com/google/i18n/phonenumbers/timezones/testing_data + + com/google/i18n/phonenumbers/timezones/testing_data + @@ -43,24 +48,29 @@ 5.1.9 - com.googlecode.libphonenumber + com.googlecode.libphonenumber maven-jar-plugin - 3.3.0 default-jar - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + com.google.i18n.phonenumbers.geocoder + + - - + + org.codehaus.mojo animal-sniffer-maven-plugin diff --git a/java/internal/prefixmapper/pom.xml b/java/internal/prefixmapper/pom.xml index 9c43180d50..0ebfca012a 100644 --- a/java/internal/prefixmapper/pom.xml +++ b/java/internal/prefixmapper/pom.xml @@ -1,7 +1,8 @@ - + 4.0.0 - com.googlecode.libphonenumber prefixmapper 2.245-SNAPSHOT jar @@ -19,8 +20,11 @@ test - ../../geocoder/test/com/google/i18n/phonenumbers/geocoding/testing_data - com/google/i18n/phonenumbers/geocoding/testing_data + + ../../geocoder/test/com/google/i18n/phonenumbers/geocoding/testing_data + + com/google/i18n/phonenumbers/geocoding/testing_data + @@ -30,24 +34,30 @@ 5.1.9 - com.googlecode.libphonenumber + com.googlecode.libphonenumber maven-jar-plugin - 3.3.0 default-jar - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + com.google.i18n.phonenumbers.prefixmapper + + - - + + org.codehaus.mojo diff --git a/java/libphonenumber/pom.xml b/java/libphonenumber/pom.xml index 54f95f9460..c472bd42d2 100644 --- a/java/libphonenumber/pom.xml +++ b/java/libphonenumber/pom.xml @@ -1,7 +1,8 @@ - + 4.0.0 - com.googlecode.libphonenumber libphonenumber 8.13.51-SNAPSHOT jar @@ -35,20 +36,26 @@ 5.1.9 - true + true com.google.i18n.phonenumbers maven-jar-plugin - 3.3.0 default-jar - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + com.google.i18n.phonenumbers.libphonenumber + + @@ -61,7 +68,14 @@ no-metadata - ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + com.google.i18n.phonenumbers.libphonenumber + + com/google/i18n/phonenumbers/data/* diff --git a/java/pom.xml b/java/pom.xml index c864d6fc72..3cdaa49a5a 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 com.googlecode.libphonenumber libphonenumber-parent @@ -14,7 +16,8 @@ - Google's common Java library for parsing, formatting, storing and validating international phone numbers. + Google's common Java library for parsing, formatting, storing and validating + international phone numbers. Optimized for running on smartphones. @@ -31,8 +34,10 @@ - scm:git:https://github.com/google/libphonenumber.git - scm:git:git@github.com:googlei18n/libphonenumber.git + scm:git:https://github.com/google/libphonenumber.git + + scm:git:git@github.com:googlei18n/libphonenumber.git + https://github.com/google/libphonenumber/ v8.13.50 @@ -108,6 +113,10 @@ animal-sniffer-maven-plugin 1.15 + + maven-jar-plugin + 3.3.0 + @@ -162,20 +171,20 @@ 3.11.0 1.7 - 1.7 - UTF-8 + 1.7 + UTF-8 org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.6.13 true sonatype-nexus-staging https://oss.sonatype.org/ 23ed8fbc71e875 - true + true From 5273bf665eb5484acc8da66d4e3324871d3fe50f Mon Sep 17 00:00:00 2001 From: tijanavg Date: Wed, 11 Dec 2024 13:07:37 +0000 Subject: [PATCH 2/3] Removed Automatic-Module-Name from carrier and geocoder. Classes in these modules belong to the same package as core libphonenumber library, which leads to the split package problem with Java modules. --- java/carrier/pom.xml | 4 ---- java/geocoder/pom.xml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/java/carrier/pom.xml b/java/carrier/pom.xml index 18fa0e1916..9a5130bd32 100644 --- a/java/carrier/pom.xml +++ b/java/carrier/pom.xml @@ -52,10 +52,6 @@ ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - com.google.i18n.phonenumbers.carrier - - diff --git a/java/geocoder/pom.xml b/java/geocoder/pom.xml index b713d5c763..6c43f1c942 100644 --- a/java/geocoder/pom.xml +++ b/java/geocoder/pom.xml @@ -62,10 +62,6 @@ ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - com.google.i18n.phonenumbers.geocoder - - From b2b89594907b4eedf791b8d9b6671d83bf93e062 Mon Sep 17 00:00:00 2001 From: tijanavg Date: Wed, 18 Dec 2024 14:25:08 +0000 Subject: [PATCH 3/3] Documented the issue with checking isPossible only for default country --- cpp/src/phonenumbers/phonenumberutil.h | 14 ++++ .../com/google/phonenumbers/demo/result.soy | 40 +++++----- .../i18n/phonenumbers/PhoneNumberUtil.java | 13 ++++ javascript/i18n/phonenumbers/demo.js | 76 +++++++++---------- .../i18n/phonenumbers/phonenumberutil.js | 12 +++ 5 files changed, 95 insertions(+), 60 deletions(-) diff --git a/cpp/src/phonenumbers/phonenumberutil.h b/cpp/src/phonenumbers/phonenumberutil.h index 14cfc670c7..d22f997a80 100644 --- a/cpp/src/phonenumbers/phonenumberutil.h +++ b/cpp/src/phonenumbers/phonenumberutil.h @@ -531,6 +531,13 @@ class PhoneNumberUtil : public Singleton { // would most likely be area codes) and length (obviously includes the // length of area codes for fixed line numbers), it will return false for // the subscriber-number-only version. + // + // There is a known issue with this method: if a number is possible only in a + // certain region among several regions that share the same country calling + // code, this method will consider only the "main" region. For example, + // +1310xxxx are valid numbers in Canada. However, they are not possible in + // the US. As a result, this method will return false for +1310xxxx. See + // https://issuetracker.google.com/issues/335892662 for more details. ValidationResult IsPossibleNumberWithReason(const PhoneNumber& number) const; // Convenience wrapper around IsPossibleNumberWithReason(). Instead of @@ -565,6 +572,13 @@ class PhoneNumberUtil : public Singleton { // would most likely be area codes) and length (obviously includes the // length of area codes for fixed line numbers), it will return false for // the subscriber-number-only version. + // + // There is a known issue with this method: if a number is possible only in a + // certain region among several regions that share the same country calling + // code, this method will consider only the "main" region. For example, + // +1310xxxx are valid numbers in Canada. However, they are not possible in + // the US. As a result, this method will return false for +1310xxxx. See + // https://issuetracker.google.com/issues/335892662 for more details. ValidationResult IsPossibleNumberForTypeWithReason( const PhoneNumber& number, PhoneNumberType type) const; diff --git a/java/demo/src/main/resources/com/google/phonenumbers/demo/result.soy b/java/demo/src/main/resources/com/google/phonenumbers/demo/result.soy index e3107109e8..baaa9d4181 100644 --- a/java/demo/src/main/resources/com/google/phonenumbers/demo/result.soy +++ b/java/demo/src/main/resources/com/google/phonenumbers/demo/result.soy @@ -101,44 +101,42 @@ Result from isPossibleNumber() {$isPossibleNumber} -{if $isPossibleNumber} - {if $validationResult == "IS_POSSIBLE_LOCAL_ONLY"} Result from isPossibleNumberWithReason() {$validationResult} - - Number is considered invalid as it is not a possible national number. - - {else} Result from isValidNumber() {$isValidNumber} + {if $isValidNumber} + {if $validationResult != "IS_POSSIBLE"} + + + Warning: This number represents a known + edge case - it is a valid number, but it is not considered (strictly) possible + + + {/if} {if $isValidNumberForRegion != null} - - Result from isValidNumberForRegion() - {$isValidNumberForRegion} - + + Result from isValidNumberForRegion() + {$isValidNumberForRegion} + {/if} Phone Number region - {$phoneNumberRegion ?: ""} + {$phoneNumberRegion} Result from getNumberType() {$numberType} - {/if} -{else} - - Result from isPossibleNumberWithReason() - {$validationResult} - - - Note: Numbers that are not possible have type UNKNOWN, an unknown region, and are considered invalid. - -{/if} + {else} + + Note: Invalid numbers have type UNKNOWN and no region. + + {/if} diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index e85cb65b52..d843bbbe9c 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -2705,6 +2705,13 @@ private ValidationResult testNumberLength( * length (obviously includes the length of area codes for fixed line numbers), it will * return false for the subscriber-number-only version. * + * + *

There is a known issue with this + * method: if a number is possible only in a certain region among several regions that share the + * same country calling code, this method will consider only the "main" region. For example, + * +1310xxxx are valid numbers in Canada. However, they are not possible in the US. As a result, + * this method will return IS_POSSIBLE_LOCAL_ONLY for +1310xxxx. + * * @param number the number that needs to be checked * @return a ValidationResult object which indicates whether the number is possible */ @@ -2734,6 +2741,12 @@ public ValidationResult isPossibleNumberWithReason(PhoneNumber number) { * return false for the subscriber-number-only version. * * + *

There is a known issue with this + * method: if a number is possible only in a certain region among several regions that share the + * same country calling code, this method will consider only the "main" region. For example, + * +1310xxxx are valid numbers in Canada. However, they are not possible in the US. As a result, + * this method will return IS_POSSIBLE_LOCAL_ONLY for +1310xxxx. + * * @param number the number that needs to be checked * @param type the type we are interested in * @return a ValidationResult object which indicates whether the number is possible diff --git a/javascript/i18n/phonenumbers/demo.js b/javascript/i18n/phonenumbers/demo.js index e18d351ad1..04c1871df0 100644 --- a/javascript/i18n/phonenumbers/demo.js +++ b/javascript/i18n/phonenumbers/demo.js @@ -58,52 +58,50 @@ function phoneNumberParser() { output.append('\nResult from isPossibleNumber(): '); output.append(isPossible); var validationResult = i18n.phonenumbers.PhoneNumberUtil.ValidationResult; - var isPossibleReason = phoneUtil_.isPossibleNumberWithReason(number) - var hasRegionCode = regionCode && regionCode != 'ZZ'; - if (isPossible) { - // Checking as isValid() fails if possible local only. - if (isPossibleReason == validationResult.IS_POSSIBLE_LOCAL_ONLY) { - output.append('\nResult from isPossibleNumberWithReason(): '); + var isPossibleReason = phoneUtil_.isPossibleNumberWithReason(number); + output.append('\nResult from isPossibleNumberWithReason(): '); + switch (isPossibleReason) { + case validationResult.IS_POSSIBLE: + output.append('IS_POSSIBLE'); + break; + case validationResult.IS_POSSIBLE_LOCAL_ONLY: output.append('IS_POSSIBLE_LOCAL_ONLY'); + break; + case validationResult.INVALID_COUNTRY_CODE: + output.append('INVALID_COUNTRY_CODE'); + break; + case validationResult.TOO_SHORT: + output.append('TOO_SHORT'); + break; + case validationResult.TOO_LONG: + output.append('TOO_LONG'); + break; + case validationResult.INVALID_LENGTH: + output.append('INVALID_LENGTH'); + break; + } + var hasRegionCode = regionCode && regionCode != 'ZZ'; + var isNumberValid = phoneUtil_.isValidNumber(number); + output.append('\nResult from isValidNumber(): '); + output.append(isNumberValid); + if (isNumberValid) { + if (isPossibleReason != validationResult.IS_POSSIBLE) { output.append( - '\nNumber is considered invalid as it is ' + - 'not a possible national number.'); - } else { - var isNumberValid = phoneUtil_.isValidNumber(number); - output.append('\nResult from isValidNumber(): '); - output.append(isNumberValid); - if (isNumberValid && hasRegionCode) { + '\nWarning: This number represents a known edge case - it is ' + + 'a valid number, but it is not considered (strictly) possible. ' + + 'See https://issuetracker.google.com/issues/335892662 for more details.'); + } + if (hasRegionCode) { output.append('\nResult from isValidNumberForRegion(): '); output.append(phoneUtil_.isValidNumberForRegion(number, regionCode)); - } - output.append('\nPhone Number region: '); - output.append(phoneUtil_.getRegionCodeForNumber(number)); - output.append('\nResult from getNumberType(): '); - output.append(getNumberTypeString(number)); } + output.append('\nPhone Number region: '); + output.append(phoneUtil_.getRegionCodeForNumber(number)); + output.append('\nResult from getNumberType(): '); + output.append(getNumberTypeString(number)); } else { - output.append('\nResult from isPossibleNumberWithReason(): '); - switch (isPossibleReason) { - case validationResult.INVALID_COUNTRY_CODE: - output.append('INVALID_COUNTRY_CODE'); - break; - case validationResult.TOO_SHORT: - output.append('TOO_SHORT'); - break; - case validationResult.TOO_LONG: - output.append('TOO_LONG'); - break; - case validationResult.INVALID_LENGTH: - output.append('INVALID_LENGTH'); - break; - } - // IS_POSSIBLE shouldn't happen, since we only call this if _not_ - // possible. output.append( - '\nNote: Numbers that are not possible have type UNKNOWN,' + - ' an unknown region, and are considered invalid.'); - } - if (!isNumberValid) { + '\nNote: Invalid numbers have type UNKNOWN and no region.'); var shortInfo = i18n.phonenumbers.ShortNumberInfo.getInstance(); output.append('\n\n****ShortNumberInfo Results:****'); output.append('\nResult from isPossibleShortNumber: '); diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index d530dae5e4..d6e67138ec 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -3584,6 +3584,12 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.testNumberLengthForType_ = * numbers), it will return false for the subscriber-number-only version. * * + *

There is a known issue with this + * method: if a number is possible only in a certain region among several regions that share the + * same country calling code, this method will consider only the "main" region. For example, + * +1310xxxx are valid numbers in Canada. However, they are not possible in the US. As a result, + * this method will return IS_POSSIBLE_LOCAL_ONLY for +1310xxxx. + * * @param {i18n.phonenumbers.PhoneNumber} number the number that needs to be * checked * @return {i18n.phonenumbers.PhoneNumberUtil.ValidationResult} a @@ -3613,6 +3619,12 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.isPossibleNumberWithReason = * numbers), it will return false for the subscriber-number-only version. * * + *

There is a known issue with this + * method: if a number is possible only in a certain region among several regions that share the + * same country calling code, this method will consider only the "main" region. For example, + * +1310xxxx are valid numbers in Canada. However, they are not possible in the US. As a result, + * this method will return IS_POSSIBLE_LOCAL_ONLY for +1310xxxx. + * * @param {i18n.phonenumbers.PhoneNumber} number the number that needs to be * checked * @param {i18n.phonenumbers.PhoneNumberType} type the type we are interested in