You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "nbauma109 (via GitHub)" <gi...@apache.org> on 2023/05/02 20:46:39 UTC

[GitHub] [commons-bcel] nbauma109 opened a new pull request, #221: Fix for type.getType(...) use on non-signature type names

nbauma109 opened a new pull request, #221:
URL: https://github.com/apache/commons-bcel/pull/221

   This is a fix for a small regression introduced by PR #171 with the use of Type.getType(...) on an internal type name which needs to be converted to a signature first (i.e. java/lang/String => Ljava/lang/String;)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] garydgregory commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1327778949


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -180,7 +181,7 @@ public static String getSignature(final java.lang.reflect.Method meth) {
     public static Type getType(final Class<?> cls) {
         Objects.requireNonNull(cls, "cls");
         /*
-         * That's an amzingly easy case, because getName() returns the signature. That's what we would have liked anyway.
+         * That's an amazingly easy case, because getName() returns the signature. That's what we would have liked anyway.

Review Comment:
   Good one! :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] Jeeppler commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "Jeeppler (via GitHub)" <gi...@apache.org>.
Jeeppler commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1317173715


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   @garydgregory any chance you can have a look at it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] JuditKnoll commented on pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "JuditKnoll (via GitHub)" <gi...@apache.org>.
JuditKnoll commented on PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#issuecomment-1582499502

   This fix seems to solve problem. It works on my machine.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] JuditKnoll commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "JuditKnoll (via GitHub)" <gi...@apache.org>.
JuditKnoll commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1288233929


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   Since none of the existing arrays could be reused here because of the different values, the renaming should be in a separate PR, not in this one. In the [JVM specification](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2) these short names are introduced as field descriptors, but that name may cause some confusion with the field and it rather refers to the type of the fields.
   As far as I can see, this particular "array" contains the primitive or base types, but naming it is the privilege of the author.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] nbauma109 commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "nbauma109 (via GitHub)" <gi...@apache.org>.
nbauma109 commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1271763738


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   The array has different values 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] Jeeppler commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "Jeeppler (via GitHub)" <gi...@apache.org>.
Jeeppler commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1309221035


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   @nbauma109 any chance you could look at the proposed solution by @JuditKnoll : https://github.com/apache/commons-bcel/pull/221#discussion_r1288233929



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] JuditKnoll commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "JuditKnoll (via GitHub)" <gi...@apache.org>.
JuditKnoll commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1287197695


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   I couldn't find any array containing these exact short names. The mentioned [SHORT_NAMES](https://github.com/apache/commons-bcel/blob/d256a461b40e91569961ae02ad3f33dd51814024/src/main/java/org/apache/bcel/generic/InstructionFactory.java#L55) misses `Z`, and `J`, but contains `L` additionally. The `SHORT_TYPE_NAMES` in [Consts](https://github.com/apache/commons-bcel/blob/master/src/main/java/org/apache/bcel/Const.java#L2851) and [Constants](https://github.com/apache/commons-bcel/blob/master/src/main/java/org/apache/bcel/Constants.java#L2364) both contain `V` and `ILLEGAL_TYPE` unnecessarily. There are constants for the short names individually in [ElementValue](https://github.com/apache/commons-bcel/blob/master/src/main/java/org/apache/bcel/classfile/ElementValue.java#L65), but I'm not sure using those would help a lot.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] garydgregory commented on pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#issuecomment-1582606529

   @JuditKnoll 
   Good to know. I'll take a look this weekend.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] codecov-commenter commented on pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#issuecomment-1721854682

   ## [Codecov](https://app.codecov.io/gh/apache/commons-bcel/pull/221?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#221](https://app.codecov.io/gh/apache/commons-bcel/pull/221?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (c1e615d) into [master](https://app.codecov.io/gh/apache/commons-bcel/commit/de3f85821dd82202d90331730bd1ca791e545d73?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (de3f858) will **increase** coverage by `0.02%`.
   > Report is 64 commits behind head on master.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #221      +/-   ##
   ============================================
   + Coverage     64.73%   64.75%   +0.02%     
   - Complexity     3872     3878       +6     
   ============================================
     Files           364      364              
     Lines         15666    15675       +9     
     Branches       1943     1946       +3     
   ============================================
   + Hits          10142    10151       +9     
     Misses         4602     4602              
     Partials        922      922              
   ```
   
   
   | [Files Changed](https://app.codecov.io/gh/apache/commons-bcel/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [src/main/java/org/apache/bcel/Const.java](https://app.codecov.io/gh/apache/commons-bcel/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2JjZWwvQ29uc3QuamF2YQ==) | `96.77% <ø> (ø)` | |
   | [src/main/java/org/apache/bcel/generic/LDC.java](https://app.codecov.io/gh/apache/commons-bcel/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2JjZWwvZ2VuZXJpYy9MREMuamF2YQ==) | `80.85% <100.00%> (ø)` | |
   | [src/main/java/org/apache/bcel/generic/Type.java](https://app.codecov.io/gh/apache/commons-bcel/pull/221?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2JjZWwvZ2VuZXJpYy9UeXBlLmphdmE=) | `85.80% <100.00%> (+0.77%)` | :arrow_up: |
   
   ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/apache/commons-bcel/pull/221/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] JuditKnoll commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "JuditKnoll (via GitHub)" <gi...@apache.org>.
JuditKnoll commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1326918479


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   @garydgregory can you please look at this PR?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] garydgregory commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1287721741


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   Hi all,
   I'm looking for clarity when reading the code. A hard coded array of strings is bad. Having a good name for a constant would help, and SHORT_NAMES is not a good name when the class is Constants or Consts. Any improvement is appreciated. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] nbauma109 commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "nbauma109 (via GitHub)" <gi...@apache.org>.
nbauma109 commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1309298059


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   @garydgregory is it ok now ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] garydgregory merged pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #221:
URL: https://github.com/apache/commons-bcel/pull/221


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] garydgregory commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1271335243


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   I'm not crazy about this magic list of strings. Could we reuse or refactor `org.apache.bcel.generic.InstructionFactory.SHORT_NAMES` (by making it public)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] hazendaz commented on pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "hazendaz (via GitHub)" <gi...@apache.org>.
hazendaz commented on PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#issuecomment-1646643308

   @garydgregory Any status on this fix?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] Jeeppler commented on pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "Jeeppler (via GitHub)" <gi...@apache.org>.
Jeeppler commented on PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#issuecomment-1722798689

   @garydgregory thanks 👍 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] nbauma109 commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "nbauma109 (via GitHub)" <gi...@apache.org>.
nbauma109 commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1309296078


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   InstructionFactory.SHORT_NAMES wasn't a good fit but Const.SHORT_TYPE_NAMES looks better suited



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-bcel] garydgregory commented on a diff in pull request #221: Fix for type.getType(...) use on non-signature type names

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #221:
URL: https://github.com/apache/commons-bcel/pull/221#discussion_r1317176598


##########
src/main/java/org/apache/bcel/generic/Type.java:
##########
@@ -365,6 +366,24 @@ public int hashCode() {
         return type ^ signature.hashCode();
     }
 
+    static String internalTypeNameToSignature(final String internalTypeName) {
+        if (StringUtils.isEmpty(internalTypeName) || StringUtils.equalsAny(internalTypeName, "B", "C", "D", "F", "I", "J", "S", "Z")) {
+            return internalTypeName;

Review Comment:
   Sometime this week...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org