Clojure

Function names not munged in :gen-class

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.2
  • Component/s: None
  • Labels:
    None
  • Approval:
    Ok

Description

A function name with a dash in the :methods list isn't properly munged when using compile/gen-class. This results in a method in the byte code that is not callable from Java.

Offending code:

(ns foo.bar
(:gen-class
:methods [[foo-bar [] void]]))

(defn -foo-bar [] (println "a"))

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - stu said: [file:by19VCMomr360aeJe5cbCb]
Hide
Assembla Importer added a comment -

stu said: patch fixes this by disallowing it. I don't think we should munged in methods names in gen-class – callers are already forced to Java names by any Java methods they implement, so better to be consistent.

patch also piggybacks some unrelated test refactoring

Show
Assembla Importer added a comment - stu said: patch fixes this by disallowing it. I don't think we should munged in methods names in gen-class – callers are already forced to Java names by any Java methods they implement, so better to be consistent. patch also piggybacks some unrelated test refactoring
Hide
Assembla Importer added a comment -

richhickey said: Seems to specifically single out '-' rather than ensure a valid Java name

Show
Assembla Importer added a comment - richhickey said: Seems to specifically single out '-' rather than ensure a valid Java name
Hide
Assembla Importer added a comment -

stu said: How far do we go here? A complete implementation would need to

  • use the isJavaIdentifierPart / isJavaIdentifierStart methods of Character
  • enumerate the characters as code points (bring in c.c.string/codepoints? if so, as public fn?)
  • blacklist keywords, boolean literals, null literal
Show
Assembla Importer added a comment - stu said: How far do we go here? A complete implementation would need to
  • use the isJavaIdentifierPart / isJavaIdentifierStart methods of Character
  • enumerate the characters as code points (bring in c.c.string/codepoints? if so, as public fn?)
  • blacklist keywords, boolean literals, null literal
Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - stu said: [file:cje20uM0Cr35VBeJe5cbLA]
Hide
Assembla Importer added a comment -

stu said: second patch uses munge

Show
Assembla Importer added a comment - stu said: second patch uses munge

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: