# Automatically 'camelCase' method names for Java targets

**URL:** https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249
**Category:** Oxygene
**Tags:** java, cooper
**Created:** [August 23, 2018, 5:44am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249 "2018-08-23T05:44:27Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [August 23, 2018, 5:44am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/1 "2018-08-23T05:44:27Z")

</div>

Hi Carlo & all,

We have a large base of Oxygene code, with a Pascal style naming convention used throughout. So far, our primary target for that code was .NET, hence the choice of the naming convention.

Now, we are looking to compile this code for Java targets as well. Our main concern are method names, which we want in this case to comply with Java best practices and so use camelCase and not PascalCase when compiled. Renaming the methods in code is not an option as we want to keep PascalCase for our .NET targets for the same methods.

Is there any hidden option available to achieve our goal? If not, would it be possible to have this feature in Elements compiler?

Thanks!

Ken

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [August 23, 2018, 7:18am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/2 "2018-08-23T07:18:50Z")

</div>

Good question… There’s no such option currently, however you could easily accomplish it with a simple aspect, something like:

```auto
namespace ClassLibrary1;

interface
uses 
  RemObjects.Elements.Cirrus.*;

type
  [AttributeUsage(AttributeTargets.Assembly or AttributeTargets.Class or AttributeTargets.Method)]
  MethodFormatterAspect = public class(Attribute, IMethodInterfaceDecorator)
  private
  protected
  public
    method HandleInterface(Services: IServices; aMethod: IMethodDefinition);
    begin 
      var lName := aMethod.Name;
      if (length(lName) > 2) and Char.IsUpper(lName[0]) and (Char.IsLower(lName[1])) then begin
        lName := lName.Substring(0, 1).ToLowerInvariant + lName.Substring(1);
        aMethod.Name := lName;
      end;
    end;
  end;

implementation

end.

```

(Seems there’s a bug in ebuild references to Cirrus libs which I’ve logged which makes this not work, once it’s fixed i’ll update this post)

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [August 23, 2018, 10:52am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/3 "2018-08-23T10:52:31Z")

</div>

Thanks Carlo, the Cirrus-based approach looks very interesting. We didn’t use Cirrus before, so my next question may be quite lame, but do I understand right that Cirrus is a fully build-time tool, i.e. using Cirrus aspects won’t make our compiled binaries dependent on Cirrus?

Thanks!

Ken

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 23, 2018, 10:57am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/4 "2018-08-23T10:57:12Z")

</div>

correct.

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [August 23, 2018, 11:00am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/5 "2018-08-23T11:00:52Z")

</div>

Cool, thanks Marc!

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [September 5, 2018, 11:17am UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/6 "2018-09-05T11:17:20Z")

</div>

Hi Carlo,

Has the references issue been fixed yet? We are eager to try Cirrus :).

Thanks!

Ken

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [September 5, 2018, 1:07pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/7 "2018-09-05T13:07:46Z")

</div>

It’s fixed on the ebuild level (so building should be fine); It also works as project reference, but not regular reference in the VS ide yet (but is fine in the file); that part is still open.

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [September 5, 2018, 1:10pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/8 "2018-09-05T13:10:35Z")

</div>

Great, thanks! We’re building everything from command line, so should be ok for us. Is it included in build 10.0.0.2321?

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [September 5, 2018, 1:35pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/9 "2018-09-05T13:35:58Z")

</div>

yes 2321 should be fine.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 5, 2018, 3:01pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/10 "2018-09-05T15:01:42Z")

</div>

No, .2323.

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [October 3, 2018, 12:30pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/11 "2018-10-03T12:30:55Z")

</div>

Hi Carlo, Marc,

