UE3-UnrealScript throw: Error, Code space for [FunctionName] overflowed by 77 bytes - overflow

Code as follows
enum Type
{
...
...
...
NewEnumValue, // new value
}
var() array<class<Inventory>> ArrayClasses;
function Test()
{
ArrayClasses[TypeValue] = class<Inventory>(..., class'Class');
...
...
...
ArrayClasses[NewEnumValue] = class<Inventory>(..., class'Class');
} // throw error
Assign values to array by enumeration, now thown error:
Error, Code space for [FunctionName] overflowed by 77 bytes.
This enum count be exceed 500. When I add the 'NewEnumValue' to TypeEnum, and assign value in Test Function, throw error in this line, What the happen?

I found the answer.
Too many lines of code in the method, More than 708 lines will throw this error.
But I don't know why :(

Related

Laravel Cache seems don't work properly

I'm new to Laravel. I use Cache Facade to cache some data on the server, the cache driver is "file". Below is part of my code has problem:
// at the very beginning, forget the cache item, and run only once
if (Cache::has('votes_record')) {
Cache::forget('votes_record');
}
...
...
line 147 if (Cache::has('votes_record')) {
line 148 $votes_record = Cache::get('votes_record');
line 149 if (array_key_exists($input['From'], $votes_record)){
// do something here
}
} else {
// first time, create this array
$score = 0;
$votes_record = array(
$input['From'] => array(
'score' => $score,
)
)
Cache::put('votes_record', $votes_record, 60);
}
above code (from line 147) will run multiple times, this is the error message: exception 'ErrorException' with message 'array_key_exists() expects parameter 2 to be array, null given' in /app/Http/Controllers/VotesController.php:149
So it said the $votes_record is null, but I check if this Cache item exists on line 147, and it pass the check, so it means the Cache item exists, why it return null on line 148?
above error doesn't happen all the time, it looks happen randomly, when there are a lot of requests to call this piece of code(from line 147),
Thanks!

Appending a byte into a byte array in Java Card

I have a method below to insert a single byte into a byte buffer and during building and cleaning for a Java Card CAP file it throws an error.
Code:
private void appendOutputBuffer(byte msg) {
ArrayLogic.arrayCopyRepack(msg, (short) 0, (short) 0, outputBuffer, (short) outputBuffer.length);
}
Error:
error: line 163: sctest: class java.lang.Byte not found in export file lang.exp.
error: line 163: sctest: method valueOf(byte) of class java.lang.Byte not found in export file lang.exp or the method signature has changed.
error: line 163: sctest: class java.lang.Byte not found in export file lang.exp.
error: line 163: sctest: class java.lang.Byte in return type of method java.lang.Byte.valueOf(byte) not found.
How do I resolve it ?
This is not how arrayCopyRepack works. Read the documentation: http://www.win.tue.nl/pinpasjc/docs/apis/jc222/javacardx/framework/util/ArrayLogic.html#arrayCopyRepack%28java.lang.Object,%20short,%20short,%20java.lang.Object,%20short%29
Its signature is:
public static final short arrayCopyRepack(Object src,
short srcOff,
short srcLen,
Object dest,
short destOff)
but the src argument is meant to be an array - it is an Object just because there is no common ancestor class for all primitive arrays in Java Card. Not everything in Java Card is an Object: byte is a primitive. That causes your troubles.
The first step of Java Card build is a common Java compiler creating a standard .class file. This compiler does not know anything about Java Card and it sees a byte used as an Object, so it uses autoboxing, casting your byte to java.lang.Byte and adding a dependence to java.lang.Byte in your .class file. So far so good. This is just plain Java, so it works.
However, in Java Card libraries there is no java.lang.Byte in java.lang package. That causes the error when creating a .cap file.
Appending a byte to an existing array (and thus creating a new array) is a very bad idea, btw. You should create your buffer long enough and store the effective length (how long is the used part of the buffer):
private static final short BUF_LEN = (short) 256;
byte[] outputBuffer = new byte[BUF_LEN];
...
private void appendOutputBuffer(byte msg) {
if (effectiveLen == BUF_LEN)
ISOException.throwIt(ISO7816.SW_UNKNOWN);
outputBuffer[effectiveLen] = msg;
++effectiveLen;
}
and think about RAM vs EEPROM storing of both outputBuffer and effectiveLen.

Custom TemplateExceptionHandler