So I’ve finally set up my ebuild-driven processes and am ready to continue with this goal. I started with writing a simple aspect as Carlo had suggested above, and packed that into an Elements .NET project, as suggested [here](https://docs.elementscompiler.com/Concepts/Aspects/GettingStarted/). That compiles just fine into a tiny .NET assembly (MyCirrusAspects.dll).

Now, I want to plug that aspect in when compiling my Oxygene code for Java platform to camelise the names. This is where I’m stuck. What would be the right way to reference the aspect assembly in my Elements project? I tried referencing MyCirrusAspects.dll via “Reference Include=…” but that gives me “Reference 'MyCirrusAspects” could not be resolved for target ‘Cooper’ (Cooper Plain jvm)." I believe some special trick is needed here to pass a .NET assembly to the compiler when compiling a Java target, is that correct?

I tried to find an answer in the docs and samples but unfortunately without luck. Could you please help?

I am using EBuild version 10.0.0.2331.

Thanks!

Ken

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 3, 2018, 12:50pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/12 "2018-10-03T12:50:30Z")

</div>

> [@kenivanov](#):
>
> What would be the right way to reference the aspect assembly in my Elements project? I tried referencing MyCirrusAspects.dll via “Reference Include=…” but that gives me “Reference 'MyCirrusAspects” could not be resolved for target ‘Cooper’ (Cooper Plain jvm)." I believe some special trick is needed here to pass a .NET assembly to the compiler when compiling a Java target, is that correct?

No, this should just work as is, the was fixed a few weeks ago. Can you send me your solution so i can have a look at why it doesn’t;t work for you? Is this a project reference or a regular .dll reference?

thanx,  
marc

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [October 3, 2018, 12:52pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/13 "2018-10-03T12:52:41Z")

</div>

something like:

```auto

    <Reference Include="ClassLibrary1.dll">
      <Private>True</Private>
      <Cirrus>True</Cirrus>
      <HintPath>..\ClassLibrary1\Bin\Debug\ClassLibrary1.dll</HintPath>
    </Reference>

```

should work for you. IsCirrusref is the key here.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 3, 2018, 12:54pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/14 "2018-10-03T12:54:22Z")

</div>

`Cirrus` shouldn’t even matter, afaik.

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [October 3, 2018, 1:14pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/15 "2018-10-03T13:14:13Z")

</div>

Thanks for your quick replies guys! It was actually HintPath that I was missing. For some reason EBuild didn’t find the aspect DLL by its name, even though it was residing in one of AdditionalReferencePaths directories. I guess that should’ve been because building a Cooper target it was looking for .jars and not .dlls. Anyway, the things do compile just fine now.

On a side note, Marc, you were correct, the Cirrus flag didn’t matter.

Thanks!

---

<div class="post-metadata">

### Author: ![kenivanov](https://talk.remobjects.com/user_avatar/talk.remobjects.com/kenivanov/32/8394_2.png) [@kenivanov](https://talk.remobjects.com/u/kenivanov)
#### Post date: [October 3, 2018, 1:25pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/16 "2018-10-03T13:25:34Z")

</div>

Just a quick follow-up - I can confirm that the aspect is actually picked up and applied just as we expect it to. Thanks again for all your help!

Ken

---

<div class="post-metadata">

### Author: ![ck](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ck/32/8740_2.png) [@ck](https://talk.remobjects.com/u/ck)
#### Post date: [October 3, 2018, 1:26pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/17 "2018-10-03T13:26:09Z")

</div>

Let us know if you have some problems with the aspect logic.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [October 3, 2018, 3:52pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/18 "2018-10-03T15:52:18Z")

</div>

> [@kenivanov](#):
>
> For some reason EBuild didn’t find the aspect DLL by its name, even though it was residing in one of AdditionalReferencePaths directories.

Yeah, those are checked for platform references only. Cirrus references are only located directly or via the explicit CirrusReferences xml files. I suppose I could/should add an additional setting one can provide for cirrus search paths. I’ll log an issue.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [October 3, 2018, 3:52pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/19 "2018-10-03T15:52:25Z")

</div>

Thanks, logged as bugs://81137

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [November 7, 2018, 4:30pm UTC](https://talk.remobjects.com/t/automatically-camelcase-method-names-for-java-targets/17249/20 "2018-11-07T16:30:05Z")

</div>

bugs://81137 got closed with status wontfix.