I need to change the FreeMarker behavior about processing template&data in case some data are missing.
In missing case I need to let the template unchanged and continue in processing.
Example:
Template:
...
var1 = ${var1}
var2 = ${var2}
...
Data:
var1 = Hello
I need Result after processing:
...
var1 = Hello
var2 = ${var2}
...
My solution is:
class MyTemplateExceptionHandler implements TemplateExceptionHandler {
public void handleTemplateException(TemplateException te, Environment env, java.io.Writer out)
throws TemplateException {
try {
//2nd word on 2nd row is name of missing variable :(
String missingVariable = te.getMessageWithoutStackTop().split("\n")[1].split(" ")[1];
out.write("${" + missingVariable + "}");
} catch (IOException e) {
throw new TemplateException("Failed to print error message. Cause: " + e, env);
}
} }
and using:
...
Configuration cfg = new Configuration();
cfg.setTemplateExceptionHandler(new MyTemplateExceptionHandler());
...
My solution works, but I am not satisfied because of:
1) getting missing variable in handleTemplateException() is horrible. Does exist better way how to get a name of missing variable?
2) Even if I have my own TemplateExceptionHandler, FreeMarker writes enough information to output. Can I change it?
Example output for missing variable "environment_name":
22.10.2014 9:01:55 freemarker.log._JDK14LoggerFactory$JDK14Logger error
SEVERE: Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> environment_name [in template "Osb-PrepareAndDeploy.ftl" at line 33, column 33]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (FTL stack trace):
----------
==> ${environment_name} [in template "Osb-PrepareAndDeploy.ftl" at line 33, column 31]
----------
Java stack trace (for programmers):
----------
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:98)
at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.java:382)
at freemarker.core.Expression.evalAndCoerceToString(Expression.java:115)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:265)
at freemarker.core.MixedContent.accept(MixedContent.java:93)
at freemarker.core.Environment.visit(Environment.java:265)
at freemarker.core.Environment.process(Environment.java:243)
at freemarker.template.Template.process(Template.java:277)
at net.homecredit.scm.jenkinsTool.countrySettings.Country.createJobs(Country.java:282)
at net.homecredit.scm.jenkinsTool.Start.main(Start.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
You can't prevent the exception from being logged. TemplateExceptionHandler doesn't mean to make non-error from an error, it just lets you decide what to do after the error has happened. Like, you want to print an error page or something. In extreme case, you may want to continue page rendering after printing some error indicator, but that's still an error that need to be fixed.
Maybe it would help if you tell why do you need this. Maybe the solution isn't TemplateExceptionHandler-s.
As of more intelligent exception processing, first, in the handler you should check if the exception is a InvalidReferenceException, becaue I guess you don't want to deal with others. Then, with getBlamedExpressionString() (requires FreeMarker 2.3.21) you could get part of what you want to print to the output. It's only part of that, because if ${x + 1} fails because x is undefined, it will only return "x", not "x + 1".

Error: Compile Error: expecting a colon, found 'vInvReq.JDRF_Location__c' at line 16 column 13

I am getting this error while compiling this trigger,
Error: Compile Error: expecting a colon, found 'vInvReq.JDRF_Location__c' at line 16 column 13
My code below, problem is with this line WHERE Name=vInvReq.JDRF_Location__c]);
Thanks and appreciate any help,
trigger TgrInventoryRequestAfter on Inventory_Request__c (after update) {
//set<Id> JDRFLocationId = new set<Id>();
//List<Inventory_Request__c> vLstInventory_Request= new List<Inventory_Request__c>();
List<JDRF_Location__c> locaList = new list<JDRF_Location__c>();
for (Inventory_Request__c vInvReq:trigger.new)
{
if(vInvReq.Request_Status__c == 'Approved' && vInvReq.Inventory_Type__c == 'Bag of Hope')
{
locaList=
new list<JDRF_Location__c> ([Select Name,Current_boh_Inventory__c from JDRF_Location__c
WHERE Name=vInvReq.JDRF_Location__c]);
Integer sumCBOH = vInvReq.Units_Requested__c+ locaList.Current_boh_Inventory__c ;
locaList.Current_boh_Inventory__c= sumCBOH;
}
}
Put =: after WHERE in between the field name and the variable:
WHERE Name=:vInvReq.JDRF_Location__c
Here is why:
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_variables.htm

how to interpret the error codes of boost::mpi?

How to make sense of the boost::mpi error code? For instance, what does error code 834983239 mean?
...
mpi::communicator world;
mpi::request req = world.isend(1, 1, std::string("hello"));
while(!req.test()) {
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
int errorCode = req.test()->error();
...
The error code is unlikely to be filled in if there was not an error (and the default behavior for Boost.MPI is to throw an exception on error, not return a code). You should not need to check error codes manually unless you have changed Boost.MPI's default error handling settings.

Resources